void clear() { _wrenchstatus = null; isadd = true; this.tb_statuscode.Clear(); this.tb_statusname.Clear(); }
ToolModel GetToolMode(wrench w) { ToolModel tm = null; wrenchstatus ws = WrenchStatus.selectByguid(w.status); if (ws == null || ws.guid == null) { return(tm); } tm = new ToolModel() { wrenchBarCode = w.wrenchBarCode, wrenchCode = w.wrenchCode, comment = w.comment, createDate = w.createDate, cycletime = Convert.ToDecimal(w.cycletime.ToString("f0")), factory = w.factory, guid = w.guid, id = w.id, IP = w.IP, isallowcheck = w.isallowcheck, lastrepair = w.lastrepair, port = w.port, rangeMax = w.rangeMax, rangeMin = w.rangeMin, species = w.species, status = w.status, statusName = ws.statusName, targetvalue = w.targetvalue, unit = w.unit }; return(tm); }
private void Button_Click_19(object sender, RoutedEventArgs e) { wrenchstatus w = Wrenchsatatus.selectByguid("22"); w.statusName = this.content.Text.Trim(); Wrenchsatatus.update(w); }
private void bt_editer_Click(object sender, RoutedEventArgs e) { if (this.dt_showdata.SelectedIndex < 0) { return; } _wrenchstatus = dt_showdata.SelectedItem as wrenchstatus; showdata(_wrenchstatus); isadd = false; }
private void Button_Click(object sender, RoutedEventArgs e) { if (this.tb_statusname.Text.Trim() == "") { MessageAlert.Warning("请填写状态名称"); return; } if (this.tb_statuscode.Text.Trim() == "") { MessageAlert.Warning("请填写状态编号!"); return; } try { if (isadd) { wrenchstatus w = new wrenchstatus(); w.statusDM = this.tb_statuscode.Text.Trim(); w.statusName = this.tb_statusname.Text.Trim(); w.guid = Guid.NewGuid().ToString(); if (IsExit(w)) { return; } if (save(w)) { MessageAlert.Alert("保存成功!"); databind(getsatus()); clear(); return; } } else { _wrenchstatus.statusDM = this.tb_statuscode.Text.Trim(); _wrenchstatus.statusName = this.tb_statusname.Text.Trim(); wrenchstatus w = new wrenchstatus(); w = _wrenchstatus; if (IsUpdataRepeat(w)) { return; } if (WrenchStatus.update(w)) { MessageAlert.Alert("保存成功!"); databind(getsatus()); clear(); return; } } MessageAlert.Alert("保存失败!"); } catch { MessageAlert.Alert("保存失败!"); } }
void getstatuslist() { List <wrenchstatus> status = WrenchStatus.selectAll(); wrenchstatus w = new wrenchstatus(); if (status != null) { status.Insert(0, w); } this.cb_status.ItemsSource = status; this.cb_status.DisplayMemberPath = "statusName"; this.cb_status.SelectedValuePath = "guid"; }
private List <ToolModel> Gettoolmodel(List <wrench> wrenchlist) { List <ToolModel> toolmodellist = new List <ToolModel>(); try { if (wrenchlist != null && wrenchlist.Count > 0) { int count = 0; foreach (wrench w in wrenchlist) { count++; wrenchspecies ws = WrenchSpecies.selectByGuid(w.species); wrenchstatus wss = WrenchStatus.selectByguid(w.status); toolmodellist.Add(new ToolModel() { comment = w.comment, createDate = w.createDate, factory = w.factory, guid = w.guid, id = count, IP = w.IP, port = w.port, rangeMax = Convert.ToDecimal(w.rangeMax.ToString("f1")), rangeMin = Convert.ToDecimal(w.rangeMin.ToString("f1")), targetvalue = Convert.ToDecimal(w.targetvalue.ToString("f1")), targetvalue1 = Convert.ToDecimal(w.targetvalue1.ToString("f1")), targetvalue2 = Convert.ToDecimal(w.targetvalue2.ToString("f1")), unit = w.unit, species = w.species, speciesName = ws.speciesName, status = w.status, statusDM = wss.statusDM, statusName = wss.statusName, lastrepair = w.lastrepair, cycletime = Convert.ToDecimal(w.cycletime.ToString("f0")), wrenchBarCode = w.wrenchBarCode, wrenchCode = w.wrenchCode }); } } else { MessageAlert.Alert("没有工具信息!"); } } catch { } return(toolmodellist); }
public bool addlist(List <Model.wrench> wrenchlist) { try { string sql = ""; foreach (wrench wrenchtool in wrenchlist) { string sqldep = string.Format("select * from wrenchspecies where id='{0}'", wrenchtool.species); DataSet dps = SqliteHelper.ExecuteDataSet(con, sqldep, CommandType.Text); if (dps != null && dps.Tables.Count > 0) { department dep = DataTableToList.GetList <department>(dps.Tables[0]).FirstOrDefault(); if (dep != null) { wrenchtool.species = dep.guid; } } sqldep = string.Format("select * from wrenchstatus where id='{0}'", wrenchtool.status); dps = SqliteHelper.ExecuteDataSet(con, sqldep, CommandType.Text); if (dps != null && dps.Tables.Count > 0) { wrenchstatus dep = DataTableToList.GetList <wrenchstatus>(dps.Tables[0]).FirstOrDefault(); if (dep != null) { wrenchtool.status = dep.guid; } } sql += string.Format ( "INSERT INTO wrench(wrenchCode,wrenchBarCode,rangeMin,rangeMax,factory,createDate,IP,port,species_id,status_id,lastrepair,cycletime,isallowcheck,targetvalue,targetvalue1,targetvalue2,unit,comment,guid,offPset) VALUES('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}');", wrenchtool.wrenchCode, wrenchtool.wrenchBarCode, wrenchtool.rangeMin, wrenchtool.rangeMax, wrenchtool.factory, wrenchtool.createDate, wrenchtool.IP, wrenchtool.port, wrenchtool.species, wrenchtool.status, wrenchtool.lastrepair, wrenchtool.cycletime, wrenchtool.isallowcheck == true ? 1 : 0, wrenchtool.targetvalue, wrenchtool.targetvalue1, wrenchtool.targetvalue2, wrenchtool.unit, wrenchtool.comment, wrenchtool.guid, wrenchtool.offPset ) + "\r"; } sql += "select last_insert_rowid();"; var ds = SqliteHelper.ExecuteNonQuery(con, sql, CommandType.Text); if (Convert.ToInt32(ds) > 0) { return(true); } return(false); } catch { return(false); } }
bool IsExit(wrenchstatus w) { wrenchstatus wl = WrenchStatus.selectByName(w.statusName); if (wl != null) { MessageAlert.Alert("该状态已经存在!"); return(true); } wl = WrenchStatus.selectByStatusDM(w.statusDM); if (wl != null) { MessageAlert.Alert("该工具编号已经存在!"); return(true); } return(false); }
bool IsUpdataRepeat(wrenchstatus w) { wrenchstatus wl = WrenchStatus.selectByName(w.statusName); if (wl != null && wl.guid != w.guid) { MessageAlert.Alert("该状态已经存在!"); return(true); } wl = WrenchStatus.selectByStatusDM(w.statusDM); if (wl != null && wl.guid != w.guid) { MessageAlert.Alert("该工具编号已经存在!"); return(true); } return(false); }
bool updatewrench(string status) { List <wrench> wr = new List <wrench>(); wrenchstatus ws = WrenchSataus.selectByName(status); foreach (wrench w in _wrenchlist) { w.status = ws.guid; if (!Wrench.updata(w)) { return(false); } } return(true); }
void ShowWrench(wrench e) { if (e == null) { return; } IWrenchStatus WrenchStatus = DataAccess.CreateWrenchStatus(); wrenchstatus w = WrenchStatus.selectByguid(e.status); if (w != null) { this.wrenchstatus.Text = w.statusName; } this.wrenchcode.Text = e.wrenchCode; this.cb_wrench.IsEnabled = true; }
public wrenchinfo GetWrenchinfo(string barcode) { wrench w = Wrench.selectByBarcode(barcode); if (w == null) { return(null); } wrenchspecies ws = WrenchSpecies.selectByGuid(w.species); wrenchstatus wss = WrenchStatus.selectByguid(w.status); wrenchinfo wi = new wrenchinfo(); wi.wrench = w; wi.species = ws; wi.status = wss; return(wi); }
bool updata(string type) { try { for (int i = 0; i < dt_showdata.Items.Count; i++) { var cntr = dt_showdata.ItemContainerGenerator.ContainerFromIndex(i); DataGridRow ObjROw = (DataGridRow)cntr; if (ObjROw != null) { FrameworkElement objElement = dt_showdata.Columns[0].GetCellContent(ObjROw); if (objElement != null) { System.Windows.Controls.CheckBox objChk = (System.Windows.Controls.CheckBox)objElement; if (objChk.IsChecked == true) { ToolModel tm = ObjROw.Item as ToolModel; if (tm == null || tm.guid == null) { continue; } wrench s = new wrench(); if (type == "001") { s = Wrench.selectByguid(tm.guid); wrenchstatus ws = WrenchStatus.selectByStatusDM(type); s.status = ws.guid; s.lastrepair = DateTime.Now; } if (type == "002") { s = Wrench.selectByguid(tm.guid); wrenchstatus ws = WrenchStatus.selectByStatusDM(type); s.status = ws.guid; } Wrench.updata(s); } } } } return(true); } catch { return(false); } }
private List <ToolModel> Gettoolmodel(List <wrench> wrenchlist) { List <ToolModel> toolmodellist = new List <ToolModel>(); try { if (wrenchlist != null) { int tempid = 1; foreach (wrench w in wrenchlist) { wrenchspecies ws = WrenchSpecies.selectByGuid(w.species); wrenchstatus wss = WrenchStatus.selectByguid(w.status); toolmodellist.Add(new ToolModel() { comment = w.comment, createDate = w.createDate, factory = w.factory, guid = w.guid, id = tempid++, IP = w.IP, port = w.port, rangeMax = Convert.ToDecimal(w.rangeMax.ToString("f1")), rangeMin = Convert.ToDecimal(w.rangeMin.ToString("f1")), targetvalue = Convert.ToDecimal(w.targetvalue.ToString("f1")), targetvalue1 = Convert.ToDecimal(w.targetvalue1.ToString("f1")), targetvalue2 = Convert.ToDecimal(w.targetvalue2.ToString("f1")), offPset = w.offPset, unit = w.unit, species = w.species, speciesName = ws != null ? ws.speciesName : "", status = w.status, statusDM = wss != null ? wss.statusDM : "", statusName = wss != null ? wss.statusName : "", wrenchBarCode = w.wrenchBarCode, wrenchCode = w.wrenchCode, lastrepair = w.lastrepair }); } } } catch { } return(toolmodellist); }
List <wrench> ListWrench(DataTable sourcetabledata) { List <wrench> listwrench = new List <wrench>(); List <string> log = new List <string>(); if (sourcetabledata == null || sourcetabledata.Rows.Count < 1) { return(listwrench); } try { if (!filterInWrench(sourcetabledata)) { return(listwrench = null);; } foreach (DataRow dr in sourcetabledata.Rows) { List <wrenchspecies> wl = WrenchSpecies.selectbyname(dr[1].ToString()); wrenchstatus ws = WrenchStatus.selectByStatusDM("001"); listwrench.Add(new wrench() { id = dr[0] != DBNull.Value ? Convert.ToInt32(dr[0].ToString()) : 0, wrenchCode = dr[2].ToString(), wrenchBarCode = dr[3].ToString(), rangeMax = Convert.ToDecimal(dr[4].ToString()), rangeMin = Convert.ToDecimal(dr[5].ToString()), targetvalue = Convert.ToDecimal(dr[6].ToString()), targetvalue1 = dr[7] == null ? 0 : Convert.ToDecimal(dr[7].ToString()), targetvalue2 = dr[8] == null ? 0 : Convert.ToDecimal(dr[8].ToString()), factory = dr[11] == null ? " " : dr[11].ToString(), createDate = dr[9] != null ? Convert.ToDateTime(Convert.ToDateTime(dr[9]).ToString("yyyy-MM-dd HH:mm:ss")) : Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")), comment = dr[12] == null ? " " : dr[12].ToString(), species = wl.FirstOrDefault().id.ToString(), status = ws.id.ToString(), guid = Guid.NewGuid().ToString(), unit = "N.m", cycletime = 0, isallowcheck = true, lastrepair = dr[10] != null ? Convert.ToDateTime(Convert.ToDateTime(dr[10]).ToString("yyyy-MM-dd HH:mm:ss")) : Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")) }); } return(listwrench); } catch { return(listwrench = null); } }
private void bt_del_Click(object sender, RoutedEventArgs e) { if (this.dt_showdata.SelectedIndex >= 0) { wrenchstatus w = this.dt_showdata.SelectedItem as wrenchstatus; if (w != null) { if (WrenchStatus.Del(w)) { MessageAlert.Alert("删除成功!"); } else { MessageAlert.Alert("该条记录不能删除!"); } } databind(getsatus()); } }
private void bt_submit_Click(object sender, RoutedEventArgs e) { if (cb_status.SelectedIndex < 0) { MessageAlert.Alert("请选择要修改的状态!"); return; } if (ischeck() <= 0) { MessageAlert.Warning("请选择要修该的内容!"); return; } wrenchstatus w = this.cb_status.SelectedItem as wrenchstatus; if (w == null || w.guid == null) { return; } if (updata(w.statusDM)) { MessageAlert.Alert("修改成功!"); } BindGrid(toollist); }
bool save(wrenchstatus w) { return(WrenchStatus.add(w)); }
public bool Del(wrenchstatus wrenchstatus) { string contion = string.Format("id='{0}'", wrenchstatus.id); return(ServerHelp.deleteDataByWhere <wrenchstatus>(_webip, contion)); }
void showdata(wrenchstatus ws) { this.tb_statuscode.Text = ws.statusDM; this.tb_statusname.Text = ws.statusName; }