using System; using System.Collections; 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 FrmPayment : LYFZ.Software.UI.Dresses.DressManagement.Rental.FrmPayment { LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder(); LYFZ.BLL.BLL_ErpPayment paybll = new BLL.BLL_ErpPayment(); LYFZ.BLL.BLL_ErpDressSaleRentalOrder dsrobll = new BLL.BLL_ErpDressSaleRentalOrder(); LYFZ.BLL.BLL_ErpDressDepositReceivables ddrbll = new BLL.BLL_ErpDressDepositReceivables(); public FrmPayment() { } /// /// 订单号 /// public string StrOrderNumber; /// /// 是否保存 /// public bool IsSaveed = false; /// /// 登录者姓名 /// string StrUserName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_Name; /// /// 登录者ID /// string StrUserID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID; /// /// 订单类型 /// string OrderType; public string guid = ""; LYFZ.BLL.MemberCardPaymentModel modelpm = null; /// /// 窗体加载事件 /// /// /// protected override void FrmPayment_Shown(object sender, EventArgs e) { LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.HidePhoneControls(this.txtTsorder_Telephone); this.btnDelete.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.DressManagement, CustomAttributes.OperatingAuthority.Delete); DataTable dt = orbll.GetView_Custom("BView_DressOrderReport", StrWhere: "订单号 = '" + this.StrOrderNumber + "'", ShowColumnName: "*").Tables[0]; if (dt.Rows.Count > 0) { this.txtCope.Text = dt.Rows[0]["应付金额"].ToString().Trim(); this.txtPaid.Text = dt.Rows[0]["已付金额"].ToString().Trim(); this.txtArrears.Text = dt.Rows[0]["欠款金额"].ToString().Trim(); this.txtDsro_MortgageAmount.Text = (Convert.ToDecimal(dt.Rows[0]["应收押金"]) - Convert.ToDecimal(dt.Rows[0]["已收押金"])).ToString(); this.txtTsorder_Number.Text = this.StrOrderNumber; this.txtTsorder_CustomerName.Text = dt.Rows[0]["客户姓名"].ToString().Trim(); this.txtTsorder_Telephone.Text = dt.Rows[0]["客户电话"].ToString().Trim(); this.OrderType = dt.Rows[0]["订单类型"].ToString().Trim(); if (this.OrderType == "出售") { this.txtTsorder_Name.Text = "礼服出售"; this.lblDsro_MortgageAmount.Visible = false; this.txtDsro_MortgageAmount.Visible = false; this.lblType.Visible = false; this.cmbType.Visible = false; } else { this.txtTsorder_Name.Text = "礼服出租"; } // 获取收款详情 this.txtPay_ThePayee.Text = this.StrUserName; this.txtPay_CreateDatetime.Text = SDateTime.Now.ToString("yyyy-MM-dd"); } LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_PaymentMethod(this.cmbPay_PaymentMethod, StrWhere: " "); this.cmbPay_PaymentMethod.ComboBoxTree_NodeMouseClick += CmbPay_PaymentMethod_ComboBoxTree_NodeMouseClick; this.PublicFunctionRows(); } private void CmbPay_PaymentMethod_ComboBoxTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { if (cmbType.Text != "押金") { guid = Guid.NewGuid().ToString().Replace("-", "").ToUpper(); if (this.cmbPay_PaymentMethod.Text != "") { if (this.cmbPay_PaymentMethod.Tag.ToString() == "BEBACCAFEGECFBJFD") { if (!string.IsNullOrEmpty(this.txtPay_AmountOf.Text)) { LYFZ.Software.MainBusiness.DoorCityProcess.SuperSmallForm.MemberCardDeductAmountSuperSmallForm frm = new DoorCityProcess.SuperSmallForm.MemberCardDeductAmountSuperSmallForm(); frm.strOrdNumber = StrOrderNumber;//订单编号 frm.PaymentAmount = Convert.ToDecimal(txtPay_AmountOf.Text);//支付金额 frm.StrReturnType = "clist"; frm.ShowDialog(); if (frm.IsSaveed) { modelpm = frm.model; this.btnSave_Click(this, null); } else { this.cmbPay_PaymentMethod.SetTextAndTag_ValueNull(); } } else { this.cmbPay_PaymentMethod.SetTextAndTag_ValueNull(); MessageBoxCustom.Show("请输入金额!"); } } else { modelpm = null; } } } else if (this.cmbPay_PaymentMethod.Tag.ToString() == "BEBACCAFEGECFBJFD") { this.cmbPay_PaymentMethod.SetTextAndTag_ValueNull(); MessageBoxCustom.Show("押金不能通过储值卡扣款支付!"); } } /// /// 全部历史收款 /// public void PublicFunctionRows() { this.dgv.Rows.Clear(); string StrTableName = "(select tb_ErpPayment.ID," + "Pay_OrdNumber AS 订单号," + "(case when Dsro_Type = '0' then '租金' else '出售' end) AS 收款类型," + "Pay_AmountOf AS 收款金额," + "Pay_ReceivableProject AS 收款项目," + "dbo.fn_CheckDateTime(Pay_CreateDatetime) AS 收款时间," + "tb_OrderPerson.User_Name AS 接单人," + "tb_Payee.User_Name AS 收款人," + "(case when Sc_ClassName is null then Pay_PaymentMethod else Sc_ClassName end) AS 付款方式," + "Pay_Remark AS 收款备注 " + "FROM tb_ErpPayment " + "Left Join tb_ErpUser AS tb_Payee on tb_Payee.User_EmployeeID = Pay_ThePayee " + "Left Join tb_ErpUser AS tb_OrderPerson on tb_OrderPerson.User_EmployeeID = Pay_OpenSingle " + "Left Join tb_ErpSystemCategory on Sc_ClassCode = Pay_PaymentMethod " + "Left Join tb_ErpDressSaleRentalOrder on Pay_OrdNumber = Dsro_Number " + "UNION ALL " + "select tb_ErpDressDepositReceivables.ID," + "DDR_Number AS 订单号," + "'押金' AS 收款类型," + "DDR_Money AS 收款金额," + "DDR_ProjectTitle AS 收款项目," + "dbo.fn_CheckDateTime(DRR_CreateDatetime) AS 收款时间," + "User_Name AS 接单人," + "User_Name AS 收款人," + "(case when Sc_ClassName is null then DDR_Payments else Sc_ClassName end) AS 付款方式," + "DRR_Remark AS 收款备注 " + "from tb_ErpDressDepositReceivables " + "Left Join tb_ErpUser on User_EmployeeID = DRR_CreateName " + "Left Join tb_ErpSystemCategory on Sc_ClassCode = DDR_Payments) AS tb"; DataTable dt = orbll.GetView_Custom(StrTableName, StrWhere: "订单号 = '" + this.StrOrderNumber + "'", ShowColumnName: "ID,收款类型,收款金额,收款项目,收款时间,接单人,收款人,付款方式,收款备注").Tables[0]; for (int i = 0; i < dt.Rows.Count; i++) { DataGridViewRow dgvr = new DataGridViewRow(); DataGridViewCell cell = null; for (int j = 0; j < dt.Columns.Count; j++) { cell = new DataGridViewTextBoxCell(); cell.Value = dt.Rows[i][j].ToString(); dgvr.Cells.Add(cell); } this.dgv.Rows.Add(dgvr); } this.dgv.ClearSelection(); } /// /// 时间控件 /// /// /// protected override void txtPay_CreateDatetime_Enter(object sender, EventArgs e) { if (this.txtPay_CreateDatetime.Text == "") { this.txtPay_CreateDatetime.Text = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime().ToString("yyyy-MM-dd"); } } /// /// 时间控件 /// /// /// protected override void txtPay_CreateDatetime_Leave(object sender, EventArgs e) { if (this.txtPay_CreateDatetime.Text.Trim() != "") { if (LYFZ.Command.Command_Validate.IsDateTime(this.txtPay_CreateDatetime.Text.Trim()) == false) { this.txtPay_CreateDatetime.Text = ""; MessageBoxCustom.Show("收款时间格式输入错误"); } } } /// /// 输入框设置 /// /// /// protected override void txtPay_AmountOf_KeyPress(object sender, KeyPressEventArgs e) { if (!Char.IsNumber(e.KeyChar) && !Char.IsPunctuation(e.KeyChar) && !Char.IsControl(e.KeyChar)) { e.Handled = true; } else if (Char.IsPunctuation(e.KeyChar)) { if (e.KeyChar == '.') { if (((System.Windows.Forms.TextBox)sender).Text.LastIndexOf('.') != -1) { e.Handled = true; } } else if (e.KeyChar == '-') { if (txtPay_AmountOf.Text != "") { e.Handled = true; } } else { e.Handled = true; } } } /// /// 支付方式设置 /// /// /// protected override void btnSet_Click(object sender, EventArgs e) { LYFZ.Software.MainBusiness.InitialSet.FrmSystemSet set = new InitialSet.FrmSystemSet(); set.TypeName = "BEBACCAFCCEAGAIHH"; set.Version = "Version"; if (set.ShowDialog() == DialogResult.OK) { LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_PaymentMethod(this.cmbPay_PaymentMethod, StrWhere: "Sc_ClassCode!='BEBACCAFEGECFBJFD'"); } } /// /// 修改时间 /// /// /// protected override void btnUpdateTime_Click(object sender, EventArgs e) { if (LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.DressManagement, CustomAttributes.OperatingAuthority.UpdatePaymentTime)) { this.txtPay_CreateDatetime.Enabled = true; } else { LYFZ.Software.MainBusiness.DoorCityProcess.SuperSmallForm.AuthorizeLoginSuperSmallForm frm = new DoorCityProcess.SuperSmallForm.AuthorizeLoginSuperSmallForm("DressManagement", CustomAttributes.OperatingAuthority.UpdatePaymentTime); if (frm.ShowDialog() == DialogResult.OK) { if (LYFZ.BLL.BLL_ErpUser.GetRights(frm.CurrentAuthorizeUserRights.DressManagement, CustomAttributes.OperatingAuthority.UpdatePaymentTime, frm.User_BelongRoles)) { frm.SetAuthorizationResult(); this.txtPay_CreateDatetime.Enabled = true; } else { frm.SetAuthorizationResult(String.Format("授权失败,授权人没有'{0}'权限", LYFZ.Software.MainBusiness.DoorCityProcess.SuperSmallForm.AuthorizeLoginSuperSmallForm.ConvertEnumToDescription(CustomAttributes.OperatingAuthority.UpdatePaymentTime).ToString())); } } } } /// /// 保存 /// /// /// protected override void btnSave_Click(object sender, EventArgs e) { try { #region 判断不能为空 if (string.IsNullOrEmpty(this.txtTsorder_Number.Text.Trim())) { MessageBoxCustom.Show("订单单号不能为空!"); return; } if (this.OrderType != "出售") { if (string.IsNullOrEmpty(this.cmbType.Text.Trim())) { MessageBoxCustom.Show("收款类型不能为空!"); return; } } if (string.IsNullOrEmpty(this.txtPay_AmountOf.Text.Trim())) { MessageBoxCustom.Show("收款" + this.cmbType.Text.Trim() + "不能为空!"); return; } //if (Convert.ToDecimal(this.txtPay_AmountOf.Text.Trim()) == 0) //{ MessageBoxCustom.Show("收款" + this.cmbType.Text.Trim() + "不能为0!"); return; } if (string.IsNullOrEmpty(this.cmbPay_PaymentMethod.Text.Trim())) { MessageBoxCustom.Show("支付方式不能为空!"); return; } if (string.IsNullOrEmpty(this.txtPay_ThePayee.Text.Trim())) { MessageBoxCustom.Show("收款人不能为空!"); return; } if (string.IsNullOrEmpty(this.txtPay_CreateDatetime.DateValue.Trim())) { MessageBoxCustom.Show("收款时间不能为空!"); return; } #endregion #region 2017-03-24 杨云奕 添加 判断是否接入微信支付宝的接口 LYFZ.Software.MainBusiness.FinancialManagement.FinancialPayApiControl PayApi = new LYFZ.Software.MainBusiness.FinancialManagement.FinancialPayApiControl(); int intCode = PayApi.PayApiControl(this.txtTsorder_Number.Text, this.cmbPay_PaymentMethod.Text.Trim(), Convert.ToDecimal(this.txtPay_AmountOf.Text)); string serialnumber = ""; if (intCode == 1) { serialnumber = PayApi.SerialNumber; } else if (intCode == -1) { //MessageBoxCustom.Show("取消微信刷卡支付,保存取消"); return; } #endregion #region 保存 List clist = new List(); bool IsFind = false; if (this.OrderType != "出售") { if (this.cmbType.Text == "押金") { IsFind = true; LYFZ.Model.Model_ErpDressDepositReceivables modelDeposit = new Model.Model_ErpDressDepositReceivables(); modelDeposit.DDR_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID(); modelDeposit.DDR_Money = Convert.ToDecimal(txtPay_AmountOf.Text.ToString()); modelDeposit.DDR_DepositAmountAudit = ""; modelDeposit.DDR_DepositAmountAuditName = ""; modelDeposit.DDR_DepositAmountAuditRemark = ""; modelDeposit.DDR_Number = this.txtTsorder_Number.Text; modelDeposit.DDR_PaymentMethod = this.cmbPay_PaymentMethod.Tag.ToString().Trim(); modelDeposit.DDR_Payments = this.cmbPay_PaymentMethod.Text.ToString(); modelDeposit.DDR_ProjectTitle = this.txtTsorder_Name.Text; modelDeposit.DRR_Remark = this.txtPay_Remark.Text; modelDeposit.DRR_CreateDatetime = Convert.ToDateTime(this.txtPay_CreateDatetime.DateTimeValue.Trim()); modelDeposit.DRR_CreateName = this.StrUserID; clist.Add(ddrbll.GetAddCommandInfo(modelDeposit)); MessageBoxCustom.Show("保存成功!"); } } if (!IsFind) { DataTable dt = orbll.GetView_Custom("tb_ErpDressSaleRentalOrder", StrWhere: "Dsro_Number='" + this.StrOrderNumber + "'", ShowColumnName: "Dsro_CreateName").Tables[0]; LYFZ.Model.Model_ErpPayment model = new Model.Model_ErpPayment(); model.pay_SerialNumber = serialnumber; model.Pay_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID(); model.Pay_OrdNumber = this.txtTsorder_Number.Text.Trim(); model.Pay_ViceNumber = ""; model.Pay_AmountOf = Convert.ToDecimal(this.txtPay_AmountOf.Text); model.Pay_OpenSingle = dt.Rows[0]["Dsro_CreateName"].ToString(); model.Pay_ThePayee = this.StrUserID; model.Pay_PaymentMethod = this.cmbPay_PaymentMethod.Tag.ToString(); model.Pay_OrdersLocation = ""; model.Pay_ReceivableProject = this.txtTsorder_Name.Text; model.Pay_Remark = this.txtPay_Remark.Text; model.Pay_CreateDatetime = Convert.ToDateTime(this.txtPay_CreateDatetime.DateTimeValue.Trim()); model.Pay_Category = "后期收款"; if (modelpm == null) { modelpm = new BLL.MemberCardPaymentModel(); modelpm.PaymentAmount = Convert.ToDecimal(this.txtPay_AmountOf.Text); modelpm.RechargeDiscount = 0; modelpm.DiscountAmount = 0; modelpm.StrOrdNumber = this.StrOrderNumber; modelpm.StrPaymentMethod = "其他"; modelpm.StrReturnType = "clist"; } //if (modelpm.RechargeDiscount>0) //{ // model.Pay_AmountOf = model.Pay_AmountOf * modelpm.RechargeDiscount; //} //if (modelpm.PaymentAmount != model.Pay_AmountOf) //{ // MessageBoxCustom.Show("储值卡扣款金额:“" + modelpm.PaymentAmount + "”和订单收款金额:“" + model.Pay_AmountOf + "”不一致,请重新收款!"); // cmbPay_PaymentMethod.Text = ""; // return; //} model.Pay_PaymentDiscount = modelpm.RechargeDiscount; model.Pay_DiscountAmount = modelpm.DiscountAmount; model.Pay_McNumber = modelpm.StrCardNumber; model.Pay_Type = 2; clist.Add(paybll.GetAddCommandInfo(model)); } if (clist.Count > 0) { if (LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist) > 0) { if (!IsFind) { #region 获取金额 //应收款 this.txtCope.Text = Convert.ToDecimal(this.txtCope.Text).ToString(); //已付款 decimal Paid = 0; DataTable DaPayment = paybll.GetSum(" Pay_OrdNumber='" + StrOrderNumber + "'").Tables[0]; if (!string.IsNullOrEmpty(DaPayment.Rows[0]["Pay_AmountOf"].ToString())) { Paid = Convert.ToDecimal(DaPayment.Rows[0]["Pay_AmountOf"]); } this.txtPaid.Text = Paid.ToString(); //欠款 this.txtArrears.Text = (Convert.ToDecimal(this.txtCope.Text) - Convert.ToDecimal(Paid)).ToString(); if (this.cmbType.Text == "押金") { this.txtDsro_MortgageAmount.Text = (Convert.ToDecimal(this.txtDsro_MortgageAmount.Text) - Convert.ToDecimal(this.txtPay_AmountOf.Text)).ToString(); } #endregion } MessageBoxCustom.Show("保存成功!"); this.txtPay_AmountOf.Text = ""; this.cmbPay_PaymentMethod.Text = ""; this.txtPay_Remark.Text = ""; this.IsSaveed = true; this.txtPay_CreateDatetime.Enabled = false; this.cmbType.Text = ""; this.PublicFunctionRows(); } else { MessageBoxCustom.Show("保存失败!"); } } #endregion } catch (Exception ex) { MessageBoxCustom.Show(ex.Message); } } /// /// 删除 /// /// /// protected override void btnDelete_Click(object sender, EventArgs e) { try { if (this.dgv.SelectedRows.Count == 0) { MessageBoxCustom.Show("请选中你要删除的数据!"); return; } if (MessageBoxCustom.Show("你确定要删除吗?", "删除提示", MessageBoxButtons.YesNo) == DialogResult.Yes) { bool IsDelete = false; int StrID = Convert.ToInt32(this.dgv.CurrentRow.Cells["ID"].Value); if (this.dgv.CurrentRow.Cells["type"].Value.ToString() == "押金") { DataTable dt = ddrbll.GetList("ID=" + StrID + "").Tables[0]; if (dt.Rows.Count > 0) { if (dt.Rows[0]["DDR_DepositAmountAudit"].ToString().Trim() == "已审核") { MessageBoxCustom.Show("收款已审核,不能删除!"); return; } } IsDelete = ddrbll.Delete(StrID); } else { DataTable dt = paybll.GetList("ID=" + StrID + "").Tables[0]; if (dt.Rows.Count > 0) { if (dt.Rows[0]["Pay_FinancialAudit"].ToString().Trim() == "已审核") { MessageBoxCustom.Show("收款已审核,不能删除!"); return; } } IsDelete = paybll.Delete(StrID); } if (IsDelete) { #region 写入操作日志 string logsContent = "删除订单号:" + StrOrderNumber; LYFZ.BLL.BLL_ErpSystemLogs.WriteSystemLog(LYFZ.EnumPublic.SystemLogsType.删除收款记录, logsContent, LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID, LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name); #endregion MessageBoxCustom.Show("删除成功!"); #region 获取金额 //应收款 this.txtCope.Text = Convert.ToDecimal(this.txtCope.Text).ToString(); //已付款 decimal Paid = 0; DataTable DaPayment = paybll.GetSum(" Pay_OrdNumber='" + StrOrderNumber + "'").Tables[0]; if (!string.IsNullOrEmpty(DaPayment.Rows[0]["Pay_AmountOf"].ToString())) { Paid = Convert.ToDecimal(DaPayment.Rows[0]["Pay_AmountOf"]); } this.txtPaid.Text = Paid.ToString(); //欠款 this.txtArrears.Text = (Convert.ToDecimal(this.txtCope.Text) - Convert.ToDecimal(Paid)).ToString(); #endregion this.PublicFunctionRows(); this.IsSaveed = true; } } } catch (Exception ex) { MessageBoxCustom.Show(ex.Message); } } /// /// 打印收据 /// /// /// protected override void btnHitSingle_Click(object sender, EventArgs e) { try { if (this.dgv.SelectedRows.Count == 0) { MessageBoxCustom.Show("请选择你要打印的数据!"); return; } Hashtable htData = new Hashtable(); htData["dgvData"] = this.dgv; htData["ordNumber"] = this.txtTsorder_Number.Text.Trim(); htData["CustomerName"] = this.txtTsorder_CustomerName.Text.Trim(); htData["Telephone"] = this.txtTsorder_Telephone.Text.Trim(); htData["StrCope"] = this.txtCope.Text.Trim(); htData["StrArrears"] = this.txtArrears.Text.Trim(); if (this.txtDsro_MortgageAmount.Visible) { htData["StrDetain"] = this.txtDsro_MortgageAmount.Text.Trim(); LYFZ.Software.MainBusiness.ReportPrint.ReportFixedFormat.PrintFixedFormat(LYFZ.EnumPublic.PrintTypeEnum.礼服出租收款, htData); } else { LYFZ.Software.MainBusiness.ReportPrint.ReportFixedFormat.PrintFixedFormat(LYFZ.EnumPublic.PrintTypeEnum.礼服出售收款, htData); } } catch (Exception ex) { MessageBoxCustom.Show(ex.Message); } } /// /// 选择收款类别 /// /// /// protected override void cmbType_SelectedValueChanged(object sender, EventArgs e) { if (!string.IsNullOrEmpty(this.cmbType.Text)) { if (this.cmbType.Text == "押金") { this.txtPay_AmountOf.Text = this.txtDsro_MortgageAmount.Text.Trim(); this.txtPay_AmountOf.ReadOnly = true; } else { this.txtPay_AmountOf.ReadOnly = false; this.txtPay_AmountOf.Text = txtArrears.Text.Trim(); } } else { this.txtPay_AmountOf.ReadOnly = false; this.txtPay_AmountOf.Text = ""; } } } }