using System; 
 | 
using System.Collections.Generic; 
 | 
using System.ComponentModel; 
 | 
using System.Data; 
 | 
using System.Drawing; 
 | 
using System.Text; 
 | 
using System.Windows.Forms; 
 | 
  
 | 
namespace Pub_Control 
 | 
{ 
 | 
    public partial class frmBillQueryCondition_Base : Form 
 | 
    { 
 | 
        public frmBillQueryCondition_Base() 
 | 
        { 
 | 
            InitializeComponent(); 
 | 
        } 
 | 
        const int IDCol = 0; 
 | 
        const int BracketLCol = 1; 
 | 
        const int FieldNameCol = 2; 
 | 
        const int ControlCol = 3; 
 | 
        const int ConditionCol = 4; 
 | 
        const int BracketRCol = 5; 
 | 
        const int RelationCol = 6; 
 | 
        //gridorder  
 | 
        const Int16 OrFieldNameCol = 0; 
 | 
        const Int16 OrDescCol = 1; 
 | 
        //gridfield 
 | 
        const Int16 FiNoCol = 0; 
 | 
        const Int16 FiFieldNameCol = 1; //字段名 
 | 
        const Int16 FiShowCol = 2;      //是否显示列 
 | 
        const Int16 FiDuiQiCol = 3; //对齐方式列 
 | 
        const Int16 FiDecCol = 4;  //小数列 
 | 
        // 
 | 
        public string SqlStr=""; 
 | 
        public string FieldsArray = ""; 
 | 
        private string mvarViewName=""; 
 | 
        private int CopyRow=0; 
 | 
        private string CopyField=""; 
 | 
        private string CopyDataType = ""; 
 | 
        private bool Copyed; 
 | 
        public Form oFrm; 
 | 
        public string ViewName; 
 | 
        public string ModName; 
 | 
        public bool bFst; 
 | 
        Pub_Class.ClsSqlHelper oCn = new Pub_Class.ClsSqlHelper(); 
 | 
        Clsxt_ICSchemeMain oItem = new Clsxt_ICSchemeMain(); 
 | 
        public Pub_Class.ClsPub.Enum_BillStatus BillStatus; 
 | 
        //是否需要显示 记账和红蓝单 
 | 
        //当前选中方案ID 
 | 
        Int64 HInterID=0; 
 | 
  
 | 
  
 | 
        //初始化 2个GRID和一个LIST  将视图加载到GRID 
 | 
        public void SetViewName(string sViewName,bool b) 
 | 
        { 
 | 
            string[] tArray; 
 | 
            DataSet Ds=new DataSet(); 
 | 
            int j; 
 | 
            if( Pub_Class.ClsPub.isStrNull(sViewName).Length==0) 
 | 
            { 
 | 
                return; 
 | 
            }  
 | 
            mvarViewName = sViewName; 
 | 
            //得到视图 字段信息 
 | 
            Ds=oCn.RunProcReturn("select column_name,data_type from information_schema.columns where table_name ='" + ViewName.Trim() + "' order by  ORDINAL_POSITION", "information"); 
 | 
            //清空 
 | 
            grdCondition.RowCount = 1; 
 | 
            grdField.RowCount = 1; 
 | 
            grdOrder.RowCount = 1; 
 | 
            lstOrder.Items.Clear(); 
 | 
            // 
 | 
            for(int i=0;i<Ds.Tables[0].Rows.Count;i++) 
 | 
            { 
 | 
                //grid1 
 | 
                grdCondition.RowCount = i+1; 
 | 
                grdCondition.Rows[i].Cells[FieldNameCol].Value= Ds.Tables[0].Rows[i]["column_name"].ToString().Trim(); 
 | 
                grdCondition.Rows[i].Cells[IDCol].Value=Ds.Tables[0].Rows[i]["data_type"].ToString().Trim(); 
 | 
                // 
 | 
                DataGridViewComboBoxCell sCellRel = new DataGridViewComboBoxCell(); 
 | 
                sCellRel.FlatStyle = FlatStyle.System; 
 | 
                sCellRel.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing; 
 | 
                sCellRel.DropDownWidth = 10;  
 | 
                sCellRel.Items.Add("并且"); 
 | 
                sCellRel.Items.Add("或者"); 
 | 
                grdCondition.Rows[i].Cells[RelationCol] = sCellRel; 
 | 
                grdCondition.Rows[i].Cells[RelationCol].Value = "并且"; 
 | 
  
 | 
                // 
 | 
                DataGridViewComboBoxCell sCellCom = new DataGridViewComboBoxCell(); 
 | 
                sCellCom.FlatStyle = FlatStyle.System; 
 | 
                sCellCom.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing; 
 | 
                sCellCom.DropDownWidth =10; 
 | 
                sCellCom.Items.Add(" "); 
 | 
                sCellCom.Items.Add("="); 
 | 
                sCellCom.Items.Add(">"); 
 | 
                sCellCom.Items.Add(">="); 
 | 
                sCellCom.Items.Add("<"); 
 | 
                sCellCom.Items.Add("<="); 
 | 
                sCellCom.Items.Add("<>"); 
 | 
                sCellCom.Items.Add("包含"); 
 | 
                sCellCom.Items.Add("左包含"); 
 | 
                sCellCom.Items.Add("右包含"); 
 | 
                sCellCom.Items.Add("不包含"); 
 | 
                grdCondition.Rows[i].Cells[ControlCol] = sCellCom; 
 | 
                //对齐列 
 | 
                //grdfield 
 | 
                grdField.RowCount = i + 1; 
 | 
                DataGridViewComboBoxCell sCellDQ = new DataGridViewComboBoxCell(); 
 | 
                sCellDQ.FlatStyle = FlatStyle.System; 
 | 
                sCellDQ.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing; 
 | 
                sCellDQ.DropDownWidth = 10; 
 | 
                sCellDQ.Items.Add("左对齐"); 
 | 
                sCellDQ.Items.Add("居中"); 
 | 
                sCellDQ.Items.Add("右对齐"); 
 | 
                grdField.Rows[i].Cells[FiDuiQiCol] = sCellDQ; 
 | 
                 
 | 
                grdField.Rows[i].Cells[FiNoCol].Value=Convert.ToString(grdField.RowCount - 1); 
 | 
                grdField.Rows[i].Cells[FiFieldNameCol].Value=Ds.Tables[0].Rows[i]["column_name"].ToString().Trim(); 
 | 
                grdField.Rows[i].Cells[FiShowCol].Value = "1"; 
 | 
                grdField.Rows[i].Cells[FiDuiQiCol].Value = "左对齐"; 
 | 
                grdField.Rows[i].Cells[FiDecCol].Value = ""; 
 | 
                // 
 | 
                DataGridViewCheckBoxCell sCell = new DataGridViewCheckBoxCell(); 
 | 
                sCell.ThreeState = false; 
 | 
                sCell.Value = 1;  
 | 
                grdField.Rows[i].Cells[FiShowCol] = sCell; 
 | 
                // 
 | 
                if (Ds.Tables[0].Rows[i]["column_name"].ToString().Trim().ToUpper().Substring(0, 1) == "H")//H开头的列隐藏 
 | 
                { 
 | 
                    grdCondition.Rows[i].Visible=false; 
 | 
                    grdField.Rows[i].Visible = false; 
 | 
                } 
 | 
                else 
 | 
                { 
 | 
                    //gridorder  lstorder 
 | 
                    lstOrder.Items.Add(Ds.Tables[0].Rows[i]["column_name"].ToString().Trim()); 
 | 
                } 
 | 
            } 
 | 
            //加载方案 
 | 
            if (!b) 
 | 
            { 
 | 
                Sub_GetSchemeInfo(); 
 | 
            } 
 | 
            // 
 | 
  
 | 
        } 
 | 
  
 | 
  
 | 
        //读取方案信息 
 | 
        private void Sub_GetSchemeInfo()  //Lock 
 | 
        { 
 | 
            //当前选中方案,若没有选中则为 默认方案,若不存在默认方案则自动新增 
 | 
            if (HInterID == 0) 
 | 
            { 
 | 
                if (oItem.ShowDefault(this.ModName)) 
 | 
                { 
 | 
                    HInterID = oItem.HInterID; 
 | 
                } 
 | 
                else//不存在则 生成默认方案 
 | 
                { 
 | 
                    return;  
 | 
                } 
 | 
            } 
 | 
            if (!oItem.ShowBill(HInterID, ref Pub_Class.ClsPub.sExeReturnInfo)) 
 | 
                return; 
 | 
            foreach (Clsxt_ICSchemeSub oSub in oItem.DetailColl) 
 | 
            { 
 | 
                //循环控件,找到则赋值 
 | 
                foreach (Control ct in this.tabPage1.Controls) 
 | 
                { 
 | 
                    if (oSub.HKey.Trim().ToLower() == ct.Name.Trim().ToLower()) 
 | 
                    { 
 | 
                        if (ct.Name.Trim().ToLower().Substring(0, 3) == "txt" || ct.Name.Trim().ToLower().Substring(0, 3) == "cmb" )  
 | 
                        { 
 | 
                            ct.Text = oSub.HValue.Trim(); 
 | 
                        } 
 | 
                    } 
 | 
                } 
 | 
                foreach (Control ct in this.panel8.Controls) 
 | 
                { 
 | 
                    if (oSub.HKey.Trim().ToLower() == ct.Name.Trim().ToLower()) 
 | 
                    { 
 | 
                        if (ct.Name.Trim().ToLower().Substring(0, 3) == "txt" || ct.Name.Trim().ToLower().Substring(0, 3) == "cmb") 
 | 
                        { 
 | 
                            ct.Text = oSub.HValue.Trim(); 
 | 
                        } 
 | 
                    } 
 | 
                } 
 | 
                foreach (Control ct in this.panel9.Controls) 
 | 
                { 
 | 
                    if (oSub.HKey.Trim().ToLower() == ct.Name.Trim().ToLower()) 
 | 
                    { 
 | 
                        if (ct.Name.Trim().ToLower().Substring(0, 3) == "txt" || ct.Name.Trim().ToLower().Substring(0, 3) == "cmb") 
 | 
                        { 
 | 
                            ct.Text = oSub.HValue.Trim(); 
 | 
                        } 
 | 
                    } 
 | 
                } 
 | 
            } 
 | 
            //得到3个GRID 
 | 
            try 
 | 
            { 
 | 
                Pub_Class.ClsSqlHelper oCn2 = new Pub_Class.ClsSqlHelper(); 
 | 
                DataSet DSet; 
 | 
                for (int i = 0; i < grdCondition.RowCount; i++) 
 | 
                { 
 | 
                    DSet = oCn2.RunProcReturn("select * from Xt_grdCondition where HInterID=" + HInterID.ToString() + " and HRow=" + i, "Xt_grdCondition"); 
 | 
                    if (Pub_Class.ClsPub.isInt(DSet.Tables[0].Rows.Count) != 0) 
 | 
                    { 
 | 
                        grdCondition.Rows[i].Cells[0].Value = DSet.Tables[0].Rows[0]["HIDCol"]; 
 | 
                        grdCondition.Rows[i].Cells[1].Value = DSet.Tables[0].Rows[0]["HBracketLCol"]; 
 | 
                        grdCondition.Rows[i].Cells[2].Value = DSet.Tables[0].Rows[0]["HFieldNameCol"]; 
 | 
                        grdCondition.Rows[i].Cells[3].Value = DSet.Tables[0].Rows[0]["HControlCol"]; 
 | 
                        grdCondition.Rows[i].Cells[4].Value = DSet.Tables[0].Rows[0]["HConditionCol"]; 
 | 
                        grdCondition.Rows[i].Cells[5].Value = DSet.Tables[0].Rows[0]["HBracketRCol"]; 
 | 
                        grdCondition.Rows[i].Cells[6].Value = DSet.Tables[0].Rows[0]["HRelationCol"]; 
 | 
                        if (DSet.Tables[0].Rows[0]["HFieldNameCol"].ToString().Trim().ToUpper().Substring(0, 1) == "H")//H开头的列隐藏 
 | 
                        { 
 | 
                            grdCondition.Rows[i].Visible = false; 
 | 
                        } 
 | 
                        else 
 | 
                        { 
 | 
                            grdCondition.Rows[i].Visible = true; 
 | 
                        } 
 | 
                    } 
 | 
                } 
 | 
                DSet = null; 
 | 
                for (int i = 0; i < grdField.RowCount; i++) 
 | 
                { 
 | 
                    DSet = oCn2.RunProcReturn("select * from Xt_grdField where HInterID=" + HInterID.ToString() + " and HRow=" + i, "Xt_grdField"); 
 | 
                    if (Pub_Class.ClsPub.isInt(DSet.Tables[0].Rows.Count) != 0) 
 | 
                    { 
 | 
                        grdField.Rows[i].Cells[0].Value = DSet.Tables[0].Rows[0]["HFiFieldName"]; 
 | 
                        grdField.Rows[i].Cells[1].Value = DSet.Tables[0].Rows[0]["HFiNo"]; 
 | 
                        grdField.Rows[i].Cells[2].Value = Pub_Class.ClsPub.isBool(DSet.Tables[0].Rows[0]["HFiShow"]); 
 | 
                        if (Pub_Class.ClsPub.isStrNull(DSet.Tables[0].Rows[0]["HFiDuiQi"]) == "") 
 | 
                        { 
 | 
                            grdField.Rows[i].Cells[3].Value = "左对齐"; 
 | 
                        } 
 | 
                        else 
 | 
                        { 
 | 
                            grdField.Rows[i].Cells[3].Value = DSet.Tables[0].Rows[0]["HFiDuiQi"]; 
 | 
                        } 
 | 
                        if (Pub_Class.ClsPub.isInt(DSet.Tables[0].Rows[0]["HDec"]) < 0 || Pub_Class.ClsPub.isInt(DSet.Tables[0].Rows[0]["HDec"]) >9) 
 | 
                        { 
 | 
                            grdField.Rows[i].Cells[4].Value = ""; 
 | 
                        } 
 | 
                        else 
 | 
                        { 
 | 
                            grdField.Rows[i].Cells[4].Value = Pub_Class.ClsPub.isInt(DSet.Tables[0].Rows[0]["HDec"]); 
 | 
                        } 
 | 
                        if (DSet.Tables[0].Rows[0]["HFiNo"].ToString().Trim().ToUpper().Substring(0, 1) == "H")//H开头的列隐藏 
 | 
                        { 
 | 
                            grdField.Rows[i].Visible = false; 
 | 
                        } 
 | 
                        else 
 | 
                        { 
 | 
                            grdField.Rows[i].Visible = true; 
 | 
                        } 
 | 
                    } 
 | 
                } 
 | 
                oCn2.CnClose(); 
 | 
                oCn2.CnDispose(); 
 | 
            } 
 | 
            catch (Exception e) 
 | 
            { 
 | 
                return; 
 | 
            } 
 | 
        } 
 | 
         
 | 
        // 
 | 
        private bool Sub_DeleteSchemeInfo() 
 | 
        { 
 | 
            if (lvScheme.FocusedItem == null) 
 | 
            { 
 | 
                return false; 
 | 
            } 
 | 
            if (lvScheme.FocusedItem.Text == "默认方案") 
 | 
            { 
 | 
                MessageBox.Show("不能删除默认方案!"); 
 | 
                return false; 
 | 
            } 
 | 
            Int64 sInterID = Pub_Class.ClsPub.isLong(lvScheme.FocusedItem.Tag); 
 | 
            if (sInterID != 0) 
 | 
            { 
 | 
                oItem.DeleteBillMain(sInterID); 
 | 
                lvScheme.Items.RemoveAt(lvScheme.FocusedItem.Index); 
 | 
                return true; 
 | 
            } 
 | 
            return false; 
 | 
        } 
 | 
  
 | 
        //保存方案 
 | 
        private bool Sub_SaveSchemeInfo()  //Lock 
 | 
        { 
 | 
             
 | 
            if (HInterID == 0) 
 | 
            { 
 | 
                if (oItem.ShowDefault(this.ViewName))//保存当前选中方案,若没有选中则为 默认方案 
 | 
                { 
 | 
                    HInterID = oItem.HInterID; 
 | 
                    BillStatus =Pub_Class.ClsPub.Enum_BillStatus.BillStatus_Modify; 
 | 
                } 
 | 
                else//不存在则 生成默认方案 
 | 
                { 
 | 
                    BillStatus = Pub_Class.ClsPub.Enum_BillStatus.BillStatus_AddNew; 
 | 
                } 
 | 
            } 
 | 
            else 
 | 
            { 
 | 
                BillStatus = Pub_Class.ClsPub.Enum_BillStatus.BillStatus_Modify; 
 | 
            } 
 | 
            //加载到类 
 | 
            oItem.HBillName = ModName; 
 | 
            oItem.HBillType = oItem.MvarItemKey; 
 | 
            oItem.HStopflag = false; 
 | 
            oItem.HUserCode = Pub_Class.ClsPub.CurUserName; 
 | 
            // 
 | 
            oItem.DetailColl.Clear(); 
 | 
            foreach (Control ct in this.tabPage1.Controls) 
 | 
            { 
 | 
                Clsxt_ICSchemeSub oSub = new Clsxt_ICSchemeSub(); 
 | 
                if (ct.Name.Trim().ToLower().Substring(0, 3) == "txt" || ct.Name.Trim().ToLower().Substring(0, 3) == "cmb" ) 
 | 
                { 
 | 
                    oSub.HKey = ct.Name.Trim(); 
 | 
                    oSub.HValue = ct.Text.Trim(); 
 | 
                    oSub.HInterID = this.HInterID; 
 | 
                    oItem.DetailColl.Add(oSub); 
 | 
                } 
 | 
            } 
 | 
            foreach (Control ct in this.panel8.Controls) 
 | 
            { 
 | 
                Clsxt_ICSchemeSub oSub = new Clsxt_ICSchemeSub(); 
 | 
                if (ct.Name.Trim().ToLower().Substring(0, 3) == "txt" || ct.Name.Trim().ToLower().Substring(0, 3) == "cmb") 
 | 
                { 
 | 
                    oSub.HKey = ct.Name.Trim(); 
 | 
                    oSub.HValue = ct.Text.Trim(); 
 | 
                    oSub.HInterID = this.HInterID; 
 | 
                    oItem.DetailColl.Add(oSub); 
 | 
                } 
 | 
            } 
 | 
            foreach (Control ct in this.panel9.Controls) 
 | 
            { 
 | 
                Clsxt_ICSchemeSub oSub = new Clsxt_ICSchemeSub(); 
 | 
                if (ct.Name.Trim().ToLower().Substring(0, 3) == "cmb") 
 | 
                { 
 | 
                    oSub.HKey = ct.Name.Trim(); 
 | 
                    oSub.HValue = ct.Text.Trim(); 
 | 
                    oSub.HInterID = this.HInterID; 
 | 
                    oItem.DetailColl.Add(oSub); 
 | 
                } 
 | 
            } 
 | 
            // 
 | 
             
 | 
            if (lvScheme.FocusedItem == null) 
 | 
            { 
 | 
                oItem.HName = "默认方案"; 
 | 
            } 
 | 
            else 
 | 
            { 
 | 
                oItem.HName = lvScheme.FocusedItem.Text; 
 | 
            } 
 | 
            if (BillStatus == Pub_Class.ClsPub.Enum_BillStatus.BillStatus_Modify) 
 | 
            { 
 | 
                if (!oItem.ModifyBill(HInterID, ref  Pub_Class.ClsPub.sExeReturnInfo)) 
 | 
                    return false; 
 | 
            } 
 | 
            else if (BillStatus == Pub_Class.ClsPub.Enum_BillStatus.BillStatus_AddNew) 
 | 
            { 
 | 
  
 | 
                if (!oItem.AddBill(ref Pub_Class.ClsPub.sExeReturnInfo, HInterID)) 
 | 
                    return false; 
 | 
                else 
 | 
                    HInterID = oItem.HInterID; 
 | 
            } 
 | 
            else 
 | 
            { 
 | 
                return false; 
 | 
            } 
 | 
            //保存3个GRID 
 | 
            try 
 | 
            { 
 | 
                Pub_Class.ClsSqlHelper oCn1 = new Pub_Class.ClsSqlHelper(); 
 | 
                oCn1.RunProc("delete Xt_grdCondition where   HInterID=" + HInterID.ToString()); 
 | 
                for (int i = 0; i < grdCondition.RowCount; i++) 
 | 
                { 
 | 
                    
 | 
                    oCn1.RunProc("Insert Into Xt_grdCondition   " + 
 | 
                    "(HInterID,HUserID,HBillName,HRow,HIDCol,HBracketLCol,HFieldNameCol,HControlCol" + 
 | 
                    ",HConditionCol,HBracketRCol,HRelationCol" + 
 | 
                    ") " + 
 | 
                    " values(" + HInterID.ToString() + ",'" + Pub_Class.ClsPub.CurUserName + "','" + ViewName.Trim() + "'," + i + 
 | 
                    ",'" + Pub_Class.ClsPub.isStrNull(grdCondition.Rows[i].Cells[0].Value) + "'" + 
 | 
                    ",'" + Pub_Class.ClsPub.isStrNull(grdCondition.Rows[i].Cells[1].Value) + "'" + 
 | 
                    ",'" + Pub_Class.ClsPub.isStrNull(grdCondition.Rows[i].Cells[2].Value) + "'" + 
 | 
                    ",'" + Pub_Class.ClsPub.isStrNull(grdCondition.Rows[i].Cells[3].Value) + "'" + 
 | 
                    ",'" + Pub_Class.ClsPub.isStrNull(grdCondition.Rows[i].Cells[4].Value).Replace("'", "''") + "'" + 
 | 
                    ",'" + Pub_Class.ClsPub.isStrNull(grdCondition.Rows[i].Cells[5].Value).Replace("'", "''") + "'" + 
 | 
                    ",'" + Pub_Class.ClsPub.isStrNull(grdCondition.Rows[i].Cells[6].Value) + "')"); 
 | 
                } 
 | 
                oCn1.RunProc("delete Xt_grdField where HinterID=" + HInterID.ToString()); 
 | 
                for (int i = 0; i < grdField.RowCount; i++) 
 | 
                { 
 | 
  
 | 
                    oCn1.RunProc("Insert Into Xt_grdField  " + 
 | 
                    "(HInterID,HUserID,HBillName,HRow,HFiFieldName,HFiNo,HFiShow,HFiDuiQi" + 
 | 
                    ") " + 
 | 
                    " values("+HInterID.ToString()+",'" + Pub_Class.ClsPub.CurUserName + "','" + ViewName.Trim() + "'," + i + 
 | 
                    ",'" + Pub_Class.ClsPub.isStrNull(grdField.Rows[i].Cells[0].Value) + "'" + 
 | 
                    ",'" + Pub_Class.ClsPub.isStrNull(grdField.Rows[i].Cells[1].Value) + "'" + 
 | 
                    "," + Convert.ToString(Pub_Class.ClsPub.isBool(grdField.Rows[i].Cells[2].Value) ? 1 : 0) +  
 | 
                    ",'"+Pub_Class.ClsPub.isStrNull(grdField.Rows[i].Cells[3].Value)+"'"+ 
 | 
                    ")"); 
 | 
                } 
 | 
                oCn1.CnClose(); 
 | 
                oCn1.CnDispose(); 
 | 
                return true; 
 | 
            } 
 | 
            catch (Exception e) 
 | 
            { 
 | 
                Pub_Class.ClsPub.sExeReturnInfo = Pub_Class.ClsPub.sExeReturnInfo + e.Message; 
 | 
                return false; 
 | 
            } 
 | 
  
 | 
        } 
 | 
  
 | 
  
 | 
        //取消  
 | 
        private void cmdCancel_Click(object sender, EventArgs e) 
 | 
        { 
 | 
            this.Tag = "CANCEL"; 
 | 
            //Sub_SaveSchemeInfo(); 
 | 
            this.Visible = false; 
 | 
        } 
 | 
  
 | 
  
 | 
        private string GetShowItem()//Lock 
 | 
        { 
 | 
            string sSql = ""; 
 | 
            for (int i = 0; i < grdField.RowCount; i++) 
 | 
            { 
 | 
                if (grdField.Rows[i].Visible == false || Pub_Class.ClsPub.isBool(grdField.Rows[i].Cells[FiShowCol].Value) != false) 
 | 
                { 
 | 
                    sSql = sSql + ",[" + Pub_Class.ClsPub.isStrNull(grdField.Rows[i].Cells[FiFieldNameCol].Value) + "]"; 
 | 
                } 
 | 
            } 
 | 
            if (sSql.Trim() == "") 
 | 
            { 
 | 
                return "*"; 
 | 
            } 
 | 
            else 
 | 
            { 
 | 
                return sSql.Trim().Substring(1, sSql.Trim().Length - 1); 
 | 
            } 
 | 
        } 
 | 
  
 | 
  
 | 
        //得到过滤条件和排序条件 
 | 
        private bool GetSql()//Lock 
 | 
        { 
 | 
            string tSql = ""; 
 | 
            string tFilter = ""; 
 | 
            string sEngCondi = ""; 
 | 
            string sLinkCondi = ""; 
 | 
            FieldsArray = tSql; 
 | 
            //得到显示项目 
 | 
            string HeadSql = ""; 
 | 
            HeadSql=GetShowItem(); 
 | 
            // 
 | 
            long ShowCount = 0; 
 | 
            if (Pub_Class.ClsPub.isLong(txtHShowCount.Text) < 1) 
 | 
            { 
 | 
                ShowCount = 1; 
 | 
            } 
 | 
            else 
 | 
            { 
 | 
                ShowCount = Pub_Class.ClsPub.isLong(txtHShowCount.Text); 
 | 
            } 
 | 
            // 
 | 
            tSql = "select Top " + ShowCount.ToString() + " " + HeadSql + " from " + mvarViewName.Trim() + " Where 1=1 "; 
 | 
            for (int i = 0; i < grdCondition.RowCount; i++) 
 | 
            { 
 | 
                sEngCondi = CHStoENG(Pub_Class.ClsPub.isStrNull(grdCondition.Rows[i].Cells[3].Value)); 
 | 
                sLinkCondi = CHStoENG(Pub_Class.ClsPub.isStrNull(grdCondition.Rows[i].Cells[6].Value));  // and or 
 | 
                if (sEngCondi.Trim().Length != 0) 
 | 
                { 
 | 
                    switch (sEngCondi.Trim().ToUpper()) 
 | 
                    { 
 | 
                        case "LIKE": 
 | 
                            tFilter = tFilter + Pub_Class.ClsPub.isStrNull(grdCondition.Rows[i].Cells[1].Value) + " [" + Pub_Class.ClsPub.isStrNull(grdCondition.Rows[i].Cells[2].Value) + "] " + " LIKE '%" + Pub_Class.ClsPub.isStrNull(grdCondition.Rows[i].Cells[4].Value).Trim().Replace("'", "''") + "%' " + Pub_Class.ClsPub.isStrNull(grdCondition.Rows[i].Cells[5].Value) + " " + sLinkCondi.Trim() + " "; 
 | 
                            break; 
 | 
                        case "NOLIKE": 
 | 
                            tFilter = tFilter + Pub_Class.ClsPub.isStrNull(grdCondition.Rows[i].Cells[1].Value) + " [" + Pub_Class.ClsPub.isStrNull(grdCondition.Rows[i].Cells[2].Value) + "] " + " NOT LIKE '%" + Pub_Class.ClsPub.isStrNull(grdCondition.Rows[i].Cells[4].Value).Trim().Replace("'", "''") + "%' " + Pub_Class.ClsPub.isStrNull(grdCondition.Rows[i].Cells[5].Value) + " " + sLinkCondi.Trim() + " "; 
 | 
                            break; 
 | 
                        case "LIKEL": 
 | 
                            tFilter = tFilter + Pub_Class.ClsPub.isStrNull(grdCondition.Rows[i].Cells[1].Value) + " [" + Pub_Class.ClsPub.isStrNull(grdCondition.Rows[i].Cells[2].Value) + "] " + " LIKE '" + Pub_Class.ClsPub.isStrNull(grdCondition.Rows[i].Cells[4].Value).Trim().Replace("'", "''") + "%' " + Pub_Class.ClsPub.isStrNull(grdCondition.Rows[i].Cells[5].Value) + " " + sLinkCondi.Trim() + " "; 
 | 
                            break; 
 | 
                        case "LIKER": 
 | 
                            tFilter = tFilter + Pub_Class.ClsPub.isStrNull(grdCondition.Rows[i].Cells[1].Value) + " [" + Pub_Class.ClsPub.isStrNull(grdCondition.Rows[i].Cells[2].Value) + "] " + " LIKE '%" + Pub_Class.ClsPub.isStrNull(grdCondition.Rows[i].Cells[4].Value).Trim().Replace("'", "''") + "' " + Pub_Class.ClsPub.isStrNull(grdCondition.Rows[i].Cells[5].Value) + " " + sLinkCondi.Trim() + " "; 
 | 
                            break; 
 | 
                        default: 
 | 
                            switch (Pub_Class.ClsPub.isStrNull(grdCondition.Rows[i].Cells[0].Value).Trim().ToUpper()) 
 | 
                            { 
 | 
                                case "BIT": 
 | 
                                    tFilter = tFilter + Pub_Class.ClsPub.isStrNull(grdCondition.Rows[i].Cells[1].Value) + " [" + Pub_Class.ClsPub.isStrNull(grdCondition.Rows[i].Cells[2].Value) + "] " + sEngCondi + " " + Pub_Class.ClsPub.isStrNull(grdCondition.Rows[i].Cells[4].Value).Trim() + "  " + Pub_Class.ClsPub.isStrNull(grdCondition.Rows[i].Cells[5].Value) + " " + sLinkCondi.Trim() + " "; 
 | 
                                    break; 
 | 
                                case "MONEY": 
 | 
                                    tFilter = tFilter + Pub_Class.ClsPub.isStrNull(grdCondition.Rows[i].Cells[1].Value) + " [" + Pub_Class.ClsPub.isStrNull(grdCondition.Rows[i].Cells[2].Value) + "] " + sEngCondi + "" + Pub_Class.ClsPub.isStrNull(grdCondition.Rows[i].Cells[4].Value) + " " + Pub_Class.ClsPub.isStrNull(grdCondition.Rows[i].Cells[5].Value) + " " + sLinkCondi.Trim() + " "; 
 | 
                                    break; 
 | 
                                case "DECIMAL": 
 | 
                                    tFilter = tFilter + Pub_Class.ClsPub.isStrNull(grdCondition.Rows[i].Cells[1].Value) + " [" + Pub_Class.ClsPub.isStrNull(grdCondition.Rows[i].Cells[2].Value) + "] " + sEngCondi + "" + Pub_Class.ClsPub.isStrNull(grdCondition.Rows[i].Cells[4].Value) + " " + Pub_Class.ClsPub.isStrNull(grdCondition.Rows[i].Cells[5].Value) + " " + sLinkCondi.Trim() + " "; 
 | 
                                    break; 
 | 
                                default: 
 | 
                                    tFilter = tFilter + Pub_Class.ClsPub.isStrNull(grdCondition.Rows[i].Cells[1].Value) + " [" + Pub_Class.ClsPub.isStrNull(grdCondition.Rows[i].Cells[2].Value) + "] " + sEngCondi + "'" + Pub_Class.ClsPub.isStrNull(grdCondition.Rows[i].Cells[4].Value) + "' " + Pub_Class.ClsPub.isStrNull(grdCondition.Rows[i].Cells[5].Value) + " " + sLinkCondi.Trim() + " "; 
 | 
                                    break; 
 | 
                            } 
 | 
                            break; 
 | 
                    } 
 | 
                } 
 | 
                else 
 | 
                { 
 | 
                    if (Pub_Class.ClsPub.isStrNull(grdCondition.Rows[i].Cells[1].Value).Trim().Length != 0 || Pub_Class.ClsPub.isStrNull(grdCondition.Rows[i].Cells[5].Value).Trim().Length != 0) 
 | 
                    { 
 | 
                        MessageBox.Show("第" + i.ToString() + "行没有条件,不应该有括号出现,请取消此括号!", "提示"); 
 | 
                        return false; 
 | 
                    } 
 | 
                } 
 | 
            } 
 | 
            if (tFilter.Trim().Length != 0) 
 | 
            { 
 | 
                tFilter = tFilter.Substring(0, tFilter.Trim().Length - 3); 
 | 
                SqlStr = tSql + " AND " + tFilter; 
 | 
            } 
 | 
            else 
 | 
            { 
 | 
                SqlStr = tSql; 
 | 
            } 
 | 
            //审核 
 | 
            if (cmbCheck.Text.Trim() != "全部") 
 | 
            { 
 | 
                if (cmbCheck.Text.ToString() == "已审") 
 | 
                { 
 | 
                    SqlStr = SqlStr + " AND 审核人<>''"; 
 | 
                } 
 | 
                else 
 | 
                { 
 | 
                    SqlStr = SqlStr + " AND 审核人=''"; 
 | 
                } 
 | 
            } 
 | 
             
 | 
            //关闭 
 | 
            if (cmbClose.Text.Trim() != "全部") 
 | 
            { 
 | 
                if (cmbClose.Text.ToString() == "已关闭") 
 | 
                { 
 | 
                    SqlStr = SqlStr + " AND 关闭人<>''"; 
 | 
                } 
 | 
                else 
 | 
                { 
 | 
                    SqlStr = SqlStr + " AND 关闭人=''"; 
 | 
                } 
 | 
            } 
 | 
            
 | 
  
 | 
            //作废 
 | 
            if (cmbDelete.Text.Trim() != "全部") 
 | 
            { 
 | 
                if (cmbDelete.Text.ToString() == "作废") 
 | 
                { 
 | 
                    SqlStr = SqlStr + " AND 作废人<>''"; 
 | 
                } 
 | 
                else 
 | 
                { 
 | 
                    SqlStr = SqlStr + " AND 作废人=''"; 
 | 
                } 
 | 
            } 
 | 
            //时间 
 | 
            if(cmbTime.Text.Trim()!="全部") 
 | 
            { 
 | 
                if (cmbTime.Text.Trim() == "本日") 
 | 
                { 
 | 
                    SqlStr = SqlStr +  " AND DATEDIFF(dd, 日期, getdate())=0 "; 
 | 
                } 
 | 
                else if (cmbTime.Text.Trim() == "本周") 
 | 
                { 
 | 
                    SqlStr = SqlStr + " AND DATEDIFF(week,日期,getdate())=0 "; 
 | 
                } 
 | 
                else if (cmbTime.Text.Trim() == "本期") 
 | 
                { 
 | 
                    SqlStr = SqlStr + " AND DATEDIFF(month,日期,getdate())=0 "; 
 | 
                } 
 | 
                else if (cmbTime.Text.Trim() == "上一周") 
 | 
                { 
 | 
                    SqlStr = SqlStr + " AND 日期 between convert(varchar(10),dateadd(d,-7,getdate()),120) and  convert(varchar(10),getdate(),120) "; 
 | 
                } 
 | 
                else if (cmbTime.Text.Trim() == "下一周") 
 | 
                { 
 | 
                    SqlStr = SqlStr + " AND 日期 between convert(varchar(10),getdate(),120)  and  convert(varchar(10),dateadd(d,7,getdate()),120) "; 
 | 
                } 
 | 
                else 
 | 
                { 
 | 
  
 | 
                } 
 | 
            } 
 | 
  
 | 
            return true; 
 | 
        } 
 | 
        //确认 
 | 
        private void cmdOk_Click(object sender, EventArgs e) 
 | 
        { 
 | 
            Sub_SaveSchemeInfo(); 
 | 
            if (GetSql()) 
 | 
            { 
 | 
                this.Tag = "OK"; 
 | 
                this.Visible=false; 
 | 
            } 
 | 
        } 
 | 
        //初始化网格 
 | 
        private void initGrid() 
 | 
        { 
 | 
             // 
 | 
  
 | 
            grdCondition.RowTemplate.Height = 18; 
 | 
            grdCondition.RowTemplate.MinimumHeight = 18; 
 | 
            grdCondition.ColumnHeadersHeight = 35; 
 | 
            grdCondition.RowHeadersVisible = false; 
 | 
            grdCondition.ColumnHeadersVisible = true; 
 | 
            grdCondition.ColumnCount = 7; 
 | 
            grdCondition.RowCount = 1; 
 | 
            grdCondition.EnableHeadersVisualStyles = false; 
 | 
            grdCondition.AllowUserToAddRows = false;             //是否允许自增--否 
 | 
            grdCondition.AllowUserToDeleteRows = false;          //是否允许删除--否  
 | 
            grdCondition.AllowUserToResizeColumns = true;         //允许调整列宽--是 
 | 
            grdCondition.AllowUserToResizeRows = false;           //允许调整行高--否 
 | 
            grdCondition.AllowUserToOrderColumns = false; 
 | 
            grdCondition.GridColor = Color.LightGray; 
 | 
            grdCondition.Columns[BracketLCol].HeaderText = "左括号"; 
 | 
            grdCondition.Columns[FieldNameCol].HeaderText = "字段名称"; 
 | 
            grdCondition.Columns[ControlCol].HeaderText = "比较关系"; 
 | 
            grdCondition.Columns[ConditionCol].HeaderText = "数值"; 
 | 
            grdCondition.Columns[BracketRCol].HeaderText = "右括号"; 
 | 
            grdCondition.Columns[RelationCol].HeaderText = "逻辑"; 
 | 
            // 
 | 
            grdCondition.EditMode = DataGridViewEditMode.EditOnEnter;      //编辑模式 
 | 
            grdCondition.RowsDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft; 
 | 
            grdCondition.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; 
 | 
            grdCondition.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing; //允许用户调整列宽 
 | 
            grdCondition.Columns[IDCol].Visible = false; 
 | 
             
 | 
            grdCondition.Columns[BracketLCol].Width = 50; 
 | 
            grdCondition.Columns[FieldNameCol].Width = 120; 
 | 
            grdCondition.Columns[ControlCol].Width = 60; 
 | 
            grdCondition.Columns[ConditionCol].Width = 90; 
 | 
            grdCondition.Columns[BracketRCol].Width = 50; 
 | 
            grdCondition.Columns[RelationCol].Width = 50; 
 | 
            for (int i = 0; i < grdCondition.ColumnCount; i++) 
 | 
            { 
 | 
                grdCondition.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable; 
 | 
            } 
 | 
            //grdCondition.set_ColWidth(BracketLCol, 700); 
 | 
            //grdCondition.set_ColWidth(FieldNameCol, 1500); 
 | 
            //grdCondition.set_ColWidth(ControlCol, 800); 
 | 
            //grdCondition.set_ColWidth(ConditionCol, 1500); 
 | 
            //grdCondition.set_ColWidth(BracketRCol, 800); 
 | 
            //grdCondition.set_ColWidth(RelationCol, 500);  
 | 
  
 | 
            //grdorder 
 | 
            //grdOrder.Cols =2; 
 | 
            //grdOrder.Rows = 1; 
 | 
            //grdOrder.set_TextMatrix(0, OrFieldNameCol, "排序字段"); 
 | 
            //grdOrder.set_TextMatrix(0, OrDescCol, "升降序"); 
 | 
            //grdOrder.set_ColComboList(OrDescCol, "升序|降序"); 
 | 
            //grdOrder.Editable = VSFlex7.EditableSettings.flexEDKbdMouse; 
 | 
            //grdOrder.set_FixedAlignment(-1, VSFlex7.AlignmentSettings.flexAlignCenterCenter); 
 | 
            //grdOrder.ExtendLastCol = false; 
 | 
            //grdOrder.RowHeightMin = 280; 
 | 
            //grdOrder.set_RowHeight(0, 450); 
 | 
            //grdOrder.set_ColWidth(OrFieldNameCol, 1500); 
 | 
            //grdOrder.set_ColWidth(OrDescCol, 1500); 
 | 
  
 | 
            //grdfield   
 | 
            // 
 | 
            grdField.RowTemplate.Height = 18; 
 | 
            grdField.RowTemplate.MinimumHeight = 18; 
 | 
            grdField.ColumnHeadersHeight = 35; 
 | 
            grdField.RowHeadersVisible = false; 
 | 
            grdField.ColumnHeadersVisible = true; 
 | 
            grdField.ColumnCount = 5; 
 | 
            grdField.RowCount = 1; 
 | 
            grdField.Columns[FiFieldNameCol].HeaderText = "字段名称"; 
 | 
            grdField.Columns[FiNoCol].HeaderText = "序号"; 
 | 
            grdField.Columns[FiShowCol].HeaderText = "显示"; 
 | 
            grdField.Columns[FiDuiQiCol].HeaderText = "对齐方式"; 
 | 
            grdField.EnableHeadersVisualStyles = false; 
 | 
            grdField.AllowUserToAddRows = false;             //是否允许自增--否 
 | 
            grdField.AllowUserToDeleteRows = false;          //是否允许删除--否  
 | 
            grdField.AllowUserToResizeColumns = true;         //允许调整列宽--是 
 | 
            grdField.AllowUserToResizeRows = false;           //允许调整行高--否 
 | 
            grdField.AllowUserToOrderColumns = false; 
 | 
            grdField.GridColor = Color.LightGray; 
 | 
            // 
 | 
            grdField.ReadOnly = false; 
 | 
            grdField.EditMode = DataGridViewEditMode.EditOnEnter;      //编辑模式 
 | 
            grdField.RowsDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; 
 | 
            grdField.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; 
 | 
            grdField.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing; //允许用户调整列宽 
 | 
            // 
 | 
            grdField.Columns[FiFieldNameCol].Width = 150; 
 | 
            grdField.Columns[FiNoCol].Width = 50; 
 | 
            grdField.Columns[FiShowCol].Width = 100; 
 | 
            for (int i = 0; i < grdField.ColumnCount; i++) 
 | 
            { 
 | 
                grdField.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable; 
 | 
            } 
 | 
              
 | 
  
 | 
  
 | 
        } 
 | 
  
 | 
        //将中文转为英文 
 | 
        private string CHStoENG(string sCHS) 
 | 
        { 
 | 
            switch (sCHS) 
 | 
            { 
 | 
                case "包含": 
 | 
                    return "LIKE"; 
 | 
                case "左包含": 
 | 
                    return "LIKEL"; 
 | 
                case "右包含": 
 | 
                    return "LIKER"; 
 | 
                case "不包含": 
 | 
                    return "NOLIKE"; 
 | 
                case "并且": 
 | 
                    return "AND"; 
 | 
                case "或者": 
 | 
                    return "OR"; 
 | 
                default: 
 | 
                    return sCHS; 
 | 
  
 | 
            } 
 | 
        } 
 | 
        
 | 
         
 | 
        //初始化 
 | 
        private void frmBillQueryCondition_Base_Load(object sender, EventArgs e) 
 | 
        { 
 | 
            this.cmbCheck.Text = "全部"; 
 | 
            this.cmbClose.Text = "全部"; 
 | 
            this.cmbDelete.Text = "全部"; 
 | 
            this.cmbTime.Text = "全部"; 
 | 
            this.cmbHComplete.Text = "是"; 
 | 
            tabControl1.TabPages.Remove(tabPage2); 
 | 
            initGrid(); 
 | 
        } 
 | 
        //初始化2 
 | 
        private void timer1_Tick(object sender, EventArgs e) 
 | 
        { 
 | 
            timer1.Enabled = false; 
 | 
            //加载方案 
 | 
            SetScheme(); 
 | 
            // 
 | 
            SetViewName(ViewName,false); 
 | 
            // 
 | 
            if (bFst) 
 | 
            { 
 | 
                //当第一次加载时,判断是否默认方案 
 | 
                if (cmbDefault.Text == "是") 
 | 
                { 
 | 
                    cmdOk_Click(sender, e); 
 | 
                } 
 | 
            } 
 | 
        } 
 | 
    //   
 | 
  
 | 
        //获取 方案项目 
 | 
        private void SetScheme() 
 | 
        { 
 | 
            lvScheme.Items.Clear(); 
 | 
            ListViewItem oSub = new ListViewItem(); 
 | 
            oSub.Tag = 0; 
 | 
            oSub.Text = "默认方案"; 
 | 
            oSub.ImageIndex = 0; 
 | 
            lvScheme.Items.Add(oSub); 
 | 
            // 
 | 
            if (oItem.GetBillList(this.ModName, ref Pub_Class.ClsPub.sExeReturnInfo)) 
 | 
            { 
 | 
                foreach (Clsxt_ICSchemeMain oMain in oItem.MainColl) 
 | 
                { 
 | 
                    ListViewItem oSub2 = new ListViewItem(); 
 | 
                    oSub2.Tag = oMain.HInterID; 
 | 
                    oSub2.Text = oMain.HName; 
 | 
                    oSub2.ImageIndex = 0; 
 | 
                    lvScheme.Items.Add(oSub2); 
 | 
                } 
 | 
            } 
 | 
  
 | 
            // 
 | 
        } 
 | 
  
 | 
        //加括号 
 | 
        private void cmdBracket_Click(object sender, EventArgs e) 
 | 
        { 
 | 
            int BRow = -1, ERow = 0; 
 | 
            if (grdCondition.SelectedCells == null || grdCondition.SelectedCells.Count==0) 
 | 
            { 
 | 
                  
 | 
                return; 
 | 
            } 
 | 
            //找最大行,最小行 
 | 
            for (int i = 0; i < grdCondition.SelectedCells.Count; i++) 
 | 
            { 
 | 
                if (grdCondition.SelectedCells[i].RowIndex > ERow) 
 | 
                { 
 | 
                    ERow = grdCondition.SelectedCells[i].RowIndex; 
 | 
                } 
 | 
                if (BRow == -1) 
 | 
                { 
 | 
                    BRow = grdCondition.SelectedCells[i].RowIndex; 
 | 
                } 
 | 
                else 
 | 
                { 
 | 
                    if (grdCondition.SelectedCells[i].RowIndex < BRow) 
 | 
                    { 
 | 
                        BRow = grdCondition.SelectedCells[i].RowIndex; 
 | 
                    } 
 | 
                } 
 | 
            } 
 | 
            // 
 | 
            if (BRow != -1) 
 | 
            { 
 | 
                grdCondition.Rows[BRow].Cells[BracketLCol].Value = Pub_Class.ClsPub.isStrNull(grdCondition.Rows[BRow].Cells[BracketLCol].Value) + "("; 
 | 
                grdCondition.Rows[ERow].Cells[BracketRCol].Value = Pub_Class.ClsPub.isStrNull(grdCondition.Rows[ERow].Cells[BracketRCol].Value) + ")"; 
 | 
            } 
 | 
        } 
 | 
        //减括号 
 | 
        private void cmdUNBracket_Click(object sender, EventArgs e) 
 | 
        { 
 | 
            int BRow = -1, ERow = 0; 
 | 
            if (grdCondition.SelectedCells == null || grdCondition.SelectedCells.Count == 0) 
 | 
            { 
 | 
  
 | 
                return; 
 | 
            } 
 | 
            //找最大行,最小行 
 | 
            for (int i = 0; i < grdCondition.SelectedCells.Count; i++) 
 | 
            { 
 | 
                if (grdCondition.SelectedCells[i].RowIndex > ERow) 
 | 
                { 
 | 
                    ERow = grdCondition.SelectedCells[i].RowIndex; 
 | 
                } 
 | 
                if (BRow == -1) 
 | 
                { 
 | 
                    BRow = grdCondition.SelectedCells[i].RowIndex; 
 | 
                } 
 | 
                else 
 | 
                { 
 | 
                    if (grdCondition.SelectedCells[i].RowIndex < BRow) 
 | 
                    { 
 | 
                        BRow = grdCondition.SelectedCells[i].RowIndex; 
 | 
                    } 
 | 
                } 
 | 
            } 
 | 
            // 
 | 
            if(Pub_Class.ClsPub.isStrNull(grdCondition.Rows[BRow].Cells[BracketLCol].Value)!="" && Pub_Class.ClsPub.isStrNull(grdCondition.Rows[ERow].Cells[BracketRCol].Value)!="" ) 
 | 
            { 
 | 
                string s; 
 | 
                s = Pub_Class.ClsPub.isStrNull(grdCondition.Rows[BRow].Cells[BracketLCol].Value); 
 | 
                grdCondition.Rows[BRow].Cells[BracketLCol].Value = s.Substring(0, s.Length - 1); 
 | 
                s = ""; 
 | 
                s = Pub_Class.ClsPub.isStrNull(grdCondition.Rows[ERow].Cells[BracketRCol].Value); 
 | 
                grdCondition.Rows[ERow].Cells[BracketRCol].Value = s.Substring(0, s.Length - 1); 
 | 
            } 
 | 
            else 
 | 
            { 
 | 
                if (Pub_Class.ClsPub.isStrNull(grdCondition.Rows[BRow].Cells[BracketLCol].Value) == "") 
 | 
                { 
 | 
                    MessageBox.Show("选择的第一行没有括号!", "提示"); 
 | 
                } 
 | 
                else 
 | 
                { 
 | 
                    MessageBox.Show("选择的最后一行没有括号!", "提示"); 
 | 
                } 
 | 
            } 
 | 
        } 
 | 
        //复制 
 | 
        private void cmdCopy_Click(object sender, EventArgs e) 
 | 
        { 
 | 
            if (grdCondition.CurrentRow!=null) 
 | 
            { 
 | 
                CopyField =Pub_Class.ClsPub.isStrNull(grdCondition.Rows[grdCondition.CurrentRow.Index].Cells[FieldNameCol].Value); 
 | 
                CopyDataType = Pub_Class.ClsPub.isStrNull(grdCondition.Rows[grdCondition.CurrentRow.Index].Cells[IDCol].Value); 
 | 
                cmdPaste.Enabled = true; 
 | 
            } 
 | 
        } 
 | 
        //黏贴 
 | 
        private void cmdPaste_Click(object sender, EventArgs e) 
 | 
        { 
 | 
            grdCondition.Rows.Insert(grdCondition.CurrentRow.Index,1); 
 | 
            // 
 | 
            grdCondition.Rows[grdCondition.CurrentRow.Index-1].Cells[IDCol].Value=CopyDataType; 
 | 
            grdCondition.Rows[grdCondition.CurrentRow.Index-1].Cells[FieldNameCol].Value= CopyField; 
 | 
            // 
 | 
            DataGridViewComboBoxCell sCellRel = new DataGridViewComboBoxCell(); 
 | 
            sCellRel.FlatStyle = FlatStyle.System; 
 | 
            sCellRel.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing; 
 | 
            sCellRel.DropDownWidth = 10; 
 | 
            sCellRel.Items.Add("并且"); 
 | 
            sCellRel.Items.Add("或者"); 
 | 
            grdCondition.Rows[grdCondition.CurrentRow.Index - 1].Cells[RelationCol] = sCellRel; 
 | 
            grdCondition.Rows[grdCondition.CurrentRow.Index - 1].Cells[RelationCol].Value = "并且"; 
 | 
            // 
 | 
            DataGridViewComboBoxCell sCellCom = new DataGridViewComboBoxCell(); 
 | 
            sCellCom.FlatStyle = FlatStyle.System; 
 | 
            sCellCom.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing; 
 | 
            sCellCom.DropDownWidth = 10; 
 | 
            sCellCom.Items.Add(" "); 
 | 
            sCellCom.Items.Add("="); 
 | 
            sCellCom.Items.Add(">"); 
 | 
            sCellCom.Items.Add(">="); 
 | 
            sCellCom.Items.Add("<"); 
 | 
            sCellCom.Items.Add("<="); 
 | 
            sCellCom.Items.Add("<>"); 
 | 
            sCellCom.Items.Add("包含"); 
 | 
            sCellCom.Items.Add("左包含"); 
 | 
            sCellCom.Items.Add("右包含"); 
 | 
            sCellCom.Items.Add("不包含"); 
 | 
            grdCondition.Rows[grdCondition.CurrentRow.Index - 1].Cells[ControlCol] = sCellCom; 
 | 
            // 
 | 
        } 
 | 
        //删除 
 | 
        private void cmdDelete_Click(object sender, EventArgs e) 
 | 
        { 
 | 
            if (grdCondition.CurrentRow!=null) 
 | 
            { 
 | 
                //if (ClsPub.isStrNull(grdCondition.get_TextMatrix(grdCondition.Row, BracketLCol)) != "" 
 | 
                //    || ClsPub.isStrNull(grdCondition.get_TextMatrix(grdCondition.Row, BracketRCol)) != "") 
 | 
                //{ 
 | 
                //    MessageBox.Show("被删除行不能有括号!", "提示"); 
 | 
                //    return; 
 | 
                //} 
 | 
                grdCondition.Rows.RemoveAt(grdCondition.CurrentRow.Index); 
 | 
            } 
 | 
        } 
 | 
        //恢复 
 | 
        private void cmdRestore_Click(object sender, EventArgs e) 
 | 
        { 
 | 
            SetViewName(ViewName,true); 
 | 
        } 
 | 
  
 | 
        private void bc_Click(object sender, EventArgs e) 
 | 
        { 
 | 
            if (lvScheme.FocusedItem == null) 
 | 
            { 
 | 
                MessageBox.Show("没有选中方案!"); 
 | 
                return; 
 | 
            } 
 | 
            if (MessageBox.Show("确定要保存当前方案到数据库?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.Cancel) 
 | 
            { 
 | 
                return; 
 | 
            } 
 | 
            Int64 sInterID = 0; 
 | 
            sInterID = Pub_Class.ClsPub.isLong(lvScheme.FocusedItem.Tag); 
 | 
            if (sInterID == 0) 
 | 
            { 
 | 
                MessageBox.Show("错误的方案!"); 
 | 
                return; 
 | 
            } 
 | 
            HInterID = sInterID; 
 | 
            Sub_SaveSchemeInfo(); 
 | 
        } 
 | 
  
 | 
        private void sc_Click(object sender, EventArgs e) 
 | 
        { 
 | 
            if (MessageBox.Show("确定要删除当前项目?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.Cancel) 
 | 
            { 
 | 
                return; 
 | 
            } 
 | 
            Sub_DeleteSchemeInfo(); 
 | 
        } 
 | 
  
 | 
        //private void grdField_BeforeEdit(object sender, AxVSFlex7._IVSFlexGridEvents_BeforeEditEvent e) 
 | 
        //{ 
 | 
        //    if (e.col != FiShowCol) 
 | 
        //    { 
 | 
        //        e.cancel = true; 
 | 
        //    } 
 | 
        //} 
 | 
  
 | 
    
 | 
  
 | 
        private void cmdAllSelect_Click(object sender, EventArgs e) 
 | 
        {  
 | 
            for (int i = 0; i < grdField.RowCount; i++) 
 | 
            { 
 | 
                grdField.Rows[i].Cells[FiShowCol].Value = true; 
 | 
            } 
 | 
        } 
 | 
  
 | 
        private void cmdAllClear_Click(object sender, EventArgs e) 
 | 
        {  
 | 
            for (int i = 0; i < grdField.RowCount; i++) 
 | 
            { 
 | 
                grdField.Rows[i].Cells[FiShowCol].Value = false; 
 | 
            } 
 | 
        } 
 | 
        //加载到GRID 
 | 
        private void LoadToGrid() 
 | 
        { 
 | 
            //if (lstOrder.SelectedIndex >= 0) 
 | 
            //{ 
 | 
            //    //是否存在 
 | 
            //    string sSelectItem = ""; 
 | 
            //    sSelectItem=lstOrder.Items[lstOrder.SelectedIndex].ToString(); 
 | 
            //    for (int i = grdOrder.FixedRows; i < grdOrder.Rows; i++) 
 | 
            //    { 
 | 
            //        if (ClsPub.isStrNull(grdOrder.get_TextMatrix(i, OrFieldNameCol)) == sSelectItem) 
 | 
            //        { 
 | 
            //            MessageBox.Show("您选择的项目已存在!"); 
 | 
            //            return; 
 | 
            //        } 
 | 
            //    } 
 | 
            //    //加载到GRID 
 | 
            //    grdOrder.AddItem(""); 
 | 
            //    grdOrder.set_TextMatrix(grdOrder.Rows - 1, OrFieldNameCol, sSelectItem); 
 | 
            //    grdOrder.set_TextMatrix(grdOrder.Rows - 1, OrDescCol, "升序"); 
 | 
            //    grdOrder.set_ColComboList(OrDescCol, "升序|降序"); 
 | 
            //} 
 | 
        } 
 | 
        // 
 | 
        private void cmdAddNew_Click(object sender, EventArgs e) 
 | 
        { 
 | 
            LoadToGrid(); 
 | 
        } 
 | 
  
 | 
        private void lstOrder_DoubleClick(object sender, EventArgs e) 
 | 
        { 
 | 
            LoadToGrid(); 
 | 
        } 
 | 
  
 | 
        private void cmdDel_Click(object sender, EventArgs e) 
 | 
        { 
 | 
            if (grdOrder.CurrentRow!=null) 
 | 
            { 
 | 
                grdOrder.Rows.RemoveAt(grdOrder.CurrentRow.Index);  
 | 
            } 
 | 
        } 
 | 
  
 | 
          
 | 
        private void grdCondition_KeyDown(object sender, KeyEventArgs e) 
 | 
        { 
 | 
            Sub_GridKeyView(e.KeyValue, grdCondition.CurrentRow.Index, grdCondition.CurrentCell.ColumnIndex, grdCondition, EditingControl); 
 | 
        } 
 | 
  
 | 
        private void grdField_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e) 
 | 
        { 
 | 
  
 | 
            if (grdField.CurrentCell.ColumnIndex != FiShowCol && grdField.CurrentCell.ColumnIndex != FiDuiQiCol) 
 | 
            { 
 | 
                e.Cancel = true; 
 | 
            } 
 | 
            else 
 | 
            { 
 | 
                // 
 | 
            } 
 | 
        } 
 | 
  
 | 
        private void grdCondition_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e) 
 | 
        { 
 | 
            if (grdCondition.CurrentCell.ColumnIndex != ControlCol && grdCondition.CurrentCell.ColumnIndex != ConditionCol && grdCondition.CurrentCell.ColumnIndex != RelationCol) 
 | 
            { 
 | 
                e.Cancel = true; 
 | 
            } 
 | 
            else 
 | 
            { 
 | 
                // 
 | 
            } 
 | 
        } 
 | 
  
 | 
        DataGridViewTextBoxEditingControl EditingControl; 
 | 
        private void EditingControl_KeyDown(object sender, KeyEventArgs e) 
 | 
        { 
 | 
            //业务处理  
 | 
            Sub_GridKeyView(e.KeyValue, grdCondition.CurrentRow.Index, grdCondition.CurrentCell.ColumnIndex, grdCondition, EditingControl); 
 | 
        } 
 | 
  
 | 
        private void grdCondition_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) 
 | 
        { 
 | 
            if (grdCondition.CurrentCell != null) 
 | 
            { 
 | 
                if (e.Control is DataGridViewTextBoxEditingControl) 
 | 
                { 
 | 
                    this.EditingControl = (DataGridViewTextBoxEditingControl)e.Control; 
 | 
                    //增加委托处理  
 | 
                    this.EditingControl.KeyDown += new KeyEventHandler(this.EditingControl_KeyDown); 
 | 
                } 
 | 
  
 | 
            } 
 | 
        } 
 | 
  
 | 
        private void grdCondition_CellEndEdit(object sender, DataGridViewCellEventArgs e) 
 | 
        { 
 | 
            if (this.EditingControl != null) 
 | 
            { 
 | 
                EditingControl.KeyDown -= new KeyEventHandler(this.EditingControl_KeyDown); 
 | 
                this.EditingControl = null; 
 | 
            } 
 | 
        } 
 | 
  
 | 
        
 | 
  
 | 
        public virtual void Sub_GridKeyView(int sKeyCode, int sRow, int sCol, DataGridView grdCondition,DataGridViewTextBoxEditingControl oEdit) 
 | 
        { 
 | 
            // 
 | 
        } 
 | 
  
 | 
        private void cmdUp2_Click(object sender, EventArgs e) 
 | 
        { 
 | 
            if (grdField.CurrentRow == null) 
 | 
                return; 
 | 
            if (grdField.CurrentRow.Index > 0) 
 | 
            { 
 | 
  
 | 
            } 
 | 
        } 
 | 
  
 | 
        private void cmdDown2_Click(object sender, EventArgs e) 
 | 
        { 
 | 
  
 | 
        } 
 | 
  
 | 
        private void cmdUp_Click(object sender, EventArgs e) 
 | 
        { 
 | 
  
 | 
        } 
 | 
  
 | 
        private void cmdDown_Click(object sender, EventArgs e) 
 | 
        { 
 | 
  
 | 
        } 
 | 
  
 | 
        frm_SetName ofrmDlg = new frm_SetName(); 
 | 
  
 | 
        //新增方案  
 | 
        private void xz_Click(object sender, EventArgs e) 
 | 
        { 
 | 
            //弹出框 设置方案名字 
 | 
            ofrmDlg.ShowDialog(); 
 | 
            if (ofrmDlg.isOk) 
 | 
            { 
 | 
                
 | 
                string s = ""; 
 | 
                Int64 sInterID=0; 
 | 
                s = ofrmDlg.txtHName.Text; 
 | 
                //判断方案名是否重复 
 | 
                for (int i = 0; i < lvScheme.Items.Count; i++) 
 | 
                { 
 | 
                    if (s.Trim() == lvScheme.Items[i].Text.Trim()) 
 | 
                    { 
 | 
                        MessageBox.Show("已存在相同的方案名,请重新录入!"); 
 | 
                        return; 
 | 
                    } 
 | 
                } 
 | 
                //  
 | 
                sInterID = Pub_Class.ClsPub.CreateBillID("0001", ref Pub_Class.ClsPub.sExeReturnInfo); //获取新ID 
 | 
                if (s.Trim() != "" && sInterID !=0) 
 | 
                { 
 | 
                    ListViewItem oSub = new ListViewItem(); 
 | 
                    oSub.Tag = sInterID; 
 | 
                    oSub.Text = s; 
 | 
                    oSub.ImageIndex = 0; 
 | 
                    lvScheme.Items.Add(oSub); 
 | 
                } 
 | 
            } 
 | 
        } 
 | 
  
 | 
        //选择方案 改变时  
 | 
        private void lvScheme_SelectedIndexChanged(object sender, EventArgs e) 
 | 
        { 
 | 
            if (lvScheme.FocusedItem == null) 
 | 
            { 
 | 
                return; 
 | 
            } 
 | 
            Int64 sInterID = 0; 
 | 
            sInterID = Pub_Class.ClsPub.isLong(lvScheme.FocusedItem.Tag); 
 | 
            HInterID = sInterID; 
 | 
            SetViewName(ViewName, false);  
 | 
        } 
 | 
    } 
 | 
} 
 |