using LYFZ.ComponentLibrary; 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.Rental { public partial class FrmRentalManagement : LYFZ.Software.UI.Dresses.DressManagement.Rental.FrmRentalManagement { private delegate void UpdateControl(); public FrmRentalManagement() { this.ucPagerEx1.EventPaging += ucPagerEx1_EventPaging; } #region 加载 protected override void FrmRentalManagement_Shown(object sender, EventArgs e) { try { bind(); #region 收款 if (LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.DressManagement, CustomAttributes.OperatingAuthority.ReceivablesAll)) { btnReceivables.Enabled = true; } else { btnReceivables.Enabled = false; } #endregion } catch (Exception ex) { MessageBoxCustom.Show(ex.Message); } } #region 获取礼服订单 /// /// 获取礼服订单 /// public void bind() { this.ucPagerEx1.PageCurrent = 1; this.ucPagerEx1.PageSize = 100;// LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetPageSize();//3;分页条数 this.ucPagerEx1.Bind(); } #endregion #endregion #region 查询 protected override void btnSlect_Click(object sender, EventArgs e) { try { if (!string.IsNullOrEmpty(txtTimeStart.DateValue)) { if (string.IsNullOrEmpty(txtTimeEnd.DateValue)) { MessageBoxCustom.Show("还衣结束时间不能为空!"); return; } } if (!string.IsNullOrEmpty(txtTimeEnd.DateValue)) { if (string.IsNullOrEmpty(txtTimeStart.DateValue)) { MessageBoxCustom.Show("还衣开始时间不能为空!"); return; } } bind(); } catch (Exception ex) { MessageBoxCustom.Show(ex.Message); } } #endregion #region 删除 protected override void btnDelete_Click(object sender, EventArgs e) { if (this.dgv.SelectedRows.Count == 0) { MessageBoxCustom.Show("请选中你要删除的数据!"); return; } if (MessageBoxCustom.Show("你确定要删除吗?", "删除提示", MessageBoxButtons.YesNo) == DialogResult.Yes) { LYFZ.BLL.BLL_ErpDressSaleRentalOrder bll = new BLL.BLL_ErpDressSaleRentalOrder(); string Dsro_Number = this.dgv.CurrentRow.Cells["Dsro_Number"].Value.ToString(); if (bll.DeleteLf(Dsro_Number) == 1) { #region 写入操作日志 string logsContent = "删除出租礼服编号:" + Dsro_Number; LYFZ.BLL.BLL_ErpSystemLogs.WriteSystemLog(LYFZ.EnumPublic.SystemLogsType.删除礼服, logsContent, LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID, LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name); //LYFZ.BLL.BLL_ErpSystemLogs systemLogsBll = new BLL.BLL_ErpSystemLogs(); //LYFZ.Model.Model_ErpSystemLogs systemLogsModel = new Model.Model_ErpSystemLogs(); //systemLogsModel.Slogs_Type = "user"; //systemLogsModel.Slogs_Topic = "删除出租礼服"; //systemLogsModel.Slogs_Content = "删除出租礼服编号:" + Dsro_Number; //systemLogsModel.Slogs_UserName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_Name; //systemLogsModel.Slogs_IP = ""; //systemLogsModel.Slogs_CreateDatetime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime(); //systemLogsModel.Slogs_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID; //systemLogsBll.Add(systemLogsModel); #endregion MessageBoxCustom.Show("删除成功!"); bind(); } else { MessageBoxCustom.Show("删除失败!"); } } } #endregion #region 修改 protected override void btnUpdate_Click(object sender, EventArgs e) { if (dgv.SelectedRows.Count == 0) { MessageBoxCustom.Show("请选择你要修改的礼服订单"); return; } LYFZ.Software.MainBusiness.Dresses.DressManagement.FrmPreselectedUpdate set = new FrmPreselectedUpdate(); set.Dsro_Number = dgv.CurrentRow.Cells["Dsro_Number"].Value.ToString(); if (set.ShowDialog() == DialogResult.OK) { bind(); } } #endregion #region 还回 protected override void btnAlsoback_Click(object sender, EventArgs e) { if (dgv.SelectedRows.Count == 0) { MessageBoxCustom.Show("选择你要还回的礼服订单"); return; } LYFZ.Software.MainBusiness.Dresses.DressManagement.Rental.FrmAlsoBack set = new FrmAlsoBack(); set.StrOrderNumber = dgv.CurrentRow.Cells["Dsro_Number"].Value.ToString(); if (set.ShowDialog() == DialogResult.OK) { bind(); } } #endregion #region 打印 protected override void btnPrint_Click(object sender, EventArgs e) { try { if (dgv.SelectedRows.Count == 0) { MessageBoxCustom.Show("请选择你要打印的数据!"); return; } LYFZ.Software.MainBusiness.ReportPrint.ReportFixedFormat.PrintFixedFormat(LYFZ.EnumPublic.PrintTypeEnum.礼服出租清单, this.dgv.CurrentRow.Cells["Dsro_Number"].Value); } catch (Exception ex) { MessageBoxCustom.Show(ex.Message); } } #endregion #region 收款 protected override void btnReceivables_Click(object sender, EventArgs e) { try { if (dgv.SelectedRows.Count == 0) { MessageBoxCustom.Show("请选择你要收款的数据!"); return; } LYFZ.Software.MainBusiness.Dresses.DressManagement.Rental.FrmPayment set = new FrmPayment(); set.StrOrderNumber = dgv.CurrentRow.Cells["Dsro_Number"].Value.ToString(); set.ShowDialog(); if (set.IsSaveed) { bind(); } } catch (Exception ex) { MessageBoxCustom.Show(ex.Message); } } #endregion #region 退款 protected override void btnRefund_Click(object sender, EventArgs e) { try { if (dgv.SelectedRows.Count == 0) { MessageBoxCustom.Show("请选择你要退押金的数据!"); return; } LYFZ.Software.MainBusiness.Dresses.DressManagement.Rental.FrmRefundRecord set = new FrmRefundRecord(); set.StrOrderNumber = dgv.CurrentRow.Cells["Dsro_Number"].Value.ToString(); set.ShowDialog(); if (set.IsSaveed) { bind(); } } catch (Exception ex) { MessageBoxCustom.Show(ex.Message); } } #endregion #region 画分页 /// /// 画分页 /// /// /// private int ucPagerEx1_EventPaging(UCPager.EventPagingArg e) { dgv.Rows.Clear(); DataTable dt = new DataTable(); string StrWhere = ""; if (!string.IsNullOrEmpty(txtkeyword.Text)) { StrWhere += " 1=1 and (Dsro_Number like '%" + txtkeyword.Text.Trim() + "%' or Cus_Name like '%" + txtkeyword.Text.Trim() + "%' or Cus_Telephone like '%" + txtkeyword.Text.Trim() + "%' or Py_Cus_Name like '%" + txtkeyword.Text.Trim() + "%') and Dsro_Type='0'"; } else { StrWhere = " 1=1 and Dsro_Type='0'"; } if (!string.IsNullOrEmpty(txtTimeEnd.DateValue) && !string.IsNullOrEmpty(txtTimeStart.DateValue)) { StrWhere += " and Dsro_ReservationBackTime>='" + Convert.ToDateTime(txtTimeStart.DateValue).ToString("yyyy-MM-dd") + "' and Dsro_ReservationBackTime<='" + Convert.ToDateTime(txtTimeEnd.DateValue).ToString("yyyy-MM-dd") + "'"; } //#region 今日 //if (ChkToDay.Checked == true) //{ // StrWhere += " and Dsro_ReservationBackTime>='" + Convert.ToDateTime(LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime()).ToString("yyyy-MM-dd") + "' and Dsro_ReservationBackTime<='" + Convert.ToDateTime(LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime()).ToString("yyyy-MM-dd") + "'"; //} //#endregion //#region 近三日 //if (ChkThreeDay.Checked == true) //{ // string TimeStart = Convert.ToDateTime(LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime()).ToString("yyyy-MM-dd"); // string TimeEnd = Convert.ToDateTime(LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime().AddDays(3)).ToString("yyyy-MM-dd"); // StrWhere += " and Dsro_ReservationBackTime>='" + TimeStart + "' and Dsro_ReservationBackTime<='" + TimeEnd + "'"; //} //#endregion LYFZ.UCPager.PageData pageData = new LYFZ.UCPager.PageData(); LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker) { pageData.TableName = "View_DressSaleRentalOrder"; pageData.PageIndex = this.ucPagerEx1.PageCurrent; pageData.PageSize = this.ucPagerEx1.PageSize; pageData.QueryCondition = StrWhere.ToString(); pageData.QueryFieldName = " ID,Dsro_Number,Dsro_Type,Dsro_Amount,Dsro_MortgageAmount,Dsro_CustomerNumber,Dsro_TakeDressTime,Dsro_ReservationBackTime,Dsro_Remark,Dsro_CreateDateTime,Dsro_CreateName,Dsro_UpdateDateTime,Dsro_UpdateName,Cus_CustomerNumber,Cus_CustomizeNumber,Cus_Type,Cus_ServiceType,Cus_Grade,Cus_Name,Cus_Sex,Cus_Birthday,Cus_BirthdayLunar,Cus_DayForMarriage,Cus_DayForMarriageLunar,Cus_Relations,Cus_QQ,Cus_MicroSignal,Cus_Telephone,Cus_FixedPhone,Cus_Region,Cus_Address,Py_Cus_Name"; pageData.OrderStr = "ID desc"; pageData.OrderType = 1; DataSet da = pageData.QueryDataTable(); dt = da.Tables[0]; if (dt.Rows.Count > 0) { this.Invoke(new UpdateControl(delegate() { for (int t = 0; t < dt.Rows.Count; t++) { #region DataGridViewRow dgvr = new DataGridViewRow(); DataGridViewCell cell = null; cell = new DataGridViewTextBoxCell(); cell.Value = dt.Rows[t]["Dsro_Number"].ToString().Trim(); dgvr.Cells.Add(cell); //应付 cell = new DataGridViewTextBoxCell(); cell.Value = dt.Rows[t]["Dsro_Amount"].ToString().Trim(); dgvr.Cells.Add(cell); //已付 cell = new DataGridViewTextBoxCell(); decimal Paid; LYFZ.BLL.BLL_ErpPayment Paymentbll = new BLL.BLL_ErpPayment(); DataTable DaPayment = Paymentbll.GetSum(" Pay_OrdNumber='" + dt.Rows[t]["Dsro_Number"].ToString().Trim() + "'").Tables[0]; if (string.IsNullOrEmpty(DaPayment.Rows[0]["Pay_AmountOf"].ToString())) { Paid = 0.00m; } else { Paid = Convert.ToDecimal(DaPayment.Rows[0]["Pay_AmountOf"]); } cell.Value = Paid; dgvr.Cells.Add(cell); //欠款 cell = new DataGridViewTextBoxCell(); cell.Value = Convert.ToDecimal(dt.Rows[t]["Dsro_Amount"]) - Convert.ToDecimal(Paid); if (Convert.ToDecimal(cell.Value) > 0) { cell.Style.BackColor = Color.Red; } dgvr.Cells.Add(cell); //押金 cell = new DataGridViewTextBoxCell(); LYFZ.BLL.BLL_ErpDressRefundRecord DressRefundRecordBll = new BLL.BLL_ErpDressRefundRecord(); DataTable dt_DressRefundRecord = DressRefundRecordBll.GetSun(" and DRR_Number='" + dt.Rows[t]["Dsro_Number"].ToString().Trim() + "'").Tables[0]; if (!string.IsNullOrEmpty(dt_DressRefundRecord.Rows[0]["DRR_Money"].ToString())) { cell.Value = Convert.ToDecimal(dt.Rows[t]["Dsro_MortgageAmount"].ToString().Trim()) - Convert.ToDecimal(dt_DressRefundRecord.Rows[0]["DRR_Money"].ToString()); } else { cell.Value = dt.Rows[t]["Dsro_MortgageAmount"].ToString().Trim(); } if (Convert.ToDecimal(cell.Value) > 0) { cell.Style.BackColor = Color.Red; } dgvr.Cells.Add(cell); cell = new DataGridViewTextBoxCell(); cell.Value = dt.Rows[t]["Cus_Name"].ToString().Trim(); dgvr.Cells.Add(cell); cell = new DataGridViewTextBoxCell(); cell.Value = dt.Rows[t]["Cus_Telephone"].ToString().Trim(); dgvr.Cells.Add(cell); cell = new DataGridViewTextBoxCell(); cell.Value = Convert.ToDateTime(dt.Rows[t]["Dsro_TakeDressTime"].ToString().Trim()).ToString("yyyy-MM-dd"); dgvr.Cells.Add(cell); cell = new DataGridViewTextBoxCell(); cell.Value = Convert.ToDateTime(dt.Rows[t]["Dsro_ReservationBackTime"].ToString().Trim()).ToString("yyyy-MM-dd"); dgvr.Cells.Add(cell); cell = new DataGridViewTextBoxCell(); cell.Value = dt.Rows[t]["Dsro_Remark"].ToString().Trim(); dgvr.Cells.Add(cell); LYFZ.BLL.BLL_ErpUser UserBll = new BLL.BLL_ErpUser(); cell = new DataGridViewTextBoxCell(); cell.Value = UserBll.GetUserName(dt.Rows[t]["Dsro_CreateName"].ToString().Trim()); dgvr.Cells.Add(cell); cell = new DataGridViewTextBoxCell(); cell.Value = Convert.ToDateTime(dt.Rows[t]["Dsro_CreateDateTime"].ToString().Trim()).ToString("yyyy-MM-dd"); dgvr.Cells.Add(cell); this.dgv.Rows.Add(dgvr); dgv.ClearSelection(); #endregion } })); } #region 单元格变色 //for (int i = 0; i < dgv.Rows.Count; i++) //{ // string Dsro_Number = dgv.Rows[i].Cells["Dsro_Number"].Value.ToString(); // LYFZ.BLL.BLL_ErpDressSaleRentalDetail DressSaleRentalDetailBll = new BLL.BLL_ErpDressSaleRentalDetail(); // dt = new DataTable(); // dt = DressSaleRentalDetailBll.GetList("Dsrd_Number='" + Dsro_Number + "' and Dsrd_BackStatus='3'").Tables[0]; // if (dt.Rows.Count > 0) // { // this.dgv.Rows[i].DefaultCellStyle.ForeColor = Color.Red; // } // else { this.dgv.Rows[i].DefaultCellStyle.ForeColor = Color.Blue; } //} #endregion }); try { this.ucPagerEx1.TbDataSource = dt; } catch { } return pageData.TotalCount; } #endregion } }