/// <summary> /// 设置状态 /// </summary> /// <param name="btn">状态修改按钮</param> /// <param name="cmb">通道号下拉框</param> /// <returns>0无操作,1成功,2失败</returns> private string YCStatusChange(Button btn, ComboBox cmb) { string newstatevalue; string newstatename; if (btn.Text == "已启用") { newstatevalue = "0"; newstatename = "已禁用"; } else { newstatevalue = "10"; newstatename = "已启用"; } DialogResult dia = MessageBox.Show("确当修改状态为" + newstatename + "?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (dia == DialogResult.OK) { HUNHETROUGH2 obj = new HUNHETROUGH2(); obj.troughnum = cmb.Text; obj.status = newstatevalue; databinding(); return(SpecialSmoke.StatusChange(obj, Convert.ToDecimal(comboBox_linenums.SelectedItem))); } else { return("取消操作!"); } }
//互换烟仓 private void button_huhuan_Click(object sender, EventArgs e) { DialogResult result = MessageBox.Show("确认进行互换:\r\n" + comboBox_yc1.Text + " " + label_ycpp1.Text + "\r\n" + comboBox_yc2.Text + " " + label_ycpp2.Text, "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (result == DialogResult.OK) { HUNHETROUGH2 obj1 = new HUNHETROUGH2(); HUNHETROUGH2 obj2 = new HUNHETROUGH2(); obj1.troughnum = comboBox_yc1.Text; obj2.troughnum = comboBox_yc2.Text; obj1.cigarettecode = troughlist.Where(x => x.troughnum == comboBox_yc1.Text).Select(x => x.cigarettecode).FirstOrDefault(); obj1.cigarettename = troughlist.Where(x => x.troughnum == comboBox_yc1.Text).Select(x => x.cigarettename).FirstOrDefault(); obj1.machineseq = troughlist.Where(x => x.troughnum == comboBox_yc1.Text).Select(x => x.machineseq).FirstOrDefault(); obj1.status = troughlist.Where(x => x.troughnum == comboBox_yc1.Text).Select(x => x.status).FirstOrDefault(); obj2.cigarettecode = troughlist.Where(x => x.troughnum == comboBox_yc2.Text).Select(x => x.cigarettecode).FirstOrDefault(); obj2.cigarettename = troughlist.Where(x => x.troughnum == comboBox_yc2.Text).Select(x => x.cigarettename).FirstOrDefault(); obj2.machineseq = troughlist.Where(x => x.troughnum == comboBox_yc2.Text).Select(x => x.machineseq).FirstOrDefault(); obj2.status = troughlist.Where(x => x.troughnum == comboBox_yc2.Text).Select(x => x.status).FirstOrDefault(); if (SpecialSmoke.HuHuanYc(obj1, obj2, Convert.ToDecimal(comboBox_linenums.SelectedItem))) { MessageBox.Show("互换成功!"); } else { MessageBox.Show("互换失败!"); } databinding(); } }
/// <summary> /// 互换烟仓 /// </summary> /// <param name="obj1">烟仓1</param> /// <param name="obj2">烟仓2</param> /// <returns>互换结果</returns> public static bool HuHuanYc(HUNHETROUGH2 obj1, HUNHETROUGH2 obj2, decimal groupno) { Entities et = new Entities(); var list = et.T_PRODUCE_SORTTROUGH.Where(x => x.CIGARETTETYPE == 30 && x.TROUGHTYPE == 10 && x.GROUPNO == groupno).Select(x => x).ToList(); foreach (var item in list) { if (item.TROUGHNUM == obj2.troughnum) { item.CIGARETTECODE = obj1.cigarettecode; item.CIGARETTENAME = obj1.cigarettename; } if (item.TROUGHNUM == obj1.troughnum) { item.CIGARETTECODE = obj2.cigarettecode; item.CIGARETTENAME = obj2.cigarettename; } } if (et.SaveChanges() > 0) { return(true); } else { return(false); } }
private void button_tohunhe_Click(object sender, EventArgs e) { DialogResult result = MessageBox.Show("确定进行烟仓与混合道品牌互换?", "", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (result == DialogResult.Cancel) { label_hhdppt.Text = null; textBox_hunhe.Text = null; return; } if (label_hhdppt.Text.Length > 0 && textBox_hunhe.Text.Length > 0) { HUNHETROUGH2 hunhe = new HUNHETROUGH2(); HUNHETROUGH2 yc = new HUNHETROUGH2(); hunhe.troughnum = label_hhdppt.Text; yc.troughnum = comboBox_yct.Text; hunhe.cigarettecode = specialtroughlist.Where(x => x.troughnum == label_hhdppt.Text).Select(x => x.cigarettecode).FirstOrDefault(); hunhe.cigarettename = specialtroughlist.Where(x => x.troughnum == label_hhdppt.Text).Select(x => x.cigarettename).FirstOrDefault(); hunhe.machineseq = specialtroughlist.Where(x => x.troughnum == label_hhdppt.Text).Select(x => x.machineseq).FirstOrDefault(); hunhe.status = specialtroughlist.Where(x => x.troughnum == label_hhdppt.Text).Select(x => x.status).FirstOrDefault(); yc.cigarettecode = troughlist.Where(x => x.troughnum == comboBox_yct.Text).Select(x => x.cigarettecode).FirstOrDefault(); yc.cigarettename = troughlist.Where(x => x.troughnum == comboBox_yct.Text).Select(x => x.cigarettename).FirstOrDefault(); yc.machineseq = troughlist.Where(x => x.troughnum == comboBox_yct.Text).Select(x => x.machineseq).FirstOrDefault(); yc.status = troughlist.Where(x => x.troughnum == comboBox_yct.Text).Select(x => x.status).FirstOrDefault(); if (SpecialSmoke.HuHuanHunHeDao(hunhe, yc, Convert.ToDecimal(comboBox_linenums.SelectedItem))) { MessageBox.Show("互换成功!"); } else { MessageBox.Show("互换失败!"); } databinding(); label_hhdppt.Text = null; textBox_hunhe.Text = null; } else { MessageBox.Show("请选择要参与互换的混合道品牌"); } }
/// <summary> /// 修改状态 /// </summary> /// <returns></returns> public static string StatusChange(HUNHETROUGH2 obj, decimal groupno) { Entities et = new Entities(); var list = et.T_PRODUCE_SORTTROUGH.Where(x => x.CIGARETTETYPE == 30 && x.TROUGHTYPE == 10 && x.GROUPNO == groupno).Select(x => x).ToList(); foreach (var item in list) { if (item.TROUGHNUM == obj.troughnum && item.STATE != obj.status) { item.STATE = obj.status; } } if (et.SaveChanges() > 0) { return("修改成功!"); } else { return("修改失败!"); } }