//加载故障原因 public void initFaultreason() { string MachineJson = Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Machine", "GetMachine", machine_code); List <V_Station_Machine> MachineList = JsonConvert.DeserializeObject <List <V_Station_Machine> >(MachineJson); string type_id = string.Empty; if (MachineList != null) { type_id = MachineList[0].type_id.ToString(); } string Json = Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Machine", "GetMachineFaultphenomenon", type_id); List <B_Machine_Faultphenomenon> ListFaultreason = JsonConvert.DeserializeObject <List <B_Machine_Faultphenomenon> >(Json); if (ListFaultreason != null) { for (int i = 0; i < ListFaultreason.Count(); i++) { Tools.ComboboxItem item = new Tools.ComboboxItem(); item.Value = ListFaultreason[i].faultphenomenon_code; item.Text = ListFaultreason[i].faultphenomenon_name; this.comboBox1.Items.Add(item); SaveFaultreason.Add(ListFaultreason[i].faultphenomenon_name, ListFaultreason[i].faultphenomenon_code);//保存键值 } this.comboBox1.SelectedIndex = this.comboBox1.Items.Count > 0 ? 0 : -1; } this.comboBox2.SelectedIndex = this.comboBox2.Items.Count > 0 ? 0 : -1; }
//加载关机原因 public void initOffFaultreason() { string Json = Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Machine", "GetMachineOFFFaultreason", ""); List <B_Machine_Stopreason> ListFaultreason = JsonConvert.DeserializeObject <List <B_Machine_Stopreason> >(Json); for (int i = 0; i < ListFaultreason.Count(); i++) { Tools.ComboboxItem item = new Tools.ComboboxItem(); item.Value = ListFaultreason[i].stopreason_code; item.Text = ListFaultreason[i].stopreason_name; this.comboBox1.Items.Add(item); SaveFaultreason.Add(ListFaultreason[i].stopreason_name, ListFaultreason[i].stopreason_code);//保存键值 this.comboBox1.SelectedIndex = this.comboBox1.Items.Count > 0 ? 0 : -1; } }
//初始化页面 public void InitFrom(string sfc, List <P_SFC_Jude> ListJude, decimal qty) { this.textBox1.Text = sfc; this.dataGridView1.DataSource = ListJude; this.textBox2.Text = qty.ToString(); string gradeJson = Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.SFC", "GetSfcGrade", sfc); List <V_SFC_Grade> listGrade = JsonConvert.DeserializeObject <List <V_SFC_Grade> >(gradeJson); if (listGrade != null) { foreach (var grade in listGrade) { Tools.ComboboxItem item = new Tools.ComboboxItem(); item.Value = grade.grade_code; item.Text = grade.grade_name; this.comboBox1.Items.Add(item); } this.comboBox1.SelectedIndex = this.comboBox1.Items.Count > 0 ? 0 : -1; } }