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.DressManagement.Valet { public partial class FrmDressValet : LYFZ.Software.UI.Dresses.DressManagement.Valet.FrmDressValet { bool bl = false; public string Dsfm_DressNumber; public FrmDressValet() { this.FormClosed += FrmDressValet_FormClosed; } void FrmDressValet_FormClosed(object sender, FormClosedEventArgs e) { if (bl) { this.DialogResult = DialogResult.OK; } } #region 加载 protected override void FrmDressValet_Shown(object sender, EventArgs e) { try { LYFZ.BLL.BLL_ErpDressFrom DressFromBll = new BLL.BLL_ErpDressFrom(); DataTable dt = new DataTable(); txtDsro_CreateName.Text = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_Name; txtDsro_CreateDateTime.Text = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime().ToString("yyyy-MM-dd"); #region 获取单号 BindDsro_Number(); #endregion #region 获取礼服资料 if (!string.IsNullOrEmpty(Dsfm_DressNumber)) { string[] Dsfm_DressNumbers = Dsfm_DressNumber.Split(','); for (int t = 0; t < Dsfm_DressNumbers.Length; t++) { dt = DressFromBll.View_tb_ErpDressFrom(" and Dsfm_DressNumber='" + Dsfm_DressNumbers[t] + "'").Tables[0]; #region DataGridViewRow dgvr = new DataGridViewRow(); DataGridViewCell cell = null; cell = new DataGridViewTextBoxCell(); cell.Value = dt.Rows[0]["Dsfm_DressNumber"].ToString().Trim(); dgvr.Cells.Add(cell); cell = new DataGridViewTextBoxCell(); cell.Value = dt.Rows[0]["Dsfm_DressName"].ToString().Trim(); dgvr.Cells.Add(cell); cell = new DataGridViewTextBoxCell(); cell.Value = "1"; dgvr.Cells.Add(cell); cell = new DataGridViewTextBoxCell(); cell.Value = dt.Rows[0]["Dsfm_CostPrice"].ToString().Trim(); dgvr.Cells.Add(cell); cell = new DataGridViewTextBoxCell(); cell.Value = dt.Rows[0]["Dsfm_SalePrice"].ToString().Trim(); dgvr.Cells.Add(cell); this.dgv.Rows.Add(dgvr); #endregion } dgv.ClearSelection(); } #endregion } catch (Exception ex) { MessageBoxCustom.Show(ex.Message); } } #region 获取礼服送洗订单单号 /// /// 获取礼服送洗订单单号 /// public void BindDsro_Number() { DataTable dt = new DataTable(); //获取最大编号 LYFZ.BLL.BLL_ErpDressSendWashOrder DressSendWashOrderbll = new BLL.BLL_ErpDressSendWashOrder(); dt = DressSendWashOrderbll.GetAllList().Tables[0]; if (dt.Rows.Count > 0) { int Count = Convert.ToInt32(DressSendWashOrderbll.Get_Max_Dsro_Number()); this.txtDsro_Number.Text = "LFSX00" + Convert.ToInt32(Count + 1); } else { this.txtDsro_Number.Text = "LFSX001"; } } #endregion #endregion #region dgv事件 protected override void dgv_Click(object sender, EventArgs e) { if (dgv.Rows.Count > 0) { LYFZ.BLL.BLL_ErpDressFrom DressFromBll = new BLL.BLL_ErpDressFrom(); DataTable dt = new DataTable(); string Dsfm_DressNumber = dgv.CurrentRow.Cells["Dsfm_DressNumber"].Value.ToString(); dt = DressFromBll.View_tb_ErpDressFrom(" and Dsfm_DressNumber='" + Dsfm_DressNumber + "'").Tables[0]; if (dt.Rows.Count > 0) { picDsfm_PicturePath.Image = Image.FromFile(BLL.BLL_ErpDressFrom.GetDressFromPath() + "\\" + dt.Rows[0]["Dsfm_PicturePath"]); } } } #endregion #region 保存 protected override void btnSave_Click(object sender, EventArgs e) { try { LYFZ.BLL.BLL_ErpDressSendWashOrder DressSendWashOrderBll = new BLL.BLL_ErpDressSendWashOrder(); LYFZ.Model.Model_ErpDressSendWashOrder DressSendWashOrderModel = new Model.Model_ErpDressSendWashOrder(); LYFZ.BLL.BLL_ErpDressSendWashDetail DressSendWashDetailBll = new BLL.BLL_ErpDressSendWashDetail(); LYFZ.Model.Model_ErpDressSendWashDetail DressSendWashDetailModel = new Model.Model_ErpDressSendWashDetail(); LYFZ.BLL.BLL_ErpDressFrom DressFromBll = new BLL.BLL_ErpDressFrom(); #region 判断输入框不能为空 if (string.IsNullOrEmpty(txtDsro_Number.Text)) { MessageBoxCustom.Show("单号不能为空!"); return; } if (dgv.Rows.Count == 0) { MessageBoxCustom.Show("礼服资料不能为空!请选择礼服!"); return; } if (string.IsNullOrEmpty(txtDsro_TakeDressTime.Text)) { MessageBoxCustom.Show("送洗时间不能为空!"); return; } if (string.IsNullOrEmpty(txtDsro_ReservationBackTime.Text)) { MessageBoxCustom.Show("还回时间不能为空!"); return; } if (!string.IsNullOrEmpty(txtDsro_TakeDressTime.Text) && !string.IsNullOrEmpty(txtDsro_ReservationBackTime.Text)) { if (Convert.ToDateTime(txtDsro_TakeDressTime.Text) > Convert.ToDateTime(txtDsro_ReservationBackTime.Text)) { MessageBoxCustom.Show("送洗时间必须小于还回时间!"); return; } } #endregion #region 增加礼服送洗订单表 DressSendWashOrderModel.Dswo_Number = txtDsro_Number.Text.Trim(); DressSendWashOrderModel.Dswo_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID(); DressSendWashOrderModel.Dswo_SendWashTime = Convert.ToDateTime(txtDsro_TakeDressTime.Text); DressSendWashOrderModel.Dswo_ReservationBackTime = Convert.ToDateTime(txtDsro_ReservationBackTime.Text); DressSendWashOrderModel.Dswo_Remark = txtDsro_Remark.Text.Trim(); DressSendWashOrderModel.Dswo_CreateDateTime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime(); DressSendWashOrderModel.Dswo_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID; DressSendWashOrderBll.Add(DressSendWashOrderModel); #endregion #region 增加送洗礼服详情表 if (dgv.Rows.Count > 0) { for (int i = 0; i < dgv.Rows.Count; i++) { DressSendWashDetailModel.Dswd_Number = DressSendWashOrderModel.Dswo_Number; DressSendWashDetailModel.Dswd_DressNumber = dgv.Rows[i].Cells["Dsfm_DressNumber"].Value.ToString(); DressSendWashDetailModel.Dswd_DressName = dgv.Rows[i].Cells["Dsfm_DressName"].Value.ToString(); DressSendWashDetailModel.Dswd_SendWashQuantity = Convert.ToInt32(dgv.Rows[i].Cells["Dsfm_DressQuantity"].Value); DressSendWashDetailModel.Dswd_CostPrice = Convert.ToDecimal(dgv.Rows[i].Cells["Dsfm_CostPrice"].Value); DressSendWashDetailModel.Dswd_SalePrice = Convert.ToDecimal(dgv.Rows[i].Cells["Dsfm_SalePrice"].Value); DressSendWashDetailModel.Dswd_CreateDatetime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime(); DressSendWashDetailModel.Dswd_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID; DressSendWashDetailModel.Dswd_BackTime = Convert.ToDateTime(null); DressSendWashDetailModel.Dswd_BackStatus = "3"; DressSendWashDetailModel.Dswd_BackRemark = ""; DressSendWashDetailBll.Add(DressSendWashDetailModel); } } #endregion MessageBoxCustom.Show("保存成功!"); bl = true; this.Close(); } catch (Exception ex) { MessageBoxCustom.Show(ex.Message); } } #endregion #region 关闭 protected override void btnClose_Click(object sender, EventArgs e) { this.Close(); } #endregion #region 清空 protected override void btnClear_Click(object sender, EventArgs e) { txtDsro_Remark.Text = ""; BindDsro_Number(); txtDsro_CreateName.Text = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_Name; txtDsro_CreateDateTime.Text = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime().ToString(); } #endregion #region 时间输入框设置 protected override void txtDsro_ReservationBackTime_Leave(object sender, EventArgs e) { if (this.txtDsro_ReservationBackTime.Text.Trim() != "") { if (LYFZ.Command.Command_Validate.IsDateTime(this.txtDsro_ReservationBackTime.Text.Trim()) == false) { this.txtDsro_ReservationBackTime.Text = ""; MessageBoxCustom.Show("还回时间格式输入错误"); txtDsro_ReservationBackTime.Text = Convert.ToDateTime(LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime()).ToString("yyyy-MM-dd"); } } } protected override void txtDsro_ReservationBackTime_Enter(object sender, EventArgs e) { if (this.txtDsro_ReservationBackTime.Text == "") { txtDsro_ReservationBackTime.Text = Convert.ToDateTime(LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime()).ToString("yyyy-MM-dd"); } } protected override void txtDsro_TakeDressTime_Leave(object sender, EventArgs e) { if (this.txtDsro_TakeDressTime.Text.Trim() != "") { if (LYFZ.Command.Command_Validate.IsDateTime(this.txtDsro_TakeDressTime.Text.Trim()) == false) { this.txtDsro_TakeDressTime.Text = ""; MessageBoxCustom.Show("取衣时间格式输入错误"); txtDsro_TakeDressTime.Text = Convert.ToDateTime(LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime()).ToString("yyyy-MM-dd"); } } } protected override void txtDsro_TakeDressTime_Enter(object sender, EventArgs e) { if (this.txtDsro_TakeDressTime.Text == "") { txtDsro_TakeDressTime.Text = Convert.ToDateTime(LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime()).ToString("yyyy-MM-dd"); } } #endregion } }