首页 > 代码库 > 耳座操作流程

耳座操作流程

  1         private void FormLug_Load(object sender, EventArgs e)  2         {  3             cbType.Items.Clear();  4             FieldListLug.Clear();//字段清除  5             //System.Drawing.Image img=Image.FromFile(@"");  6             //pbShow.Image = img;  7             string where = string.Format("DnX < {0} and DnD > {0}", DI);//定义查询条件  8             //where = "DnX < " + DI.ToString() + " and DnD > " + DI.ToString();  9             FieldListLug.Add("TypeE");//要查询的列 10             tbType = GetAccessData(TypeName, FieldListLug, where);//获得查询出来的表 11             TypeList = tbType.AsEnumerable().Select(p => p.Field<string>("TypeE")).Distinct().ToList();//将表变成列 12             cbType.Items.AddRange(TypeList.ToArray());//变成列加入控件中 13         } 14         private void cbType_SelectedIndexChanged(object sender, EventArgs e)//CBTYPE里面数据变化时产生的操作 15         { 16             cbNum.Items.Clear(); 17             cbbHasCover.Enabled = true;//默认CHACKBOX初始时为可以改变 18             FieldListLug.Clear();//清除耳座字段列表 19             string where = string.Format("DnX < {0} and DnD > {0}", DI);//定义查找条件字符串 20             FieldListLug.Add("LugNumber");//将需要的列的字段加入字段列 可以加入多个 21             string TableName; 22             if (cbType.Text == "A") 23             { 24                  TableName = "Y_SUPPORT_LUG_4712_3_2007_A"; 25                  tbNum = GetAccessData(TableName, FieldListLug, 26                  where);//查询表 使用查询语句将表名 条件 字段列加入获得顶板表 27             } 28             else if(cbType.Text == "B") 29             { 30                  TableName = "Y_SUPPORT_LUG_4712_3_2007_B"; 31                  tbNum = GetAccessData(TableName, FieldListLug, 32                  where);//查询表 使用查询语句将表名 条件 字段列加入获得顶板表 33             } 34             else if(cbType.Text == "C") 35             { 36                 TableName = "Y_SUPPORT_LUG_4712_3_2007_C"; 37                 tbNum = GetAccessData(TableName, FieldListLug, 38                 where);//查询表 使用查询语句将表名 条件 字段列加入获得顶板表 39             } 40             NumList = tbNum.AsEnumerable().Select(p => p.Field<int>("LugNumber").ToString()).Distinct().ToList(); 41             cbNum.Items.AddRange(NumList.ToArray()); 42             FieldListLug.Clear();//清除耳座字段列表 43             FieldListLug.Add("HasCover");//将需要的列的字段加入字段列 可以加入多个 44             string where1 = string.Format("DnX < {0} and DnD > {0} and TypeE =‘{1}‘", DI,cbType.Text);//定义查找条件字符串 45             tbTopPlate = GetAccessData(TypeName, FieldListLug, where1); 46             TopPlateList = tbTopPlate.AsEnumerable() 47              .Select(p => p.Field<bool>("HasCover")).Distinct().ToList();//将获得的表变成列 p.Field<>中类型要保持一致,Distinct()将重复的去除 48             if (TopPlateList.Count == 1)//如果TopPlateList中只有一个数据 则始终不能改变 49             { 50                 if (TopPlateList[0])//获取列中第一个数据 因为是一个BOOL型的列 如果第一个数据是TURE则有盖板并且成立 51                 { 52                     cbbHasCover.Checked = true;//选择有盖板 53                     cbbHasCover.Enabled = false;//并且不能改变 54                 } 55                 else//如果没有 56                 { 57                     cbbHasCover.Checked = false;//选择无盖板 58                     cbbHasCover.Enabled = false;//也不能改变 59                 } 60                  61             } 62             else 63             { 64                 TopPlateChange(cbbHasCover.Checked); 65             } 66         } 67         private void TopPlateChange(bool hasTopPlate) 68         { 69             cbNum.Items.Clear(); 70             tbNum.Clear(); 71             FieldListLug.Clear();//清除耳座字段列表 72             FieldListLug.Add("LugNumber"); 73             string where = string.Format("DnX < {0} and DnD > {0} and TypeE = ‘{1}‘ and HasCover = {2}", DI, cbType.Text,cbbHasCover.Checked);//定义查找条件字符串 74             tbNum = GetAccessData(TypeName, FieldListLug, 75                     where);//查询表 使用查询语句将表名 条件 字段列加入获得顶板表 76             NumList1 = tbNum.AsEnumerable().Select(p => p.Field<int>("LugNumber").ToString()).Distinct().ToList(); 77             NumList1 = NumList1.Intersect(NumList).ToList(); 78             cbNum.Items.AddRange(NumList1.ToArray()); 79         } 80         private void cbbHasCover_CheckedChanged(object sender, EventArgs e) 81         { 82             TopPlateChange(cbbHasCover.Checked); 83         } 84         private void cbNum_SelectedIndexChanged(object sender, EventArgs e) 85         { 86             FieldListLug.Clear();//继续清除字段 87             if (cbType.Text == "A")//选择了A 88             { 89                 string killedString = ""; 90                 killedString = "ID,lugNumber,q1,q2,DnX,DnD,Th,kg"; 91                 DataTable tbSize = GetAccessData("Y_SUPPORT_LUG_4712_3_2007_A"); 92                 FieldListLug = tbSize.GetFieldList(killedString); 93                 string TableName = "Y_SUPPORT_LUG_4712_3_2007_A";//查询表A 94                 string where = string.Format("LugNumber = {0} ", int.Parse(cbNum.Text));//定义查询条件 95                 tbValue = http://www.mamicode.com/GetAccessData(TableName, FieldListLug, where);//查出需要的表 96             } 97             else if (cbType.Text == "B")//选择B 98             { 99                 string killedString = "";//定义去除字段100                 killedString = "ID,lugNumber,q1,q2,DnX,DnD,Th,kg";//去除一些没用的字段101                 DataTable tbSize = GetAccessData("Y_SUPPORT_LUG_4712_3_2007_B");//查找表102                 FieldListLug = tbSize.GetFieldList(killedString);//获取去除后的字段清单103                 string TableName = "Y_SUPPORT_LUG_4712_3_2007_B";//定义查询表104                 string where = string.Format("LugNumber = {0} ", int.Parse(cbNum.Text));//定义条件105                 tbValue = http://www.mamicode.com/GetAccessData(TableName, FieldListLug, where);//查出需要的表 去除无用信息后的数据106             }107             else if (cbType.Text == "C")//选择C108             {109                 string killedString = "";110                 killedString = "ID,lugNumber,q1,q2,DnX,DnD,Th,kg";111                 DataTable tbSize = GetAccessData("Y_SUPPORT_LUG_4712_3_2007_C");112                 FieldListLug = tbSize.GetFieldList(killedString);113                 string TableName = "Y_SUPPORT_LUG_4712_3_2007_C";114                 string where = string.Format("LugNumber = {0} ", int.Parse(cbNum.Text));115                 tbValue = http://www.mamicode.com/GetAccessData(TableName, FieldListLug, where);116             }117 118         }
View Code

 

耳座操作流程