using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace LYFZ.Software.MainBusiness.CameraControlBook.SuperSmallForm { public partial class AlertSettingSuperSmallForm : LYFZ.Software.UI.CameraControlBook.SuperSmallForm.AlertSettingSuperSmallForm { LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder(); LYFZ.BLL.BLL_ErpSystemConfigure sgbll = new BLL.BLL_ErpSystemConfigure(); public AlertSettingSuperSmallForm() { this.Load += AlertSettingSuperSmallForm_Load; this.btnSaveed.Click += btnSaveed_Click; this.btnColseed.Click += btnColseed_Click; this.chkSelectionFilm_OriginalFilm.Click += chkSelectionFilm_OriginalFilm_Click; this.chkSelectionFilm_EarlyRepair.Click += chkSelectionFilm_EarlyRepair_Click; this.txtSelectionFilm.KeyPress += txtSelectionFilm_KeyPress; this.txtLookDesign.KeyPress += txtLookDesign_KeyPress; this.txtPickup.KeyPress += txtPickup_KeyPress; this.txtSelectionFilm.Leave += txtSelectionFilm_Leave; this.txtLookDesign.Leave += txtLookDesign_Leave; this.txtPickup.Leave += txtPickup_Leave; } /// /// 是否保存 /// public bool IsSaveed = false; string StrID = ""; /// /// 窗体加载事件 /// /// /// void AlertSettingSuperSmallForm_Load(object sender, EventArgs e) { DataTable dt = orbll.GetView_Custom("tb_ErpSystemConfigure", StrWhere: "Sconfig_Code = 'ReservationDateBeforeRemind'", ShowColumnName: "ID,Sconfig_Value").Tables[0]; if (dt.Rows.Count > 0) { StrID = dt.Rows[0]["ID"].ToString().Trim(); DataTable tbl = new Json.JsontoDataTable().toObject(dt.Rows[0]["Sconfig_Value"].ToString().Trim()); for (int i = 0; i < tbl.Rows.Count; i++) { switch (tbl.Rows[i]["StrCode"].ToString().Trim()) { case "SelectionFilm": this.chk_SelectionFilm.Checked = Convert.ToBoolean(tbl.Rows[i]["StrIsShow"].ToString().Trim()); this.txtSelectionFilm.Text = tbl.Rows[i]["StrValue"].ToString().Trim(); switch (tbl.Rows[i]["StrValueType"].ToString().Trim()) { case "EarlyRepair": this.chkSelectionFilm_EarlyRepair.Checked = true; this.chkSelectionFilm_OriginalFilm.Checked = false; break; case "OriginalFilm": this.chkSelectionFilm_EarlyRepair.Checked = false; this.chkSelectionFilm_OriginalFilm.Checked = true; break; } break; case "LookDesign": this.chk_LookDesign.Checked = Convert.ToBoolean(tbl.Rows[i]["StrIsShow"].ToString().Trim()); this.txtLookDesign.Text = tbl.Rows[i]["StrValue"].ToString().Trim(); break; case "Pickup": this.chk_Pickup.Checked = Convert.ToBoolean(tbl.Rows[i]["StrIsShow"].ToString().Trim()); this.txtPickup.Text = tbl.Rows[i]["StrValue"].ToString().Trim(); break; } } } } /// /// 保存 /// /// /// void btnSaveed_Click(object sender, EventArgs e) { if (!this.chkSelectionFilm_EarlyRepair.Checked && !this.chkSelectionFilm_OriginalFilm.Checked) { MessageBoxCustom.Show("选片预约前未导片,必须选择'按原片'或'按初修片'"); return; } if(string.IsNullOrEmpty(this.txtSelectionFilm.Text)) { this.txtSelectionFilm.Text = "0"; } if (string.IsNullOrEmpty(this.txtLookDesign.Text)) { this.txtLookDesign.Text = "0"; } if (string.IsNullOrEmpty(this.txtPickup.Text)) { this.txtPickup.Text = "0"; } DataTable newdtb = new DataTable(); newdtb.Columns.Add("StrCode", typeof(string)); newdtb.Columns.Add("StrName", typeof(string)); newdtb.Columns.Add("StrIsShow", typeof(string)); newdtb.Columns.Add("StrValue", typeof(string)); newdtb.Columns.Add("StrValueType", typeof(string)); newdtb.Columns.Add("StrExplain", typeof(string)); DataRow newRow = newdtb.NewRow(); newRow["StrCode"] = "SelectionFilm"; newRow["StrName"] = "选片预约前天未导片预警"; newRow["StrIsShow"] = this.chk_SelectionFilm.Checked.ToString().Trim(); newRow["StrValue"] = this.txtSelectionFilm.Text.Trim(); newRow["StrValueType"] = this.chkSelectionFilm_EarlyRepair.Checked ? this.chkSelectionFilm_EarlyRepair.Name.Trim().Split('_')[1] : this.chkSelectionFilm_OriginalFilm.Name.Trim().Split('_')[1]; newRow["StrExplain"] = "如果StrValueType为EarlyRepair则按初修交片日期算,如果StrValueType为OriginalFilm则按原片最后交片日期算."; newdtb.Rows.Add(newRow); newRow = newdtb.NewRow(); newRow["StrCode"] = "LookDesign"; newRow["StrName"] = "看样预约前天未导片预警"; newRow["StrIsShow"] = this.chk_LookDesign.Checked.ToString().Trim(); newRow["StrValue"] = this.txtLookDesign.Text.Trim(); newRow["StrValueType"] = ""; newRow["StrExplain"] = ""; newdtb.Rows.Add(newRow); newRow = newdtb.NewRow(); newRow["StrCode"] = "Pickup"; newRow["StrName"] = "取件预约前天未回片预警 "; newRow["StrIsShow"] = this.chk_Pickup.Checked.ToString().Trim(); newRow["StrValue"] = this.txtPickup.Text.Trim(); newRow["StrValueType"] = ""; newRow["StrExplain"] = ""; newdtb.Rows.Add(newRow); string ModifiedData = "ds" + new Json.JsontoDataTable().toJson(newdtb); LYFZ.Model.Model_ErpSystemConfigure model = null; if (string.IsNullOrEmpty(StrID)) { model = new Model.Model_ErpSystemConfigure(); } else { model = sgbll.GetModel(Convert.ToInt32(this.StrID)); } new Model.Model_ErpSystemConfigure(); model.Sconfig_Code = "ReservationDateBeforeRemind"; model.Sconfig_Name = "预约日期前几天提醒"; model.Sconfig_Value = ModifiedData; model.Sconfig_IsEnabled = true; model.Sconfig_Remark = ""; model.Sconfig_Type = ""; model.Sconfig_Order = 1; model.Sconfig_CreateDatetime = SDateTime.Now; model.Sconfig_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID; if (string.IsNullOrEmpty(StrID)) { this.IsSaveed = sgbll.Add(model); } else { this.IsSaveed = sgbll.Update(model); } if (!this.IsSaveed) { MessageBoxCustom.Show("保存失败!"); } else { MessageBoxCustom.Show("保存成功!"); } } /// /// 关闭 /// /// /// void btnColseed_Click(object sender, EventArgs e) { this.Close(); } /// /// 按原片 /// /// /// void chkSelectionFilm_OriginalFilm_Click(object sender, EventArgs e) { this.chkSelectionFilm_OriginalFilm.Checked = true; this.chkSelectionFilm_EarlyRepair.Checked = false; } /// /// 按初修片 /// /// /// void chkSelectionFilm_EarlyRepair_Click(object sender, EventArgs e) { this.chkSelectionFilm_OriginalFilm.Checked = false; this.chkSelectionFilm_EarlyRepair.Checked = true; } /// /// 输入限制 /// /// /// void txtSelectionFilm_KeyPress(object sender, KeyPressEventArgs e) { if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar)) { e.Handled = true; } if (!System.Text.RegularExpressions.Regex.IsMatch(e.KeyChar.ToString(), "[0-9]") && e.KeyChar != ' ' && e.KeyChar != '\b') { e.Handled = true; } } /// /// 输入限制 /// /// /// void txtLookDesign_KeyPress(object sender, KeyPressEventArgs e) { if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar)) { e.Handled = true; } if (!System.Text.RegularExpressions.Regex.IsMatch(e.KeyChar.ToString(), "[0-9]") && e.KeyChar != ' ' && e.KeyChar != '\b') { e.Handled = true; } } /// /// 输入限制 /// /// /// void txtPickup_KeyPress(object sender, KeyPressEventArgs e) { if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar)) { e.Handled = true; } if (!System.Text.RegularExpressions.Regex.IsMatch(e.KeyChar.ToString(), "[0-9]") && e.KeyChar != ' ' && e.KeyChar != '\b') { e.Handled = true; } } /// /// 离开事件 /// /// /// void txtSelectionFilm_Leave(object sender, EventArgs e) { try { this.txtSelectionFilm.Text = Convert.ToInt32(this.txtSelectionFilm.Text.Trim()).ToString(); } catch { } } /// /// 离开事件 /// /// /// void txtLookDesign_Leave(object sender, EventArgs e) { try { this.txtLookDesign.Text = Convert.ToInt32(this.txtLookDesign.Text.Trim()).ToString(); } catch { } } /// /// 离开事件 /// /// /// void txtPickup_Leave(object sender, EventArgs e) { try { this.txtPickup.Text = Convert.ToInt32(this.txtPickup.Text.Trim()).ToString(); } catch { } } } }