/// <summary> /// 保存设置 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAdd_Click(object sender, EventArgs e) { try { //得到页面对应车辆类型的打印设置 int carType_ID = int.Parse(comboxCartype.SelectedValue.ToString()); //得到选择的打印内容 string print_Content = ""; if (chkCarNumber.Checked) { print_Content += chkCarNumber.Text.Trim() + ","; } if (chkCarType.Checked) { print_Content += chkCarType.Text.Trim() + ","; } if (chkStaff_Name.Checked) { print_Content += chkStaff_Name.Text.Trim() + ","; } if (chkList.CheckedItems.Count > 0) { foreach (var item in chkList.CheckedItems) { print_Content += item + ","; } } PrintInfo print = new PrintInfo(); print.Print_Content = print_Content.Substring(0, print_Content.Length - 1); print.Print_CarType_ID = carType_ID; print.Print_State = chkPrint_State.Text.Trim(); print.Print_Attention = txtzhuyishixiang.Text.Trim(); print.Print_Prompt = txttisi.Text.Trim(); if (chkPrint_State.Text.Trim() == "启动") { if (ChkPrintState()) { DialogResult dlgResult = MessageBox.Show("已经存在启动状态的设置,是否替换?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (dlgResult == DialogResult.OK) { //修改条件 Expression <Func <PrintInfo, bool> > funs = n => n.Print_State == "启动" && n.Print_CarType_ID == int.Parse(comboxCartype.SelectedValue.ToString()); //需要修改的内容 Action <PrintInfo> actions = p => { p.Print_State = "暂停"; }; //执行更新 PrintInfoDAL.UpdatePrint(funs, actions); PrintInfoDAL.InsertPrint(print); } else { print.Print_State = "暂停"; PrintInfoDAL.InsertPrint(print); } } else { PrintInfoDAL.InsertPrint(print); } } else { PrintInfoDAL.InsertPrint(print); } DataTable dt = LinQBaseDao.Query("select PrintInfo_ID,PrintInfo_State from PrintInfo order by PrintInfo_ID desc ").Tables[0]; string id = dt.Rows[0][0].ToString(); string state = dt.Rows[0][1].ToString(); if (state == "启动") { CommonalityEntity.WriteLogData("新增", "新增并启动编号为:" + id + "打印设置", CommonalityEntity.USERNAME); } else { CommonalityEntity.WriteLogData("新增", "新增编号为:" + id + "打印设置", CommonalityEntity.USERNAME); } } catch { CommonalityEntity.WriteTextLog("PrintSetForm btnAdd_Click()"); } finally { GetGriddataviewLoad(""); } }
/// <summary> /// 应用打印设置 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnLEDApplication_Click(object sender, EventArgs e) { try { CommonalityEntity.IsCancellation = false; isUpdate = true; int id = int.Parse(this.lvwUserList.SelectedRows[0].Cells["Print_ID"].Value.ToString()); if (ChkPrintState()) { DialogResult dlgResult = MessageBox.Show("已经存在启动状态的设置,是否替换?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (dlgResult == DialogResult.OK) { //修改条件 Expression <Func <PrintInfo, bool> > funs = n => n.Print_State == "启动" && n.Print_CarType_ID == int.Parse(this.lvwUserList.SelectedRows[0].Cells["Print_CarType_ID"].Value.ToString()); //需要修改的内容 Action <PrintInfo> actions = p => { p.Print_State = "暂停"; }; //执行更新 PrintInfoDAL.UpdatePrint(funs, actions); //应用当前选中的设置 //条件 Expression <Func <PrintInfo, bool> > fun = n => n.Print_ID == id; //需要的内容 Action <PrintInfo> action = p => { p.Print_State = "启动"; }; //执行更新 PrintInfoDAL.UpdatePrint(fun, action); CommonalityEntity.WriteLogData("修改", "启动打印编号为:" + id + "的打印设置", CommonalityEntity.USERNAME); } else { return; } } else { //应用当前选中的设置 //条件 Expression <Func <PrintInfo, bool> > fun = n => n.Print_ID == id; //需要的内容 Action <PrintInfo> action = p => { p.Print_State = "启动"; }; //执行更新 PrintInfoDAL.UpdatePrint(fun, action); CommonalityEntity.WriteLogData("修改", "启动打印编号为:" + id + "的打印设置", CommonalityEntity.USERNAME); } } catch { CommonalityEntity.WriteTextLog("LEDSerForm btnLEDApplication_Click()"); } finally { GetGriddataviewLoad("");//加载 } }
/// <summary> /// 修改 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnUpdate_Click(object sender, EventArgs e) { try { //得到页面对应车辆类型的打印设置 int carType_ID = int.Parse(comboxCartype.SelectedValue.ToString()); //得到选择的打印内容 string print_Content = ""; if (chkStaff_Name.Checked) { print_Content += chkStaff_Name.Text.Trim() + ","; } if (chkCarNumber.Checked) { print_Content += chkCarNumber.Text.Trim() + ","; } if (chkCarType.Checked) { print_Content += chkCarType.Text.Trim() + ","; } if (chkList.CheckedItems.Count > 0) { foreach (var item in chkList.CheckedItems) { print_Content += item + ","; } } if (chkPrint_State.Text.Trim() == "启动") { if (ChkPrintState()) { DialogResult dlgResult = MessageBox.Show("已经存在启动状态的设置,是否替换?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (dlgResult == DialogResult.OK) { //修改条件 Expression <Func <PrintInfo, bool> > funs = n => n.Print_State == "启动" && n.Print_CarType_ID == int.Parse(comboxCartype.SelectedValue.ToString()); //需要修改的内容 Action <PrintInfo> actions = p => { p.Print_State = "暂停"; }; //执行更新 PrintInfoDAL.UpdatePrint(funs, actions); } else { return; } } } string id = ""; string strfront = ""; string strcontent = ""; Expression <Func <PrintInfo, bool> > fun = p => p.Print_ID == int.Parse(this.lvwUserList.SelectedRows[0].Cells["Print_ID"].Value.ToString()); Action <PrintInfo> action = print => { strfront = print.Print_Content + "," + print.Print_State + "," + print.Print_CarType_ID; print.Print_Content = print_Content.Substring(0, print_Content.Length - 1); print.Print_State = chkPrint_State.Text.Trim(); print.Print_CarType_ID = carType_ID; print.Print_State = chkPrint_State.Text.Trim(); print.Print_Attention = txtzhuyishixiang.Text.Trim(); print.Print_Prompt = txttisi.Text.Trim(); strcontent = print.Print_Content + "," + print.Print_State + "," + print.Print_CarType_ID; id = print.Print_ID.ToString(); }; PrintInfoDAL.UpdatePrint(fun, action); CommonalityEntity.WriteLogData("修改", "更新打印编号为:" + id + "的打印设置;修改前:" + strfront + ";修改后:" + strcontent, CommonalityEntity.USERNAME); } catch { CommonalityEntity.WriteTextLog("PrintSetForm btnUpdate_Click()");//记录异常日志 } finally { GetGriddataviewLoad(""); btnAdd.Enabled = true; btnUpdate.Enabled = false; } }