/// <summary> /// 绑定(重量、水分)检测项目 /// </summary> private void BindCboxTestItems() { List <TestItems> list = TestItemsDAL.GetListWhereTestItemName("", "启动"); TestItems ti = new TestItems(); ti.TestItems_ID = 0; ti.TestItems_NAME = "全部"; TestItems t = list[0]; list[0] = ti; list.Add(t); List <TestItems> list2 = list; cboxTestItems2.DataSource = list; cboxTestItems2.DisplayMember = "TestItems_NAME"; cboxTestItems2.ValueMember = "TestItems_ID"; if (cboxTestItems2.DataSource != null) { cboxTestItems2.SelectedValue = 0; } cboxTestItems.DataSource = list2;// TestItemsDAL.GetListWhereTestItemName("", "启动"); cboxTestItems.DisplayMember = "TestItems_NAME"; cboxTestItems.ValueMember = "TestItems_ID"; if (cboxTestItems.DataSource != null) { // cboxTestItems.SelectedIndex =-1; cboxTestItems.SelectedValue = 0; } }
/// <summary> /// 查重方法 /// </summary> /// <returns></returns> private bool btnCheck() { bool rbool = true; try { //定义一个字段用以保存项目检测名称 var TestItemsName = this.txtTestItems_Name.Text.Trim(); //判断名称是否为空 if (TestItemsName == "") { mf.ShowToolTip(ToolTipIcon.Info, "提示", "检测项目名称不能为空!", txtTestItems_Name, this); txtTestItems_Name.Text = ""; txtTestItems_Name.Focus(); rbool = false; } Expression <Func <View_TestItems_Dictionary, bool> > funview_TestItemsinfo = n => n.TestItems_NAME == TestItemsName; if (TestItemsDAL.Query(funview_TestItemsinfo).Count() > 0) { mf.ShowToolTip(ToolTipIcon.Info, "提示", "该检测项目名称已存在", txtTestItems_Name, this); txtTestItems_Name.Focus(); rbool = false;; } return(rbool); } catch (Exception ex) { Common.WriteTextLog("项目检测管理 btnCheck()" + ex.Message.ToString()); rbool = false; } return(rbool); }
/// <summary> /// 修改 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnUpUser_Click(object sender, EventArgs e) { try { if (this.txtTestItems_Count.Text == "") { mf.ShowToolTip(ToolTipIcon.Info, "提示", "检测项目次数不能为空!", txtTestItems_Count, this); return; } if (this.txtTestItems_Name.Text == "") { mf.ShowToolTip(ToolTipIcon.Info, "提示", "检测项目名称不能为空!", txtTestItems_Count, this); return; } if (Convert.ToDouble(this.txtTestItems_Count.Text) == 0) { mf.ShowToolTip(ToolTipIcon.Info, "提示", "检测项目次数不能为零!", txtTestItems_Count, this); return; } if (this.cbxTestItemsState.SelectedIndex > -1) { Expression <Func <TestItems, bool> > p = n => n.TestItems_NAME == this.lvwTestItems.SelectedRows[0].Cells["TestItems_NAME"].Value.ToString(); Action <TestItems> ap = s => { s.TestItems_NAME = this.txtTestItems_Name.Text.Trim(); //s.Tes_TestItems_ID = Convert.ToInt32(this.txtTes_TestItems_ID.Text.Trim()); s.Tes_TestItems_ID = Convert.ToInt32(this.cbxTes_TestItems_ID.SelectedValue); s.TestItems_Dictionary_ID = Convert.ToInt32(this.cbxTestItemsState.SelectedValue); s.TestItems_COUNT = Convert.ToInt32(this.txtTestItems_Count.Text.Trim()); s.TestItems_REMARK = this.txtTestItems_Remark.Text.Trim(); }; if (TestItemsDAL.Update(p, ap)) { MessageBox.Show("修改成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("修改失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } string strContent = "检测项目名称为:" + this.txtTestItems_Name.Text.Trim();; LogInfoDAL.loginfoadd("修改", "修改 " + strContent + " 的信息", Common.USERNAME);//添加日志 } } catch (Exception ex) { Common.WriteTextLog("项目检测管理 bntUpUser_Click()" + ex.Message.ToString()); } finally { page = new PageControl(); page.PageMaxCount = tscbxPageSize2.SelectedItem.ToString(); LoadData(); ShowAddButton(); } }
/// <summary> /// 绑定检测项目上级(水分检测和重量检测) /// </summary> private void BindcbxTestItemsID() { cbxTes_TestItems_ID.DataSource = TestItemsDAL.GetListWhereTestItemName("", "启动"); cbxTes_TestItems_ID.DisplayMember = "TestItems_NAME"; cbxTes_TestItems_ID.ValueMember = "TestItems_ID"; if (cbxTes_TestItems_ID.DataSource != null) { cbxTes_TestItems_ID.SelectedIndex = 0; } }
/// <summary> /// 查看修改信息 /// </summary> private void tsbtnUpdateSelect() { if (this.lvwTestItems.SelectedRows.Count > 0)//选中行 { if (lvwTestItems.SelectedRows.Count > 1) { MessageBox.Show("修改只能选中一行!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { //修改的值 this.txtTestItems_Name.Text = lvwTestItems.SelectedRows[0].Cells["TestItems_NAME"].Value.ToString(); Expression <Func <View_TestItems_Dictionary, bool> > funviewinto = n => n.TestItems_NAME == this.txtTestItems_Name.Text; foreach (var n in TestItemsDAL.Query(funviewinto)) { if (n.TestItems_NAME != null) { //项目检测名称 this.txtTestItems_Name.Text = n.TestItems_NAME; } if (n.Tes_TestItems_ID != null) { //项目检测上级 //this.txtTes_TestItems_ID.Text = n.Tes_TestItems_ID.ToString(); this.cbxTes_TestItems_ID.SelectedValue = n.Tes_TestItems_ID; } if (n.TestItems_Dictionary_ID != null) { //项目检测状态 this.cbxTestItemsState.SelectedValue = n.TestItems_Dictionary_ID; } if (n.TestItems_COUNT != null) { //项目检测次数 this.txtTestItems_Count.Text = n.TestItems_COUNT.ToString(); } if (n.TestItems_REMARK != null) { //项目检测备注 this.txtTestItems_Remark.Text = n.TestItems_REMARK; } break; } //隐藏添加按钮 btnAdd.Visible = false; btnUpUser.Visible = true; btnUserCancle.Visible = true; } } else { MessageBox.Show("请选择要修改的行!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
/// <summary> /// 添加 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAdd_Click(object sender, EventArgs e) { try { if (this.txtTestItems_Count.Text == "") { mf.ShowToolTip(ToolTipIcon.Info, "提示", "检测项目次数不能为空!", txtTestItems_Count, this); return; } if (Convert.ToDouble(this.txtTestItems_Count.Text) == 0) { mf.ShowToolTip(ToolTipIcon.Info, "提示", "检测项目次数不能为零!", txtTestItems_Count, this); return; } //ValidateTextBox();//调用验证文本框方法 if (!btnCheck()) { return; //去重 } var TestItemsadd = new TestItems { TestItems_NAME = this.txtTestItems_Name.Text.Trim(), //Tes_TestItems_ID = Convert.ToInt32(this.txtTes_TestItems_ID.Text.Trim()), Tes_TestItems_ID = Convert.ToInt32(this.cbxTes_TestItems_ID.SelectedValue), TestItems_Dictionary_ID = Convert.ToInt32(this.cbxTestItemsState.SelectedValue), TestItems_COUNT = Convert.ToInt32(this.txtTestItems_Count.Text.Trim()), TestItems_REMARK = this.txtTestItems_Remark.Text.Trim() }; if (TestItemsDAL.InsertOneQCRecord(TestItemsadd)) { MessageBox.Show("添加成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("添加失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } string strContent = "检测项目名称为:" + this.txtTestItems_Name.Text.Trim();; LogInfoDAL.loginfoadd("新增", "新增 " + strContent + " 的信息", Common.USERNAME);//添加日志 } catch (Exception ex) { Common.WriteTextLog("项目检测管理 btnAdd_Click()" + ex.Message.ToString()); } finally { page = new PageControl(); page.PageMaxCount = tscbxPageSize2.SelectedItem.ToString(); LoadData(); } }
/// <summary> ///删除项目检测信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tbtnDelUser_delete() { try { int j = 0; if (lvwTestItems.SelectedRows.Count > 0)//选中删除 { if (MessageBox.Show("确定要删除吗?", "系统提示", MessageBoxButtons.YesNo) == DialogResult.Yes) { //选中数量 int count = lvwTestItems.SelectedRows.Count; string id = ""; //遍历 for (int i = 0; i < count; i++) { Expression <Func <TestItems, bool> > funuserinfo = n => n.TestItems_ID == Convert.ToInt32(this.lvwTestItems.SelectedRows[i].Cells["TestItems_ID"].Value.ToString()); if (!TestItemsDAL.DeleteToMany(funuserinfo)) { j++; } } if (j == 0) { MessageBox.Show("成功删除", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("删除失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } string strContent = "检测项目编号为:" + this.lvwTestItems.SelectedRows[0].Cells["TestItems_ID"].Value.ToString(); LogInfoDAL.loginfoadd("删除", "删除 " + strContent + " 的信息", Common.USERNAME);//添加日志 } } else//没有选中 { MessageBox.Show("请选择要删除的行!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { Common.WriteTextLog("项目检测管理 tbtnDelUser_delete()+" + ex.Message.ToString()); } finally { page = new PageControl(); page.PageMaxCount = tscbxPageSize2.SelectedItem.ToString(); LoadData();//更新 } }
/// <summary> /// 获得系统设置信息 /// </summary> private void GetSystemSet() { string filepath = System.IO.Directory.GetCurrentDirectory() + "\\SystemSet.xml"; try { string version = ""; string DVRIP = ""; string DVRServerPort = ""; string DVRLoginName = ""; string DVRPwd = ""; string SaveFiel = ""; int Channel1 = 0; int Channel2 = 0; int Channel3 = 0; string MOISTURECOM = ""; string MOISTURENAME = ""; string platformScaleName = ""; string MOISTURECOMTwo = ""; string MOISTURENAMETwo = ""; string platformScaleNameTwo = ""; string WEIGHTCOM = ""; string WEIGHTCOMTwo = ""; // string NTCODE = ""; // string LEDFROMX = ""; string LEDFROMY = ""; string LEDX = ""; string LEDY = ""; string CLIENTID = ""; string CLIENTNAME = ""; string CollectionID = ""; string CollectionNAME = ""; string SFYCOUNT = ""; string MOISTUREMAX = ""; string MOISTUREMIN = ""; string waterManSelect = ""; string waterManSelectTwo = ""; string OrganizationID = ""; string SourceID = ""; string GainURL = ""; string SendURL = ""; // string LEDTabTime = ""; // string LEDEndTime = ""; string ISPackets = ""; int removePackage = 0; //string itemmoist = "0"; //string itemmoistcount = "8"; XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(filepath); XmlNode xn = xmlDoc.SelectSingleNode("param");//查找<bookstore> XmlNodeList xnl = xn.ChildNodes; if (xnl.Count > 0) { foreach (XmlNode xnf in xnl) { XmlElement xe = (XmlElement)xnf; version = xe.GetAttribute("Version").ToString(); MOISTURECOM = xe.GetAttribute("MOISTURECOM").ToString(); MOISTURENAME = xe.GetAttribute("MOISTURENAME").ToString(); platformScaleName = xe.GetAttribute("platformScaleName").ToString(); MOISTURECOMTwo = xe.GetAttribute("MOISTURECOMTwo").ToString(); MOISTURENAMETwo = xe.GetAttribute("MOISTURENAMETwo").ToString(); platformScaleNameTwo = xe.GetAttribute("platformScaleNameTwo").ToString(); WEIGHTCOM = xe.GetAttribute("WEIGHTCOM").ToString(); WEIGHTCOMTwo = xe.GetAttribute("WEIGHTCOMTwo").ToString(); //LEDFROMX = xe.GetAttribute("LEDFROMX").ToString(); //LEDFROMY = xe.GetAttribute("LEDFROMY").ToString(); //LEDX = xe.GetAttribute("LEDX").ToString(); //LEDY = xe.GetAttribute("LEDY").ToString(); CLIENTID = xe.GetAttribute("CLIENTID").ToString(); CLIENTNAME = xe.GetAttribute("CLIENTNAME").ToString(); CollectionID = xe.GetAttribute("CollectionID").ToString(); CollectionNAME = xe.GetAttribute("CollectionNAME").ToString(); SFYCOUNT = xe.GetAttribute("SFYCOUNT").ToString(); MOISTUREMAX = xe.GetAttribute("MOISTUREMAX").ToString(); MOISTUREMIN = xe.GetAttribute("MOISTUREMIN").ToString(); waterManSelect = xe.GetAttribute("waterManSelect").ToString(); waterManSelectTwo = xe.GetAttribute("waterManSelectTwo").ToString(); OrganizationID = xe.GetAttribute("OrganizationID").ToString(); SourceID = xe.GetAttribute("SourceID").ToString(); GainURL = xe.GetAttribute("GainURL").ToString(); SendURL = xe.GetAttribute("SendURL").ToString(); removePackage = Convert.ToInt32(xe.GetAttribute("removePackage")); //LEDTabTime = xe.GetAttribute("LEDTabTime").ToString(); //LEDEndTime = xe.GetAttribute("LEDEndTime").ToString(); ISPackets = xe.GetAttribute("ISPackets").ToString(); DVRIP = xe.GetAttribute("DVRIP").ToString(); DVRServerPort = xe.GetAttribute("DVRServerPort").ToString(); DVRLoginName = xe.GetAttribute("DVRLoginName").ToString(); DVRPwd = xe.GetAttribute("DVRPwd").ToString(); SaveFiel = xe.GetAttribute("SaveFiel").ToString(); Channel1 = Common.GetInt(xe.GetAttribute("Channel1").ToString()); Channel2 = Common.GetInt(xe.GetAttribute("Channel2").ToString()); Channel3 = Common.GetInt(xe.GetAttribute("Channel3").ToString()); //itemmoist = xe.GetAttribute("ItemMoist").ToString(); //itemmoistcount = xe.GetAttribute("ItemMoistCount").ToString(); } if (!string.IsNullOrEmpty(version)) { Common.Version = version; } if (!string.IsNullOrEmpty(waterManSelect)) { Common.waterManSelect = Convert.ToInt32(waterManSelect); } if (!string.IsNullOrEmpty(waterManSelectTwo)) { Common.waterManSelectTwo = Convert.ToInt32(waterManSelectTwo); } if (!string.IsNullOrEmpty(MOISTURECOM)) { Common.MOISTURECOM = Converter.ToInt(MOISTURECOM, 1); } if (!string.IsNullOrEmpty(MOISTURENAME)) { Common.MOISTURENAME = MOISTURENAME; } if (!string.IsNullOrEmpty(platformScaleName)) { Common.platformScaleName = platformScaleName; Common.WEIGHTCOMBaudRate = Common.GetComBaudrate(platformScaleName); } if (!string.IsNullOrEmpty(platformScaleNameTwo)) { Common.platformScaleNameTwo = platformScaleNameTwo; Common.WEIGHTCOMTwoBaudRate = Common.GetComBaudrate(platformScaleNameTwo); } if (!string.IsNullOrEmpty(MOISTURECOMTwo)) { Common.MOISTURECOMTwo = Converter.ToInt(MOISTURECOMTwo, 1); } if (!string.IsNullOrEmpty(MOISTURENAMETwo)) { Common.MOISTURENAMETwo = MOISTURENAMETwo; } if (!string.IsNullOrEmpty(WEIGHTCOM)) { Common.WEIGHTCOM = Converter.ToInt(WEIGHTCOM, 2); } if (!string.IsNullOrEmpty(WEIGHTCOMTwo)) { Common.WEIGHTCOMTwo = Converter.ToInt(WEIGHTCOMTwo, 2); } //if (!string.IsNullOrEmpty(LEDFROMX)) //{ // Common.LEDFROMX = Converter.ToInt(LEDFROMX); //} //if (!string.IsNullOrEmpty(LEDFROMY)) //{ // Common.LEDFROMY = Converter.ToInt(LEDFROMY); //} if (!string.IsNullOrEmpty(LEDX)) //{ // Common.LEDX = Converter.ToInt(LEDX); //} //if (!string.IsNullOrEmpty(LEDY)) //{ // Common.LEDY = Converter.ToInt(LEDY); //} if (!string.IsNullOrEmpty(CLIENTID)) { Common.CLIENTID = Converter.ToInt(CLIENTID); } if (!string.IsNullOrEmpty(SFYCOUNT)) { Common.SFYCOUNT = Converter.ToInt(SFYCOUNT); } if (!string.IsNullOrEmpty(CLIENTNAME)) { Common.CLIENT_NAME = CLIENTNAME; } if (!string.IsNullOrEmpty(CollectionID)) { Common.CollectionID = Converter.ToInt(CollectionID); } if (!string.IsNullOrEmpty(CollectionNAME)) { Common.CollectionNAME = CollectionNAME; } if (!string.IsNullOrEmpty(MOISTUREMAX)) { Common.MOISTUREMAX = Converter.ToInt(MOISTUREMAX); } if (!string.IsNullOrEmpty(MOISTUREMIN)) { Common.MOISTUREMIN = Converter.ToInt(MOISTUREMIN); } Common.OrganizationID = OrganizationID; Common.SourceID = SourceID; Common.GainURL = GainURL; Common.SendURL = SendURL; Common.removePackage = removePackage; //Common.LEDTabTime = LEDTabTime; //Common.LEDEndTime = LEDEndTime; Common.DVRIP = DVRIP; Common.DVRServerPort = DVRServerPort; Common.DVRLoginName = DVRLoginName; Common.DVRPwd = DVRPwd; Common.SaveFiel = SaveFiel; Common.Channel = Channel1; Common.Channel2 = Channel2; Common.Channel3 = Channel3; Common.ISPackets = ISPackets; //Common.ItemMoist = Common.GetInt(itemmoist); //Common.ItemMoistCount = Common.GetInt(itemmoistcount); } #region 2012-07-10 水分检测次数配置 List <TestItems> listitem = TestItemsDAL.GetListWhereTestItemName("水分检测", "启动"); if (listitem.Count > 0) { foreach (TestItems ti in listitem) { if (ti.TestItems_NAME.Trim() == "拆包后水分检测") { Common.BAGWATE = ti.TestItems_COUNT.Value; } else if (ti.TestItems_NAME.Trim() == "拆包前水分检测") { Common.TOTALCARWATE = ti.TestItems_COUNT.Value; } } } #endregion } catch (Exception ex) { MessageBox.Show("获得系统设置失败!", "运行信息", MessageBoxButtons.OK, MessageBoxIcon.Error);; } }