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.Dresses.SetSmallForm { public partial class DressPageCountSamllForm : LYFZ.Software.UI.Dresses.SetSmallForm.DressPageCountSamllForm { LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder(); LYFZ.BLL.BLL_ErpSystemConfigure scbll = new BLL.BLL_ErpSystemConfigure(); public DressPageCountSamllForm() { this.Load += DressPageCountSamllForm_Load; this.btnSaveed.Click += btnSaveed_Click; this.txtLoadCount.KeyPress += txtLoadCount_KeyPress; this.txtLoadCount.Leave += txtLoadCount_Leave; } /// <summary> /// 是否保存 /// </summary> public bool IsSaveed = false; DataTable dt = new DataTable(); /// <summary> /// 窗体加载事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void DressPageCountSamllForm_Load(object sender, EventArgs e) { dt = orbll.GetView_Custom("tb_ErpSystemConfigure", StrWhere: "Sconfig_Code = 'DressPageCount'", ShowColumnName: "*").Tables[0]; if (dt.Rows.Count > 0) { if (dt.Rows[0]["Sconfig_Value"].ToString().Trim().Length > 0) { this.txtLoadCount.Text = dt.Rows[0]["Sconfig_Value"].ToString().Trim(); } else { this.txtLoadCount.Text = "0"; } } else { this.txtLoadCount.Text = "50"; } } /// <summary> /// 保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void btnSaveed_Click(object sender, EventArgs e) { LYFZ.Model.Model_ErpSystemConfigure model = null; if (dt.Rows.Count > 0) { model = scbll.DataRowToModel(dt.Rows[0]); if (this.txtLoadCount.Text.Trim().Length > 0) { model.Sconfig_Value = this.txtLoadCount.Text.Trim(); } else { model.Sconfig_Value = "0"; } IsSaveed = scbll.Update(model); } else { model = new Model.Model_ErpSystemConfigure(); model.Sconfig_Code = "DressPageCount"; model.Sconfig_Name = "礼服每页加载条数"; model.Sconfig_Value = "50"; model.Sconfig_Remark = "礼服租售工具箱首次加载每页显示条数"; model.Sconfig_IsEnabled = true; model.Sconfig_Type = "1"; model.Sconfig_Order = 0; model.Sconfig_CreateDatetime = SDateTime.Now; model.Sconfig_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_Name; IsSaveed = scbll.Add(model); } if (IsSaveed) { MessageBoxCustom.Show("保存成功!"); this.Close(); } else { MessageBoxCustom.Show("保存失败!"); return; } } /// <summary> /// 文本框输入事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void txtLoadCount_KeyPress(object sender, KeyPressEventArgs e) { if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar)) { e.Handled = true; } } /// <summary> /// 离开事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void txtLoadCount_Leave(object sender, EventArgs e) { LYFZ.ComponentLibrary.TextBoxEx txtText = (LYFZ.ComponentLibrary.TextBoxEx)sender; if (txtText.Text.Trim().Length <= 0) { txtText.Text = "0"; } } } }