decimal CheckDataValidate(decimal checkdata) { try { systemcheckset sysset = null; List <systemcheckset> scsl = SerializeXML <systemcheckset> .Getlist(); if (scsl != null || scsl.Count > 0) { sysset = scsl.FirstOrDefault(); } if (sysset == null || sysset.throwvalue == null || sysset.throwvalue <= 0) { return(checkdata); } decimal targetvalue = Convert.ToDecimal(GetTargetValue()); decimal throwdatemin = targetvalue * (((sysset.throwvalue ?? 0) / 100)); decimal throwdatemax = targetvalue * (1 + ((sysset.throwvalue ?? 0) / 100)); if (targetvalue > throwdatemax || targetvalue < throwdatemin) { return(0); } return(checkdata); } catch { return(0); } }
//void AddToList(ShowCheckresult sc) //{ // if (sc == null) return; // if (CountPlus(sc)) // { // sc.id = id; // showcheckset.Add(sc); // CheckDataBind(); // id++; // } //} bool CountPlus(decimal checkdata) { systemcheckset sysset = null; List <systemcheckset> scsl = SerializeXML <systemcheckset> .Getlist(); if (scsl != null || scsl.Count > 0) { sysset = scsl.FirstOrDefault(); } if (procheckdata) { successcount++; } if (successcount > sysset.count) { arry = sysset.arry ?? 1; successcount = 0; arry = 4; } if (arry > sysset.arry) { finisharry++; NextCheck(finisharry); successcount = 0; arry = 1; procheckdata = true; } if (finisharry > 3) { isFinishCheck = true; return(false); } ShowCheckresult sc = CheckResult(checkdata); sc.id = id; showcheckset.Add(sc); CheckDataBind(); id++; if (sc.result.Equals("√")) { procheckdata = true; this.lb_status.Content = "本次不合格!"; } else { procheckdata = false; successcount = 0; arry++; this.lb_status.Content = "本次不合格!"; } return(true); }
void showtester() { try { ttmlist = SerializeXML <TorqueTestModel> .Getlist(); if (ttmlist.Count > 0) { TorqueTestModel t1 = ttmlist.Find(p => p.testername == "校验仪1"); TorqueTestModel t2 = ttmlist.Find(p => p.testername == "校验仪2"); if (t1 != null) { this.tb_1max.Text = t1.maxvalue.ToString(); this.tb_1min.Text = t1.minvalue.ToString(); this.tb_databit.Text = t1.databit.ToString(); foreach (string s in cb_name.Items) { if (s == t1.portname) { cb_name.SelectedItem = t1.portname; } } foreach (int i in cb_baundrate.Items) { if (i == t1.baundrate) { cb_baundrate.SelectedItem = t1.baundrate; } } } if (t2 != null) { this.tb_2max.Text = t2.maxvalue.ToString(); this.tb_2min.Text = t2.minvalue.ToString(); this.tb_2databit.Text = t2.databit.ToString(); foreach (string s in cb_2name.Items) { if (s == t2.portname) { cb_2name.SelectedItem = t2.portname; } } foreach (int i in cb_2baundrate.Items) { if (i == t2.baundrate) { cb_2baundrate.SelectedItem = t2.baundrate; } } } } } catch { } }
systemcheckset GetSystem() { List <systemcheckset> scsl = SerializeXML <systemcheckset> .Getlist(); if (scsl != null && scsl.Count > 0) { return(scsl.FirstOrDefault()); } return(new systemcheckset()); }
/// <summary> /// 获取设置校验次数组数 /// </summary> void getSystemSet() { List <systemcheckset> scsl = SerializeXML <systemcheckset> .Getlist(); if (scsl != null || scsl.Count > 0) { sysset = scsl.FirstOrDefault(); } sysset = null; }
public int CheckdetailCount() { int i = 5; List <systemcheckset> scsl = SerializeXML <systemcheckset> .Getlist(); if (scsl != null || scsl.Count > 0) { i = scsl.FirstOrDefault().count ?? 5; } return(i); }
List <PowerList> Getxml() { List <PowerList> templ = new List <PowerList>(); try { templ = SerializeXML <PowerList> .Getlist(); return(templ); } catch { return(templ); } }
void getsystemset() { string porterror = ""; ttml = SerializeXML <TorqueTestModel> .Getlist(); if (ttml.Count > 0) { _tester1 = ttml.Find(p => p.testername == "校验仪1"); if (_tester1 != null) { try { _t1.PortName = _tester1.portname; _t1.BaudRate = _tester1.baundrate; _t1.DataBits = _tester1.databit; porterror += "校验仪1链接端口为" + _tester1.portname; } catch { porterror += "校验仪1端口配置失败!"; // MessageAlert.Error("校验仪1端口打开失败!"); } finally { this.porterror.Content = porterror; } } _tester2 = ttml.Find(p => p.testername == "校验仪2"); if (_tester2 != null) { try { _t2.PortName = _tester2.portname; _t2.BaudRate = _tester2.baundrate; _t2.DataBits = _tester2.databit; porterror += " 校验仪2链接端口为" + _tester2.portname; } catch { porterror += "校验仪2端口配置失败!"; // MessageAlert.Error("校验仪2端口打开失败!"); } finally { this.porterror.Content = "提示: " + porterror; } } } }
void getErrorRanng() { errorset = new List <errorrangset>(); try { errorset = SerializeXML <errorrangset> .Getlist(); } catch { //MessageAlert.Alert("没有误差方案数据!"); return; } if (errorset.Count >= 0) { this.dg_set.ItemsSource = null; this.dg_set.ItemsSource = errorset; } }
private void Mainwindow_Loaded(object sender, RoutedEventArgs e) { // this.WindowState = System.Windows.WindowState.Normal; // this.WindowStyle = System.Windows.WindowStyle.None; //this.ResizeMode = System.Windows.ResizeMode.NoResize; this.Left = 0.0; this.Top = 0.0; this.Width = System.Windows.SystemParameters.PrimaryScreenWidth; this.Height = System.Windows.SystemParameters.PrimaryScreenHeight; show(); if (this.cf == null) { this.main.Children.Add(cf = new CheckFinal(ruc, rct1, rct2)); cf.SetSerialPort = EncoderPlcPort; } else { this.main.Children.Add(cf); } this.user.Content = "当前登录用户:" + SystData.userInfo.user.username; // l = new Login(this); //this.main.Children.Clear(); //this.main.Children.Add(l); ew = new editerWrench(); List <systemcheckset> ls = new List <systemcheckset>(); try { ls = SerializeXML <systemcheckset> .Getlist(); if (ls != null && ls.Count > 0) { if (ls.FirstOrDefault().noticeshow) { //this.taskbarNotifier.Show(); //this.taskbarNotifier.NotifyContent.Clear(); //this.taskbarNotifier.NotifyContent.Add(new NotifyObject(GetWrenchList(Convert.ToInt32(ls.FirstOrDefault().noticedays)))); //WinWrenchRepair WinWrenchRepair = new WinWrenchRepair(GetWrenchList(Convert.ToInt32(ls.FirstOrDefault().noticedays))); //WinWrenchRepair.Show(); } } } catch { } }
//void OnTimedEvent(object serder, EventArgs e) //{ // this.Dispatcher.Invoke(DispatcherPriority.Normal, // new TimerDispatcherDelegate(UpdateUI)); //} //void UpdateUI() //{ // try // { // uint result = Convert.ToUInt32(EncoderPlc.getIntimeData(),16); // Console.WriteLine("值:"+result); // this.machon.Text = Convert.ToInt64(EncoderPlc.getIntimeData(),16).ToString (); // if (EncoderPlc.Direction()) // { // direction_yes.Visibility = Visibility.Visible; // direction_no.Visibility = Visibility.Hidden; // } // else // { // direction_yes.Visibility = Visibility.Hidden; // direction_no.Visibility = Visibility.Visible; // } // if (EncoderPlc.ReDirection()) // { // redirection_yes.Visibility = Visibility.Visible; // redirection_no.Visibility = Visibility.Hidden; // } // else // { // redirection_yes.Visibility = Visibility.Hidden; // redirection_no.Visibility = Visibility.Visible; // } // } // catch(Exception ex) // { // } //} void checksetshow() { // bool sl = SerializeXML<systemcheckset>.exit(); List <systemcheckset> ls = new List <systemcheckset>(); try { ls = SerializeXML <systemcheckset> .Getlist(); if (ls.Count > 0) { systemcheckset s = new systemcheckset(); s = ls.FirstOrDefault(); this.tb_jarry.Text = s.arry == null?"":s.arry.ToString(); this.tb_jcount.Text = s.count == null?"":s.count.ToString(); this.tb_throw.Text = s.throwvalue.ToString(); radiobutton((s.ishavejuser == null || s.ishavejuser == false)?false:true); string[] time = s.noticetime.Split(':'); if (time.Length >= 3) { this.tb_hour.Text = Convert.ToInt32(time[0]).ToString("D2"); this.tb_min.Text = Convert.ToInt32(time[1]).ToString("D2"); this.tb_second.Text = Convert.ToInt32(time[2]).ToString("D2"); } this.tb_day.Text = s.noticedays.ToString(); if (s.noticeshow) { this.rb_show.IsChecked = true; } else { this.rb_notshow.IsChecked = true; } } } catch { // MessageAlert.Alert("没有相应的检验参数设置"); return; } }
void getsystemset() { try { List <systemcheckset> scsl = SerializeXML <systemcheckset> .Getlist(); erl = SerializeXML <errorrangset> .Getlist(); ttml = SerializeXML <TorqueTestModel> .Getlist(); if (scsl.Count > 0) { _systemcheckset = scsl.FirstOrDefault(); } } catch { MessageAlert.Alert("校验仪没有任何进行设置!不能校验!"); } }
private void Notice(string time) { List <systemcheckset> ls = new List <systemcheckset>(); try { ls = SerializeXML <systemcheckset> .Getlist(); if (ls != null && ls.Count > 0) { if (time.EndsWith(ls.FirstOrDefault().noticetime)) { this.taskbarNotifier.NotifyContent.Clear(); this.taskbarNotifier.NotifyContent.Add(new NotifyObject(GetWrenchList(Convert.ToInt32(ls.FirstOrDefault().noticedays)))); this.taskbarNotifier.Notify(); } } } catch { } }
private void Button_Click(object sender, RoutedEventArgs e) { try { string tempstr = (cb_role.SelectedItem as role).roleName; if (_powerlist.FindIndex(p => p.role == tempstr) >= 0) { _powerlist.RemoveAt(_powerlist.FindIndex(p => p.role == tempstr)); } PowerList pl = new PowerList() { role = tempstr, rolepower = (List <string>)lv_havefunctio.ItemsSource }; _powerlist.Add(pl); SerializeXML <PowerList> .SaveList(_powerlist); _powerlist = SerializeXML <PowerList> .Getlist(); MessageAlert.Alert("保存完成!"); } catch { MessageAlert.Alert("保存失败!"); } }
//private void borrow_Click(object sender, RoutedEventArgs e) //{ // WrenchBorrow wb = new WrenchBorrow(ruc); // this.main.Children.Clear(); // this.main.Children.Add(wb); //} //private void return_Click(object sender, RoutedEventArgs e) //{ // WrenchReturn wr = new WrenchReturn(ruc); // this.main.Children.Clear(); // this.main.Children.Add(wr); //} private void searchwrenchdata_Click(object sender, RoutedEventArgs e) { List <systemcheckset> ls = new List <systemcheckset>(); //try //{ ls = SerializeXML <systemcheckset> .Getlist(); if (ls != null && ls.Count > 0) { // if (ls.FirstOrDefault().noticeshow) // { //this.taskbarNotifier.Show(); //this.taskbarNotifier.NotifyContent.Clear(); //this.taskbarNotifier.NotifyContent.Add(new NotifyObject(GetWrenchList(Convert.ToInt32(ls.FirstOrDefault().noticedays)))); WinWrenchRepair WinWrenchRepair = new WinWrenchRepair(GetWrenchList(Convert.ToInt32(ls.FirstOrDefault().noticedays))); WinWrenchRepair.Show(); // } } //} //catch { } }
public List <CheckOutDetail> GetDetail(WrenchCheckOut wrenchcheckout) { List <CheckOutDetail> codlist = new List <CheckOutDetail>(); if (wrenchcheckout == null) { return(codlist = null); } List <torquecheckrecord> tempcheckrecorklist = new List <torquecheckrecord>(); tempcheckrecorklist = CheckTargetRecord.SelectByCheckTargetID(wrenchcheckout.guid); if (tempcheckrecorklist == null || tempcheckrecorklist.Count <= 0) { return(codlist = null); } if (tempcheckrecorklist.FindIndex(p => p.isEffective == true) < 0) { int i = 0, j = 0; List <systemcheckset> scsl = SerializeXML <systemcheckset> .Getlist(); if (scsl == null || scsl.Count <= 0) { i = 5; } else { i = Convert.ToInt16(scsl.First().count); } foreach (torquecheckrecord t in tempcheckrecorklist) { if (j >= i) { break; } codlist.Add(new CheckOutDetail() { wrenchbarcode = wrenchcheckout.wrenchbarcode, checkdata = t.analyserValue.ToString(), checktime = t.checkTime.ToString(), iseffect = t.passedFlag }); j++; } } else { foreach (torquecheckrecord t in tempcheckrecorklist) { if (t.isEffective) { codlist.Add(new CheckOutDetail() { wrenchbarcode = wrenchcheckout.wrenchbarcode, checkdata = t.analyserValue.ToString(), checktime = t.checkTime.ToString(), iseffect = t.passedFlag }); } } } return(codlist); }
List <PowerList> getpower() { return(SerializeXML <PowerList> .Getlist()); }
private void bt_print_Click(object sender, RoutedEventArgs e) { if (this.dt_showdate.SelectedIndex < 0) { MessageAlert.Alert("请选择要打印的行!"); return; } int cid = 1; systemcheckset sysset = null; List <systemcheckset> scsl = SerializeXML <systemcheckset> .Getlist(); if (scsl != null || scsl.Count > 0) { sysset = scsl.FirstOrDefault(); } WrenchCheckOut wco = dt_showdate.SelectedItem as WrenchCheckOut; List <torquecheckrecord> cd = CheckTargetRecord.SelectByCheckTargetID(wco.guid); wrench w = Wrench.selectByBarcode(wco.wrenchbarcode); List <ShowCheckresult> scr = new List <ShowCheckresult>(); if (cd != null) { List <torquecheckrecord> success = cd.FindAll(p => p.isEffective == true); foreach (torquecheckrecord t in success) { scr.Add(new ShowCheckresult() { id = cid, checkdata = t.analyserValue, setdata = t.torqueTargetValue, normalrang = (t.torqueTargetValue * (1 + Convert.ToDecimal(t.errorRangeMin))).ToString("f2") + "~" + (t.torqueTargetValue * (1 + Convert.ToDecimal(t.errorRangeMax))).ToString("f2"), result = t.passedFlag == true ? "√" : "×", error = t.torqueTargetValue == 0 ? "" : (((t.analyserValue - t.torqueTargetValue) / t.torqueTargetValue) * 100).ToString("f2") + "%" }); cid++; } List <string> successdata = GetCheckTarget(success); foreach (string s in successdata) { cd.RemoveAll(p => { if (p.torqueTargetValue.ToString("f2") == s) { return(true); } else { return(false); } }); } List <string> faildataa = GetCheckTarget(cd); foreach (string s in faildataa) { List <torquecheckrecord> fail = cd.FindAll(p => p.torqueTargetValue.ToString("f2") == s); int m = 0; foreach (torquecheckrecord t in fail) { if (m >= sysset.count) { break; } scr.Add(new ShowCheckresult() { id = cid, checkdata = t.analyserValue, setdata = t.torqueTargetValue, normalrang = (t.torqueTargetValue * (1 + Convert.ToDecimal(t.errorRangeMin))).ToString("f2") + "~" + (t.torqueTargetValue * (1 + Convert.ToDecimal(t.errorRangeMax))).ToString("f2"), result = t.passedFlag == true ? "√" : "×", error = t.torqueTargetValue == 0 ? "" : (((t.analyserValue - t.torqueTargetValue) / t.torqueTargetValue) * 100).ToString("f2") + "%" }); m++; cid++; } } } #region //foreach (torquecheckrecord ck in cd) //{ // decimal check= Convert.ToDecimal(ck.analyserValue ); // decimal setvalue= Convert.ToDecimal(wco.torquetargetvalue); // decimal derror = Convert.ToDecimal(((check - setvalue) / setvalue).ToString("f4")); // scr.Add(new ShowCheckresult() { checkdata =check, setdata =setvalue, normalrang = wco.errorrange,normalmax=wco.errormax ,normalmin =wco.errormin , errorrang =derror,result = ck.passedFlag ? "√" : "×" }); //} if (scr == null || scr.Count <= 0) { MessageAlert.Alert("选中行没有详细的校验数据!"); return; } //foreach (torquecheckrecord t in cd) //{ // if (t.isEffective) // confcount++; //} //if (confcount <= 0) //{ // systemcheckset _systemcheckset = new systemcheckset(); // try // { // confcount = Convert.ToInt16(_systemcheckset.count); // } // catch { confcount = 0; } //} //if (confcount <= 0) // confcount = 5; HandleData hd = new HandleData(wco.juserinfo.user, wco.zuserinfo, w, wco.is_good, Convert.ToDecimal(wco.torquetargetvalue), Convert.ToDecimal(10), Convert.ToDecimal(10)); //hd.Checkdatashow = scr; //hd.filterdata(); //List<ShowCheckresult> lssc = hd.Getprint(); PrintSingleCheckdata psc = PrintSingleCheckdata.GetPrintSingleCheckdata(w, scr, cd.Count, Convert.ToDecimal(wco.torquetargetvalue), wco.juserinfo, wco.zuserinfo, Convert.ToDateTime(wco.checkdate), wco.is_good); psc.Topmost = true; psc.Owner = _main; psc.Show(); #endregion }