| using System; | 
| using System.Collections.Generic; | 
| using System.ComponentModel; | 
| using System.Data; | 
| using System.Drawing; | 
| using System.Text; | 
| using System.Windows.Forms; | 
| using SQLHelper; | 
|   | 
| namespace DBUtility | 
| { | 
|     public partial class frmHlpBillList : Form | 
|     { | 
|         public frmHlpBillList() | 
|         { | 
|             InitializeComponent(); | 
|         } | 
|         public  string ViewName; | 
|         public string tSQL; | 
|         public frmBillQueryCondition_New frmCondition; | 
|         public string sPrimaryCol; | 
|         public Pub_Class.ClsPub.Enum_OKTag OKTag; | 
|         public string sBillName=""; | 
|         //³õʼ»¯GRID | 
|         private void initGrid() | 
|         { | 
|             grdMain.Cols = 1; | 
|             grdMain.Rows = 1; | 
|             grdMain.FixedCols = 1; | 
|             grdMain.FixedRows = 1; | 
|              | 
|             //grdMain.ExplorerBar = VSFlex7.ExplorerBarSettings.flexExSortAndMove; | 
|             grdMain.AllowBigSelection = false; | 
|             grdMain.AllowSelection = true; | 
|             grdMain.SelectionMode = VSFlex7.SelModeSettings.flexSelectionByRow; | 
|             grdMain.ScrollTrack = true; | 
|             grdMain.WordWrap = true; | 
|             grdMain.set_ColWidth(-1, 1500); | 
|             grdMain.set_RowHeight(-1, 400); | 
|             grdMain.set_RowHeight(0, 500); | 
|             grdMain.RowHeightMin = 250; | 
|             grdMain.Editable = VSFlex7.EditableSettings.flexEDNone; | 
|             grdMain.AllowUserResizing = VSFlex7.AllowUserResizeSettings.flexResizeBoth; | 
|             grdMain.AllowUserFreezing = VSFlex7.AllowUserFreezeSettings.flexFreezeBoth; | 
|             grdMain.set_FixedAlignment(-1, VSFlex7.AlignmentSettings.flexAlignCenterCenter); | 
|             grdMain.AutoSizeMode = VSFlex7.AutoSizeSettings.flexAutoSizeColWidth; | 
|             grdMain.GridLines = VSFlex7.GridStyleSettings.flexGridFlatVert; | 
|         } | 
|         //ÏÔʾÄÚÈÝ | 
|         private void Display() | 
|         { | 
|             ClsCN SubCn = new ClsCN(); | 
|             DataSet DSet ; | 
|             int AddCol = 1; | 
|             grdMain.Rows = grdMain.FixedRows; | 
|             string sSql = ""; | 
|             string sWhere =tSQL; | 
|             //¹ýÂËÌõ¼þ | 
|             if (frmCondition.SqlStr.Trim().Length == 0) | 
|                 return; | 
|             sSql = frmCondition.SqlStr + sWhere ; | 
|             // | 
|             DSet = SubCn.RunProcReturn(sSql, ViewName); | 
|             //Éú³ÉÊ×ÐбêÌâ | 
|             if (DSet.Tables[0].Rows.Count == 0) | 
|             { | 
|                 grdMain.Redraw = VSFlex7.RedrawSettings.flexRDBuffered; | 
|                 return; | 
|             } | 
|             // | 
|             grdMain.Redraw = VSFlex7.RedrawSettings.flexRDNone; | 
|             // | 
|             grdMain.Cols = DSet.Tables[0].Columns.Count + grdMain.FixedCols + AddCol; | 
|             grdMain.set_TextMatrix(0, grdMain.FixedCols - 1, "ÐòºÅ"); | 
|             grdMain.set_TextMatrix(0, grdMain.FixedCols - 1+AddCol, "Ñ¡Ôñ"); //ÉèÖà×Ô¶¨ÒåÁÐ | 
|             grdMain.set_ColWidth(0, 500); | 
|             for (int i = 0; i <= DSet.Tables[0].Columns.Count - 1; i++) | 
|             { | 
|                 grdMain.set_TextMatrix(0, i + grdMain.FixedCols + AddCol, DSet.Tables[0].Columns[i].Caption); | 
|                 if (DSet.Tables[0].Columns[i].Caption.ToLower().Substring(0, 1) == "h") //Ê××ÖĸΪhÔòÒþ²Ø | 
|                 { | 
|                     grdMain.set_ColHidden(i + grdMain.FixedCols + AddCol, true); | 
|                 } | 
|                 else | 
|                 { | 
|                     grdMain.set_ColHidden(i + grdMain.FixedCols + AddCol, false); | 
|                     grdMain.set_ColWidth(i + grdMain.FixedCols + AddCol, 1000); | 
|                 } | 
|             } | 
|   | 
|             //Ìî³äÍø¸ñ | 
|             string s = ""; | 
|             grdMain.Rows = DSet.Tables[0].Rows.Count + grdMain.FixedRows; | 
|             for (int i = 0; i <= DSet.Tables[0].Rows.Count - 1; i++) | 
|             { | 
|                 grdMain.set_TextMatrix(i + grdMain.FixedRows, 0, (i + grdMain.FixedRows).ToString()); //ÐкŠ| 
|                 for (int j = 0; j <= DSet.Tables[0].Columns.Count - 1; j++) | 
|                 { | 
|                     s = DSet.Tables[0].Rows[i][j].ToString(); | 
|                     grdMain.set_TextMatrix(i + grdMain.FixedRows, j + grdMain.FixedCols + AddCol, s); | 
|                 } | 
|             } | 
|             //ºÏ¼Æ | 
|             grdMain.SubtotalPosition = VSFlex7.SubtotalPositionSettings.flexSTBelow; | 
|             for (int i = 0; i <= DSet.Tables[0].Columns.Count - 1; i++) | 
|             { | 
|                 if (DSet.Tables[0].Columns[i].DataType.ToString() == "System.Double" || | 
|                     DSet.Tables[0].Columns[i].DataType.ToString() == "System.Single" || | 
|                     DSet.Tables[0].Columns[i].DataType.ToString() == "System.Decimal" | 
|                     ) | 
|                 { | 
|                     //ÈôΪÊýÖµÔò ÓÒ¶ÔÆë²¢ÇÒºÏ¼Æ | 
|                     grdMain.set_ColFormat(i + grdMain.FixedCols + AddCol, "###,###,##0.##"); | 
|                     grdMain.Subtotal(VSFlex7.SubtotalSettings.flexSTSum, -1, i + grdMain.FixedCols + AddCol, "###,###,##0.00", 15197644, 0, true, "ºÏ¼Æ", 2, false); | 
|                     grdMain.set_ColAlignment(i + grdMain.FixedCols + AddCol, VSFlex7.AlignmentSettings.flexAlignRightCenter); | 
|                 } | 
|                 else if (DSet.Tables[0].Columns[i].DataType.ToString() == "System.Int16" || | 
|                         DSet.Tables[0].Columns[i].DataType.ToString() == "System.Int32" || | 
|                         DSet.Tables[0].Columns[i].DataType.ToString() == "System.Int64") | 
|                 { | 
|                     //ÈôΪÊýÖµÔò ÓÒ¶ÔÆë²¢ÇÒºÏ¼Æ | 
|                     grdMain.Subtotal(VSFlex7.SubtotalSettings.flexSTSum, -1, i + grdMain.FixedCols + AddCol, 0, 15197644, 0, true, "ºÏ¼Æ", 2, false); | 
|                     grdMain.set_ColAlignment(i + grdMain.FixedCols + AddCol, VSFlex7.AlignmentSettings.flexAlignRightCenter); | 
|                 } | 
|                 else | 
|                 { | 
|                     //·ÇÊýÖµ Ôò×ó¶ÔÆë | 
|                     grdMain.set_ColAlignment(i + grdMain.FixedCols + AddCol, VSFlex7.AlignmentSettings.flexAlignLeftCenter); | 
|                 } | 
|             } | 
|             //¹Ì¶¨ÐРÖмä¶ÔÆë | 
|             grdMain.set_FixedAlignment(-1, VSFlex7.AlignmentSettings.flexAlignCenterCenter); | 
|             //¼ÓÔØÁпí | 
|             ClsPub.GetGrid(this.grdMain, this.Name,ClsPub.AppPath); | 
|             //»Ïß | 
|             GraphLine(); | 
|             // | 
|             grdMain.FrozenCols = 2; | 
|             grdMain.Redraw = VSFlex7.RedrawSettings.flexRDBuffered; | 
|         } | 
|   | 
|         private void timer1_Tick(object sender, EventArgs e) | 
|         { | 
|             timer1.Enabled = false; | 
|             initGrid(); | 
|             Display(); | 
|         } | 
|   | 
|         private void tc_Click(object sender, EventArgs e) | 
|         { | 
|             OKTag = Pub_Class.ClsPub.Enum_OKTag.OKTag_Cancel; | 
|             this.Visible = false; | 
|         } | 
|   | 
|         private void sx_Click(object sender, EventArgs e) | 
|         { | 
|             timer1.Enabled = true; | 
|         } | 
|         //ÕÒµ½¶ÔÓ¦ÁÐ | 
|         public Int32 Fun_GetCol(string sCol) | 
|         { | 
|             for (int c = 0; c < grdMain.Cols; c++) | 
|             { | 
|                 if (ClsPub.isStrNull(grdMain.get_TextMatrix(0, c)).ToUpper().Trim() == sCol.Trim().ToUpper()) | 
|                 { | 
|                     return c; | 
|                 } | 
|             } | 
|             return 0; | 
|         } | 
|   | 
|         private void frmHlpBillList_Load(object sender, EventArgs e) | 
|         { | 
|             frmCondition = new frmBillQueryCondition_New(); | 
|             initGrid(); | 
|         } | 
|   | 
|         private void cx_Click(object sender, EventArgs e) | 
|         { | 
|             frmCondition = new frmBillQueryCondition_New(); | 
|             frmCondition.Tag = ""; | 
|             frmCondition.ViewName = ViewName; | 
|             frmCondition.ModName = this.Name; | 
|             frmCondition.ShowDialog(); | 
|             if (frmCondition.Tag.ToString() == "OK") | 
|             { | 
|                 Display(); | 
|             } | 
|         } | 
|   | 
|         private void bclk_Click(object sender, EventArgs e) | 
|         { | 
|             //±£´æÁпí | 
|             ClsPub.SaveGrid(grdMain, this.Name, ClsPub.AppPath); | 
|         } | 
|   | 
|         private void mrlk_Click(object sender, EventArgs e) | 
|         { | 
|             grdMain.AutoSize(0, grdMain.Cols - 1, false, 1); | 
|             //²ÎÊý½âÊÍ  ¿ªÊ¼ÁР£¬½áÊøÁУ¬ÊÇ·ñÒÔ×î´óÁпíΪ׼£¬×îСÁпí | 
|             ClsPub.SaveGrid(grdMain, this.Name, ClsPub.AppPath); | 
|         } | 
|         //»®Ïß | 
|         private void GraphLine()  //Lock | 
|         { | 
|             //ÕÒµ½Ö÷±íIDºÍ×Ó±íIDµÄ ·¶Î§ | 
|             int MainIDCol = Fun_GetCol("hmainid"); | 
|             int SubIDCol = Fun_GetCol("hsubid"); | 
|             long HMainID = 0; | 
|             //Ñ»·ËùÓÐÐÐ | 
|             for (int i = grdMain.FixedRows; i < grdMain.Rows - 1; i++) | 
|             { | 
|                 if (HMainID == 0) | 
|                 { | 
|                     HMainID = ClsPub.isLong(grdMain.get_ValueMatrix(i, MainIDCol).ToString()); | 
|                 } | 
|                 else | 
|                 { | 
|                     if (HMainID == ClsPub.isLong(grdMain.get_ValueMatrix(i, MainIDCol).ToString())) | 
|                     { | 
|                         //grdMain.set_Cell(VSFlex7.CellPropertySettings.flexcpText, i, MainIDCol + 1, i, SubIDCol - 1, ""); | 
|   | 
|                     } | 
|                     else | 
|                     { | 
|                         HMainID = ClsPub.isLong(grdMain.get_ValueMatrix(i, MainIDCol).ToString()); | 
|                         grdMain.Select(i, grdMain.FixedCols, i, grdMain.Cols - 1); | 
|                         grdMain.CellBorder(16755034, 0, 1, 0, 0, 0, 0); | 
|                     } | 
|                 } | 
|             } | 
|         } | 
|         //ÊÇ·ñÔÊÐí·µ»Ø | 
|         private bool AllowBack()  //Lock | 
|         { | 
|             string stmp=""; | 
|             int PrimaryCol; | 
|             int SelectCol = Fun_GetCol("Ñ¡Ôñ"); | 
|             if (sPrimaryCol.Trim() != "") | 
|             { | 
|                 PrimaryCol = Fun_GetCol(sPrimaryCol); | 
|                 if (PrimaryCol == 0) | 
|                 { | 
|                     return true; | 
|                 } | 
|                 else | 
|                 { | 
|                     for (int i = grdMain.FixedRows; i < grdMain.Rows; i++) | 
|                     { | 
|                         if (ClsPub.isStrNull(grdMain.get_TextMatrix(i, SelectCol)) == "*") | 
|                         { | 
|                             if (stmp == "") | 
|                             { | 
|                                 stmp = ClsPub.isStrNull(grdMain.get_TextMatrix(i, PrimaryCol)); | 
|                             } | 
|                             if(stmp!=ClsPub.isStrNull(grdMain.get_TextMatrix(i, PrimaryCol))) | 
|                                 return false; | 
|                         } | 
|                     } | 
|                 } | 
|             } | 
|             else | 
|             { | 
|                 return true; | 
|             } | 
|             return true; | 
|         } | 
|         //·µ»ØÐÅÏ¢ | 
|         private void Sub_DataBack() | 
|         { | 
|             if (!AllowBack()) | 
|             { | 
|                 MessageBox.Show("²»ÔÊÐíÑ¡Ôñ²»Í¬µÄ" + sPrimaryCol + "£¡", "Ìáʾ"); | 
|                 return; | 
|             } | 
|             OKTag = Pub_Class.ClsPub.Enum_OKTag.OKTag_OK; | 
|             this.Visible = false; | 
|         } | 
|         // | 
|         private void fh_Click(object sender, EventArgs e) | 
|         { | 
|             Sub_DataBack(); | 
|         } | 
|         //Ñ¡ÖÐÐÐ | 
|         private void Sub_SelectRow() | 
|         { | 
|             int SelectCol = Fun_GetCol("Ñ¡Ôñ"); | 
|             int BRow, ERow; | 
|             if (grdMain.Row >= grdMain.RowSel) | 
|             { | 
|                 BRow = grdMain.RowSel; | 
|                 ERow = grdMain.Row; | 
|             } | 
|             else | 
|             { | 
|                 ERow = grdMain.RowSel; | 
|                 BRow = grdMain.Row; | 
|             } | 
|             for (int i = BRow; i <= ERow; i++) | 
|             { | 
|                 grdMain.set_TextMatrix(i, SelectCol, "*"); | 
|             } | 
|         } | 
|         // | 
|         private void xz_Click(object sender, EventArgs e) | 
|         { | 
|             Sub_SelectRow(); | 
|         } | 
|         // | 
|         private void Sub_ClearRow() | 
|         { | 
|             int SelectCol = Fun_GetCol("Ñ¡Ôñ"); | 
|             int BRow, ERow; | 
|             if (grdMain.Row >= grdMain.RowSel) | 
|             { | 
|                 BRow = grdMain.RowSel; | 
|                 ERow = grdMain.Row; | 
|             } | 
|             else | 
|             { | 
|                 ERow = grdMain.RowSel; | 
|                 BRow = grdMain.Row; | 
|             } | 
|             for (int i = BRow; i <= ERow; i++) | 
|             { | 
|                 grdMain.set_TextMatrix(i, SelectCol, ""); | 
|             } | 
|         } | 
|         // | 
|         private void qc_Click(object sender, EventArgs e) | 
|         { | 
|             Sub_ClearRow(); | 
|         } | 
|   | 
|         private void timer2_Tick(object sender, EventArgs e) | 
|         { | 
|             timer2.Enabled = false; | 
|             frmCondition = new frmBillQueryCondition_New(); | 
|             frmCondition.Tag = ""; | 
|             frmCondition.ViewName = ViewName; | 
|             frmCondition.ModName = this.Name; | 
|             frmCondition.ShowDialog(); | 
|             if (frmCondition.Tag.ToString() == "OK") | 
|             { | 
|                 timer1.Enabled = true; | 
|             } | 
|         } | 
|         // | 
|         private void grdMain_DblClick(object sender, EventArgs e) | 
|         { | 
|             int SelectCol = Fun_GetCol("Ñ¡Ôñ"); | 
|             if (grdMain.Row >= grdMain.FixedRows && grdMain.Row <= grdMain.Rows - 2) | 
|             { | 
|                 if (ClsPub.isStrNull( grdMain.get_TextMatrix(grdMain.Row, SelectCol)) == "*") | 
|                 { | 
|                     grdMain.set_TextMatrix(grdMain.Row, SelectCol, ""); | 
|                 } | 
|                 else | 
|                 { | 
|                     grdMain.set_TextMatrix(grdMain.Row, SelectCol,"*") ; | 
|                 } | 
|             } | 
|         } | 
|     } | 
| } |