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.MembershipManage.StatisticsForm { public partial class MemberExpiresRemindSetForm : LYFZ.Software.UI.MembershipManage.StatisticsForm.MemberExpiresRemindSetForm { LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder(); LYFZ.BLL.BLL_ErpSystemConfigure sgbll = new BLL.BLL_ErpSystemConfigure(); public MemberExpiresRemindSetForm() { this.Load += MemberExpiresRemindSetForm_Load; this.Shown += MemberExpiresRemindSetForm_Shown; this.btnSaveed.Click += btnSaveed_Click; this.btnCancel.Click += btnCancel_Click; } /// /// 是否保存 /// public bool IsSaveed = false; /// /// 保存后的数据 /// public string StrJosnData = ""; DataRow dtRows; /// /// 窗体加载事件 /// /// /// void MemberExpiresRemindSetForm_Load(object sender, EventArgs e) { DataTable tbl = sgbll.GetList("Sconfig_Code in ('MemberExpiresSet')").Tables[0]; if (tbl.Rows.Count > 0) { dtRows = tbl.Rows[0]; DataTable dt = new Json.JsontoDataTable().toObject(tbl.Rows[0]["Sconfig_Value"].ToString().Trim()); for (int i = 0; i < dt.Rows.Count; i++) { switch (dt.Rows[i]["StrName"].ToString().Trim()) { case "Points": this.txtPoints.Text = dt.Rows[i]["StrValue"].ToString().Trim(); this.chkPoints.Checked = Convert.ToBoolean(dt.Rows[i]["StrCheck"]); break; case "StoredValue": this.txtStoredValue.Text = dt.Rows[i]["StrValue"].ToString().Trim(); this.chkStoredValue.Checked = Convert.ToBoolean(dt.Rows[i]["StrCheck"]); break; case "BackCash": this.txtBackCash.Text = dt.Rows[i]["StrValue"].ToString().Trim(); this.chkBackCash.Checked = Convert.ToBoolean(dt.Rows[i]["StrCheck"]); break; case "Service": this.txtService.Text = dt.Rows[i]["StrValue"].ToString().Trim(); this.chkService.Checked = Convert.ToBoolean(dt.Rows[i]["StrCheck"]); break; case "Photographer": this.txtPhotographer.Text = dt.Rows[i]["StrValue"].ToString().Trim(); this.chkPhotographer.Checked = Convert.ToBoolean(dt.Rows[i]["StrCheck"]); break; } } } //else //{ this.txtServiceItemCount.Text = "0"; } } /// /// 窗体加载事件 /// /// /// void MemberExpiresRemindSetForm_Shown(object sender, EventArgs e) { } /// /// 保存 /// /// /// void btnSaveed_Click(object sender, EventArgs e) { if (this.txtPoints.Text.Trim().Length <= 0) { MessageBoxCustom.Show("积分提醒期限不能为空!"); return; } if (this.txtStoredValue.Text.Trim().Length <= 0) { MessageBoxCustom.Show("储值提醒期限不能为空!"); return; } if (this.txtBackCash.Text.Trim().Length <= 0) { MessageBoxCustom.Show("返现提醒期限不能为空!"); return; } if (this.txtService.Text.Trim().Length <= 0) { MessageBoxCustom.Show("服务提醒期限不能为空!"); return; } if (this.txtPhotographer.Text.Trim().Length <= 0) { MessageBoxCustom.Show("新摄会提醒期限不能为空!"); return; } DateTime strTime = SDateTime.Now; LYFZ.Model.Model_ErpSystemConfigure model = null; List clist = new List(); string strUserID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID; DataTable newtable = new DataTable(); newtable.Columns.Add("StrName", typeof(string)); newtable.Columns.Add("StrValue", typeof(string)); newtable.Columns.Add("StrCheck", typeof(string)); DataRow dtNewRow = newtable.NewRow(); dtNewRow["StrName"] = "Points"; dtNewRow["StrValue"] = this.txtPoints.Text.Trim(); dtNewRow["StrCheck"] = this.chkPoints.Checked.ToString().Trim(); newtable.Rows.Add(dtNewRow); dtNewRow = newtable.NewRow(); dtNewRow["StrName"] = "StoredValue"; dtNewRow["StrValue"] = this.txtStoredValue.Text.Trim(); dtNewRow["StrCheck"] = this.chkStoredValue.Checked.ToString().Trim(); newtable.Rows.Add(dtNewRow); dtNewRow = newtable.NewRow(); dtNewRow["StrName"] = "BackCash"; dtNewRow["StrValue"] = this.txtBackCash.Text.Trim(); dtNewRow["StrCheck"] = this.chkBackCash.Checked.ToString().Trim(); newtable.Rows.Add(dtNewRow); dtNewRow = newtable.NewRow(); dtNewRow["StrName"] = "Service"; dtNewRow["StrValue"] = this.txtService.Text.Trim(); dtNewRow["StrCheck"] = this.chkService.Checked.ToString().Trim(); newtable.Rows.Add(dtNewRow); dtNewRow = newtable.NewRow(); dtNewRow["StrName"] = "Photographer"; dtNewRow["StrValue"] = this.txtPhotographer.Text.Trim(); dtNewRow["StrCheck"] = this.chkPhotographer.Checked.ToString().Trim(); newtable.Rows.Add(dtNewRow); string StrJosnData = new Json.JsontoDataTable().toJson(newtable); if (this.dtRows != null) { model = sgbll.GetModel("Sconfig_Code", "MemberExpiresSet"); if (model.Sconfig_Value.Trim() != StrJosnData) { model.Sconfig_Name = "会员到期提醒设置"; model.Sconfig_Value = StrJosnData; model.Sconfig_Remark = "服务项次数低于N次提醒"; model.Sconfig_CreateDatetime = strTime; model.Sconfig_CreateName = strUserID; clist.Add(sgbll.GetUpdateCommandInfo(model)); } } else { model = new Model.Model_ErpSystemConfigure(); model.Sconfig_Code = "MemberExpiresSet"; model.Sconfig_Name = "会员到期提醒设置"; model.Sconfig_Value = StrJosnData; model.Sconfig_IsEnabled = true; model.Sconfig_Remark = "会员到期前N天提醒"; model.Sconfig_Type = ""; model.Sconfig_Order = 1; model.Sconfig_CreateDatetime = strTime; model.Sconfig_CreateName = strUserID; clist.Add(sgbll.GetAddCommandInfo(model)); } if (clist.Count > 0) { if (LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist) <= 0) { MessageBoxCustom.Show("保存失败"); return; } this.IsSaveed = true; this.StrJosnData = StrJosnData; MessageBoxCustom.Show("保存成功"); this.Close(); } else { MessageBoxCustom.Show("没做任何修改,无须保存!"); return; } } /// /// 取消 /// /// /// void btnCancel_Click(object sender, EventArgs e) { this.Close(); } } }