FrmTwoSalesOrderPayment.cs 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644
  1. using LYFZ.ComponentLibrary;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using System.ComponentModel;
  6. using System.Data;
  7. using System.Drawing;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Windows.Forms;
  11. namespace LYFZ.Software.MainBusiness.FinancialManagement.TwoSalesOrder
  12. {
  13. public partial class FrmTwoSalesOrderPayment : LYFZ.Software.UI.FinancialManagement.TwoSalesOrder.FrmTwoSalesOrderPayment
  14. {
  15. LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
  16. LYFZ.BLL.BLL_ErpPayment ptbll = new BLL.BLL_ErpPayment();
  17. LYFZ.BLL.BLL_ErpSystemLogs slogbll = new BLL.BLL_ErpSystemLogs();
  18. LYFZ.BLL.BLL_ErpTwoSalesOrder torbll = new BLL.BLL_ErpTwoSalesOrder();
  19. LYFZ.BLL.BLL_ErpTwoPinsProjectCommissionProportion tppcpbll = new BLL.BLL_ErpTwoPinsProjectCommissionProportion();
  20. public FrmTwoSalesOrderPayment()
  21. {
  22. this.cmbPay_PaymentMethod.ComboBoxTree_NodeMouseClick += cmbPay_PaymentMethod_ComboBoxTree_NodeMouseClick;
  23. this.btnPaymentNot.Click += btnPaymentNot_Click;
  24. this.btnPerformance.Click += BtnPerformance_Click;
  25. this.btnDelPerformance.Click += BtnDelPerformance_Click;
  26. this.dgv.CellDoubleClick += Dgv2_CellDoubleClick;
  27. }
  28. private void Dgv2_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  29. {
  30. if (e.RowIndex >= 0 && e.ColumnIndex >= 0)
  31. {
  32. if (e.ColumnIndex == 4)
  33. {
  34. DataGridViewRow gridViewRow = this.dgv.Rows[e.RowIndex];
  35. if (gridViewRow.Tag != null)
  36. {
  37. DataRow dataRow = (DataRow)gridViewRow.Tag;
  38. decimal Pay_AmountOf = Convert.ToDecimal(dataRow["Pay_AmountOf"].ToString());
  39. string commissionRatioJsonData = "";
  40. if (dataRow["Pay_CommissionRatio"] != null)
  41. {
  42. commissionRatioJsonData = dataRow["Pay_CommissionRatio"].ToString();
  43. }
  44. if (String.IsNullOrWhiteSpace(commissionRatioJsonData))
  45. {
  46. MessageBoxCustom.Show("当前这笔收款项未做自定义业绩分配");
  47. return;
  48. }
  49. else
  50. {
  51. LYFZ.Software.MainBusiness.DoorCityProcess.frmCustomPerformance customPerformance = new MainBusiness.DoorCityProcess.frmCustomPerformance();
  52. try
  53. {
  54. customPerformance.CollectionAmount = Pay_AmountOf;
  55. customPerformance.IsReadOnly = true;
  56. customPerformance.PersonCommissionRatioJsonDataInitialization(commissionRatioJsonData);
  57. customPerformance.BindPerformancePersonControls();
  58. customPerformance.ShowDialog();
  59. }
  60. catch (Exception ex)
  61. {
  62. MessageBoxCustom.Show(String.Format("收款金额输入格式不正确:{0}", ex.Message));
  63. return;
  64. }
  65. }
  66. }
  67. else
  68. {
  69. MessageBoxCustom.Show("当前收款记录异常");
  70. return;
  71. }
  72. }
  73. }
  74. }
  75. private void BtnDelPerformance_Click(object sender, EventArgs e)
  76. {
  77. this.ClearPerformance();
  78. }
  79. /// <summary>
  80. /// 清除业绩分配
  81. /// </summary>
  82. void ClearPerformance()
  83. {
  84. this.listBoxPerformance.Items.Clear();
  85. this.listBoxPerformance.Tag = null;
  86. this.currentPersonCommissionRatio = null;
  87. }
  88. LYFZ.BLL.OrderPersonCommissionRatio currentPersonCommissionRatio = null;
  89. LYFZ.Model.Model_ErpTwoSalesOrder erpOrderModel = null;
  90. private void BtnPerformance_Click(object sender, EventArgs e)
  91. {
  92. if (this.erpOrderModel != null)
  93. {
  94. LYFZ.Software.MainBusiness.DoorCityProcess.frmCustomPerformance customPerformance = new MainBusiness.DoorCityProcess.frmCustomPerformance();
  95. try
  96. {
  97. customPerformance.CollectionAmount = Convert.ToDecimal(this.txtPay_AmountOf.Text.Trim());
  98. if (this.listBoxPerformance.Items.Count > 0 && this.currentPersonCommissionRatio != null)
  99. {
  100. customPerformance.PersonCommissionRatio = this.currentPersonCommissionRatio;
  101. }
  102. else
  103. {
  104. customPerformance.OrderPersonInitialization(this.erpOrderModel.Tsorder_OpenSingle);
  105. }
  106. customPerformance.BindPerformancePersonControls();
  107. if (customPerformance.ShowDialog() == DialogResult.OK)
  108. {
  109. this.listBoxPerformance.Items.Clear();
  110. this.currentPersonCommissionRatio = customPerformance.PersonCommissionRatio;
  111. customPerformance.BindListBoxPerformance(this.listBoxPerformance);
  112. }
  113. }
  114. catch (Exception ex)
  115. {
  116. MessageBoxCustom.Show(String.Format("收款金额输入格式不正确:{0}", ex.Message));
  117. }
  118. }
  119. }
  120. /// <summary>
  121. /// 是否保存
  122. /// </summary>
  123. public bool IsSaveed = false;
  124. /// <summary>
  125. /// 应收款
  126. /// </summary>
  127. public decimal StrCope;
  128. /// <summary>
  129. /// 已收款
  130. /// </summary>
  131. public decimal StrPaid;
  132. /// <summary>
  133. /// 欠款
  134. /// </summary>
  135. public decimal StrArrears;
  136. /// <summary>
  137. /// 订单号
  138. /// </summary>
  139. public string StrOrdNumber;
  140. /// <summary>
  141. /// 客户编号
  142. /// </summary>
  143. public string StrClientNumber;
  144. /// <summary>
  145. /// 是否显示不收款按钮
  146. /// </summary>
  147. public bool IsShownPaymentNot = false;
  148. string Tsorder_Category = "";
  149. public string guid = "";
  150. /// <summary>
  151. /// 窗体加载事件
  152. /// </summary>
  153. /// <param name="sender"></param>
  154. /// <param name="e"></param>
  155. protected override void FrmTwoSalesOrderPayment_Shown(object sender, EventArgs e)
  156. {
  157. try
  158. {
  159. this.btnPaymentNot.Visible = this.IsShownPaymentNot;
  160. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.HidePhoneControls(this.txtTsorder_Telephone);
  161. this.btnDelete.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.TwoSalesOrderCompetence, CustomAttributes.OperatingAuthority.Delete);
  162. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_PaymentMethod(this.cmbPay_PaymentMethod);
  163. // 获取 金额,客户,收款详情数据
  164. if (!string.IsNullOrEmpty(this.StrOrdNumber))
  165. {
  166. DataTable dt = torbll.GetView_TwoSalesOrder(" Tsorder_Number = '" + this.StrOrdNumber + "'").Tables[0];
  167. if (dt.Rows.Count > 0)
  168. {
  169. this.erpOrderModel = torbll.DataRowToModel(dt.Rows[0]);
  170. // 获取金额
  171. this.txtCope.Text = StrCope.ToString();//应收款
  172. this.txtPaid.Text = StrPaid.ToString();//已付款
  173. this.txtArrears.Text = StrArrears.ToString();//欠款
  174. // 获取客户资料
  175. this.txtTsorder_Number.Text = dt.Rows[0]["Tsorder_Number"].ToString(); ;
  176. this.txtTsorder_Name.Text = dt.Rows[0]["Tsorder_Name"].ToString();
  177. this.txtTsorder_CustomerName.Text = dt.Rows[0]["Tsorder_CustomerName"].ToString();
  178. this.txtTsorder_Telephone.Text = dt.Rows[0]["Tsorder_Telephone"].ToString();
  179. this.StrClientNumber = dt.Rows[0]["Tsorder_CustomerNumber"].ToString();
  180. // 获取收款详情
  181. this.txtPay_ThePayee.Text = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_Name;
  182. this.txtPay_CreateDatetime.Text = SDateTime.Now.ToString("yyyy-MM-dd");
  183. this.Tsorder_Category = dt.Rows[0]["Tsorder_Category"].ToString();
  184. }
  185. else {
  186. erpOrderModel = null;
  187. MessageBoxCustom.Show("订单数据加载失败,或订单已被删除");
  188. }
  189. }
  190. else
  191. {
  192. MessageBoxCustom.Show("缺少收款订单号参数");
  193. return;
  194. }
  195. // 获取全部历史收款
  196. this.PublicFunctionRows();
  197. ///控制财务管理扫码支付的版本权
  198. List<Control> hideControl = new List<Control>();
  199. hideControl.Add(cmbPay_PaymentMethod);
  200. LYFZ.Software.MainBusiness.VersionControl.StaticVersion.BindVersionShowHideControl(VersionControl.VersionFunctionEnum.财务管理扫码支付, hideControl, null, null);
  201. }
  202. catch (Exception ex)
  203. { MessageBoxCustom.Show(ex.Message); }
  204. }
  205. /// <summary>
  206. /// 全部历史收款
  207. /// </summary>
  208. void PublicFunctionRows()
  209. {
  210. this.dgv.Rows.Clear();
  211. DataTable dt = ptbll.View_ErpPayment("Pay_OrdNumber='" + this.StrOrdNumber + "'").Tables[0];
  212. if (dt.Rows.Count > 0)
  213. {
  214. for (int t = 0; t < dt.Rows.Count; t++)
  215. {
  216. DataGridViewRow dgvr = new DataGridViewRow();
  217. DataGridViewCell cell = null;
  218. cell = new DataGridViewTextBoxCell();
  219. cell.Value = dt.Rows[t]["ID"].ToString();
  220. dgvr.Cells.Add(cell);
  221. cell = new DataGridViewTextBoxCell();
  222. cell.Value = Convert.ToDecimal(dt.Rows[t]["Pay_AmountOf"]).ToString("N2");
  223. dgvr.Cells.Add(cell);
  224. cell = new DataGridViewTextBoxCell();
  225. cell.Value = dt.Rows[t]["Pay_ReceivableProject"].ToString().Trim();
  226. dgvr.Cells.Add(cell);
  227. cell = new DataGridViewTextBoxCell();
  228. cell.Value = LYFZ.Command.Command_Validate.DateTimeToString(dt.Rows[t]["Pay_CreateDatetime"], "yyyy-MM-dd HH:mm");
  229. dgvr.Cells.Add(cell);
  230. cell = new DataGridViewTextBoxCell();
  231. cell.Value = dt.Rows[t]["Pay_UserName"].ToString().Trim();
  232. dgvr.Cells.Add(cell);
  233. cell = new DataGridViewTextBoxCell();
  234. cell.Value = dt.Rows[t]["Pay_ThePayeeName"].ToString().Trim();
  235. dgvr.Cells.Add(cell);
  236. cell = new DataGridViewTextBoxCell();
  237. cell.Value = dt.Rows[t]["Pay_PaymentMethodName"].ToString().Trim(); ;
  238. dgvr.Cells.Add(cell);
  239. cell = new DataGridViewTextBoxCell();
  240. cell.Value = dt.Rows[t]["Pay_PaymentDiscount"].ToString().Trim(); ;
  241. dgvr.Cells.Add(cell);
  242. cell = new DataGridViewTextBoxCell();
  243. cell.Value = dt.Rows[t]["Pay_DiscountAmount"].ToString().Trim(); ;
  244. dgvr.Cells.Add(cell);
  245. cell = new DataGridViewTextBoxCell();
  246. cell.Value = dt.Rows[t]["Pay_Remark"].ToString().Trim();
  247. dgvr.Cells.Add(cell);
  248. dgvr.Tag = dt.Rows[t];
  249. this.dgv.Rows.Add(dgvr);
  250. }
  251. this.dgv.ClearSelection();
  252. }
  253. }
  254. /// <summary>
  255. /// 时间控件
  256. /// </summary>
  257. /// <param name="sender"></param>
  258. /// <param name="e"></param>
  259. protected override void txtPay_CreateDatetime_Enter(object sender, EventArgs e)
  260. {
  261. if (this.txtPay_CreateDatetime.Text == "")
  262. { this.txtPay_CreateDatetime.Text = SDateTime.Now.ToString("yyyy-MM-dd"); }
  263. }
  264. /// <summary>
  265. /// 时间控件
  266. /// </summary>
  267. /// <param name="sender"></param>
  268. /// <param name="e"></param>
  269. protected override void txtPay_CreateDatetime_Leave(object sender, EventArgs e)
  270. {
  271. if (this.txtPay_CreateDatetime.Text.Trim() != "")
  272. {
  273. if (LYFZ.Command.Command_Validate.IsDateTime(this.txtPay_CreateDatetime.Text.Trim()) == false)
  274. { this.txtPay_CreateDatetime.Text = ""; MessageBoxCustom.Show("收款时间格式输入错误"); }
  275. }
  276. }
  277. /// <summary>
  278. /// 输入框设置
  279. /// </summary>
  280. /// <param name="sender"></param>
  281. /// <param name="e"></param>
  282. protected override void txtPay_AmountOf_KeyPress(object sender, KeyPressEventArgs e)
  283. {
  284. if (!Char.IsNumber(e.KeyChar) && !Char.IsPunctuation(e.KeyChar) && !Char.IsControl(e.KeyChar))
  285. { e.Handled = true; }
  286. else if (Char.IsPunctuation(e.KeyChar))
  287. {
  288. if (e.KeyChar == '.')
  289. {
  290. if (((System.Windows.Forms.TextBox)sender).Text.LastIndexOf('.') != -1)
  291. { e.Handled = true; }
  292. }
  293. else if (e.KeyChar == '-')
  294. {
  295. if (((System.Windows.Forms.TextBox)sender).Text.LastIndexOf('-') != -1)
  296. { e.Handled = true; }
  297. }
  298. else
  299. { e.Handled = true; }
  300. }
  301. }
  302. /// <summary>
  303. /// 支付方式设置
  304. /// </summary>
  305. /// <param name="sender"></param>
  306. /// <param name="e"></param>
  307. protected override void btnSet_Click(object sender, EventArgs e)
  308. {
  309. LYFZ.Software.MainBusiness.InitialSet.FrmSystemSet frm = new InitialSet.FrmSystemSet();
  310. frm.TypeName = "BEBACCAFCCEAGAIHH";
  311. frm.Version = "Version";
  312. if (frm.ShowDialog() == DialogResult.OK)
  313. {
  314. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_PaymentMethod(this.cmbPay_PaymentMethod);
  315. }
  316. }
  317. /// <summary>
  318. /// 删除
  319. /// </summary>
  320. /// <param name="sender"></param>
  321. /// <param name="e"></param>
  322. protected override void btnDelete_Click(object sender, EventArgs e)
  323. {
  324. try
  325. {
  326. if (this.dgv.SelectedRows.Count == 0)
  327. {
  328. MessageBoxCustom.Show("请选中你要删除的数据!");
  329. return;
  330. }
  331. if (MessageBoxCustom.Show("你确定要删除吗?", "删除提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
  332. {
  333. List<Helper.CommandInfo> clist = new List<Helper.CommandInfo>();
  334. int id = Convert.ToInt32(this.dgv.CurrentRow.Cells["ID"].Value);
  335. DataTable dt = ptbll.GetList("Id=" + id + "").Tables[0];
  336. if (dt.Rows.Count > 0)
  337. {
  338. if (dt.Rows[0]["Pay_FinancialAudit"].ToString().Trim() == "已审核")
  339. { MessageBoxCustom.Show("收款已审核,不能删除!"); return; }
  340. clist.Add(ptbll.GetDeleteCommandInfo("ID", "=", id));
  341. // 写入操作日志
  342. string logsContent = "删除其他消费订单号为:" + this.StrOrdNumber + " 金额为:" + this.dgv.CurrentRow.Cells["Pay_AmountOf"].Value.ToString().Trim();
  343. clist.Add(slogbll.GetAddCommandInfo(LYFZ.BLL.BLL_ErpSystemLogs.GetWriteLogModel(LYFZ.EnumPublic.SystemLogsType.删除收款记录, logsContent, LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID, LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name, StrInfoID: LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID())));
  344. // 删除二销(后期)项目提成比例设置
  345. DataTable tbl = orbll.GetView_Custom("tb_ErpTwoPinsProjectCommissionProportion", StrWhere: "Tpc_CustomNumber='" + dt.Rows[0]["Pay_CustomNumber"].ToString().Trim() + "'", ShowColumnName: "ID").Tables[0];
  346. for (int i = 0; i < tbl.Rows.Count; i++)
  347. { clist.Add(tppcpbll.GetDeleteCommandInfo("ID", "=", tbl.Rows[0]["ID"].ToString().Trim())); }
  348. decimal RefundAmount = Convert.ToDecimal(this.dgv.CurrentRow.Cells["Pay_AmountOf"].Value) - Convert.ToDecimal(this.dgv.CurrentRow.Cells["DiscountAmount"].Value);
  349. clist.AddRange(LYFZ.BLL.OrderPayment_Member.LaterPeriodPayment_DeleteRefund(this.StrOrdNumber, dt.Rows[0]["Pay_McNumber"].ToString().Trim(), StrClientNumber, RefundAmount, StrStoreNumber: LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID()));
  350. if (clist.Count > 0)
  351. {
  352. if (LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist) > 0)
  353. {
  354. MessageBoxCustom.Show("删除成功!");
  355. // 获取金额
  356. this.txtCope.Text = StrCope.ToString();//应收款
  357. DataTable DaPayment = ptbll.GetSum(" Pay_OrdNumber='" + this.StrOrdNumber + "'").Tables[0];
  358. decimal Paid = 0;//已付款
  359. if (!string.IsNullOrEmpty(DaPayment.Rows[0]["Pay_AmountOf"].ToString().Trim()))
  360. { Paid = Convert.ToDecimal(DaPayment.Rows[0]["Pay_AmountOf"]); }
  361. this.txtPaid.Text = Paid.ToString();
  362. //欠款
  363. this.txtArrears.Text = (StrCope - Paid).ToString();
  364. this.dgv.Rows.Remove(this.dgv.CurrentRow);
  365. this.IsSaveed = true;
  366. }
  367. else
  368. { MessageBoxCustom.Show("删除失败!"); return; }
  369. }
  370. }
  371. }
  372. }
  373. catch (Exception ex)
  374. { MessageBoxCustom.Show(ex.Message); }
  375. }
  376. /// <summary>
  377. /// 打印收据
  378. /// </summary>
  379. /// <param name="sender"></param>
  380. /// <param name="e"></param>
  381. protected override void btnHitSingle_Click(object sender, EventArgs e)
  382. {
  383. try
  384. {
  385. if (dgv.SelectedRows.Count == 0)
  386. {
  387. MessageBoxCustom.Show("请选择你要打印的数据!");
  388. return;
  389. }
  390. object objStr = this.txtTsorder_Number.Text.Trim() + "|" + this.txtCope.Text.Trim() + "|" + this.txtPaid.Text.Trim() + "|" + this.txtArrears.Text.Trim();
  391. Hashtable htData = new Hashtable();
  392. htData["dgvData"] = this.dgv;
  393. htData["strText"] = objStr;
  394. LYFZ.Software.MainBusiness.ReportPrint.ReportFixedFormat.PrintFixedFormat(LYFZ.EnumPublic.PrintTypeEnum.其它消费收款, htData);
  395. }
  396. catch (Exception ex)
  397. { MessageBoxCustom.Show(ex.Message); }
  398. }
  399. /// <summary>
  400. /// 修改时间
  401. /// </summary>
  402. /// <param name="sender"></param>
  403. /// <param name="e"></param>
  404. protected override void btnUpdateTime_Click(object sender, EventArgs e)
  405. {
  406. if (LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.TwoSalesOrderCompetence, CustomAttributes.OperatingAuthority.UpdatePaymentTime))
  407. { txtPay_CreateDatetime.Enabled = true; }
  408. else
  409. {
  410. LYFZ.Software.MainBusiness.DoorCityProcess.SuperSmallForm.AuthorizeLoginSuperSmallForm frm = new DoorCityProcess.SuperSmallForm.AuthorizeLoginSuperSmallForm("TwoSalesOrderCompetence", CustomAttributes.OperatingAuthority.UpdatePaymentTime);
  411. if (frm.ShowDialog() == DialogResult.OK)
  412. {
  413. if (LYFZ.BLL.BLL_ErpUser.GetRights(frm.CurrentAuthorizeUserRights.TwoSalesOrderCompetence, CustomAttributes.OperatingAuthority.UpdatePaymentTime, frm.User_BelongRoles))
  414. {
  415. frm.SetAuthorizationResult();
  416. txtPay_CreateDatetime.Enabled = true; }
  417. else {
  418. frm.SetAuthorizationResult(String.Format("授权失败,授权人没有'{0}'权限", LYFZ.Software.MainBusiness.DoorCityProcess.SuperSmallForm.AuthorizeLoginSuperSmallForm.ConvertEnumToDescription(CustomAttributes.OperatingAuthority.UpdatePaymentTime).ToString()));
  419. }
  420. }
  421. }
  422. }
  423. /// <summary>
  424. /// 不收款
  425. /// </summary>
  426. /// <param name="sender"></param>
  427. /// <param name="e"></param>
  428. void btnPaymentNot_Click(object sender, EventArgs e)
  429. {
  430. this.Close();
  431. }
  432. /// <summary>
  433. /// 保存
  434. /// </summary>
  435. /// <param name="sender"></param>
  436. /// <param name="e"></param>
  437. protected override void btnSave_Click(object sender, EventArgs e)
  438. {
  439. try
  440. {
  441. #region 判断不能为空
  442. if (string.IsNullOrEmpty(this.txtTsorder_Number.Text))
  443. {
  444. MessageBoxCustom.Show("订单单号不能为空!");
  445. return;
  446. }
  447. if (string.IsNullOrEmpty(this.txtPay_AmountOf.Text))
  448. {
  449. MessageBoxCustom.Show("收款金额不能为空!");
  450. return;
  451. }
  452. if (string.IsNullOrEmpty(this.cmbPay_PaymentMethod.Text))
  453. {
  454. MessageBoxCustom.Show("支付方式不能为空!");
  455. return;
  456. }
  457. if (string.IsNullOrEmpty(this.txtPay_ThePayee.Text))
  458. {
  459. MessageBoxCustom.Show("收款人不能为空!");
  460. return;
  461. }
  462. if (string.IsNullOrEmpty(this.txtPay_CreateDatetime.DateValue))
  463. {
  464. MessageBoxCustom.Show("收款时间不能为空!");
  465. return;
  466. }
  467. #endregion
  468. DataTable dt = torbll.GetView_TwoSalesOrder(" Tsorder_Number='" + this.StrOrdNumber + "'").Tables[0];
  469. #region 2017-03-24 杨云奕 添加 判断是否接入微信支付宝的接口
  470. FinancialPayApiControl PayApi = new FinancialPayApiControl();
  471. int intCode = PayApi.PayApiControl(StrOrdNumber, this.cmbPay_PaymentMethod.Text.Trim(), Convert.ToDecimal(this.txtPay_AmountOf.Text));
  472. string serialnumber = "";
  473. if (intCode == 1)
  474. {
  475. serialnumber = PayApi.SerialNumber;
  476. }
  477. else if (intCode == -1)
  478. {
  479. //MessageBoxCustom.Show("取消微信刷卡支付,保存取消");
  480. return;
  481. }
  482. #endregion
  483. #region 保存
  484. #region 增加二销(后期)项目提成比例设置
  485. //LYFZ.Model.Model_ErpTwoPinsProjectCommissionProportion TwoPinsProjectCommissionProportionModel = new Model.Model_ErpTwoPinsProjectCommissionProportion();
  486. //LYFZ.BLL.BLL_ErpTwoPinsProjectCommissionProportion TwoPinsProjectCommissionProportionBll = new BLL.BLL_ErpTwoPinsProjectCommissionProportion();
  487. //string[] UserNumber =dt.Rows[0]["Tsorder_UserProportionOne"].ToString().Trim().Split(',');
  488. //for (int i = 0; i < UserNumber.Length; i++)
  489. //{
  490. // TwoPinsProjectCommissionProportionModel.Tpc_OrdNumber = txtTsorder_Number.Text.Trim();
  491. // TwoPinsProjectCommissionProportionModel.Tpc_AmountOf = Convert.ToDecimal(txtPay_AmountOf.Text);
  492. // TwoPinsProjectCommissionProportionModel.Tpc_ProjectName = txtTsorder_Name.Text.Trim();
  493. // TwoPinsProjectCommissionProportionModel.Tpc_OpenSingle = UserNumber[i].Split('|')[0];
  494. // TwoPinsProjectCommissionProportionModel.Tpc_TwoPinsCategory = Tsorder_Category;
  495. // TwoPinsProjectCommissionProportionModel.Tpc_CommissionPercentage = Convert.ToDecimal(UserNumber[i].Split('|')[1]);
  496. // TwoPinsProjectCommissionProportionModel.Tpc_CustomNumber = model.Pay_CustomNumber;
  497. // TwoPinsProjectCommissionProportionModel.Tpc_CreateDatetime = model.Pay_CreateDatetime;
  498. // TwoPinsProjectCommissionProportionModel.Tpc_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  499. // TwoPinsProjectCommissionProportionBll.Add(TwoPinsProjectCommissionProportionModel);
  500. //}
  501. #endregion
  502. List<Helper.CommandInfo> clist = new List<Helper.CommandInfo>();
  503. if (modelpm == null)
  504. {
  505. modelpm = new BLL.MemberCardPaymentModel();
  506. modelpm.PaymentAmount = Convert.ToDecimal(txtPay_AmountOf.Text);
  507. modelpm.RechargeDiscount = 0;
  508. modelpm.DiscountAmount = 0;
  509. modelpm.StrOrdNumber = this.StrOrdNumber;
  510. modelpm.StrPaymentMethod = "其他";
  511. modelpm.StrReturnType = "clist";
  512. }
  513. clist.AddRange(LYFZ.BLL.OrderPayment_Member.LaterPeriodPayment(StrClientNumber, modelpm, StrSource: "其他消费",strGuid:guid));
  514. LYFZ.Model.Model_ErpPayment model = new Model.Model_ErpPayment();
  515. model.Pay_OrdNumber = this.StrOrdNumber.Trim();
  516. model.Pay_ViceNumber = "";
  517. model.Pay_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
  518. model.pay_SerialNumber = serialnumber;
  519. model.Pay_AmountOf = Convert.ToDecimal(this.txtPay_AmountOf.Text);
  520. model.Pay_PaymentDiscount = modelpm.RechargeDiscount;
  521. model.Pay_DiscountAmount = modelpm.DiscountAmount;
  522. model.Pay_OpenSingle = dt.Rows[0]["Tsorder_OpenSingle"].ToString();
  523. model.Pay_ThePayee = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  524. model.Pay_PaymentMethod = this.cmbPay_PaymentMethod.Tag.ToString();
  525. model.Pay_OrdersLocation = "";
  526. model.Pay_ReceivableProject = this.txtTsorder_Name.Text;
  527. model.Pay_Remark = this.txtPay_Remark.Text;
  528. model.Pay_CreateDatetime = Convert.ToDateTime(this.txtPay_CreateDatetime.DateTimeValue.Trim());
  529. model.Pay_Category = "后期收款";
  530. model.Pay_TwoPinsCategory = Tsorder_Category;
  531. model.Pay_CommissionRatio = "";
  532. if (this.listBoxPerformance.Items.Count > 0 && this.currentPersonCommissionRatio != null)
  533. {
  534. model.Pay_OpenSingle = this.currentPersonCommissionRatio.ToOrderPersons();
  535. model.Pay_CommissionRatio = this.currentPersonCommissionRatio.ToString();
  536. }
  537. model.Pay_Type = 1;
  538. model.Pay_McNumber = modelpm.StrCardNumber;
  539. clist.Add(ptbll.GetAddCommandInfo(model));
  540. if (clist.Count > 0)
  541. {
  542. if (LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist) <= 0)
  543. { MessageBoxCustom.Show("支付失败!"); return; }
  544. }
  545. this.cmbPay_PaymentMethod.SetTextAndTag_ValueNull();
  546. this.ClearPerformance();
  547. MessageBoxCustom.Show("保存成功!");
  548. // 获取金额
  549. this.txtCope.Text = StrCope.ToString();//应收款
  550. DataTable DaPayment = ptbll.GetSum(" Pay_OrdNumber = '" + StrOrdNumber + "'").Tables[0];
  551. decimal Paid = 0;//已付款
  552. if (!string.IsNullOrEmpty(DaPayment.Rows[0]["Pay_AmountOf"].ToString().Trim()))
  553. { Paid = Convert.ToDecimal(DaPayment.Rows[0]["Pay_AmountOf"]); }
  554. this.txtPaid.Text = Paid.ToString();
  555. this.txtArrears.Text = (StrCope - Paid).ToString();//欠款
  556. this.PublicFunctionRows();
  557. this.txtPay_AmountOf.Text = "";
  558. this.cmbPay_PaymentMethod.Text = "";
  559. this.txtPay_Remark.Text = "";
  560. this.IsSaveed = true;
  561. this.txtPay_CreateDatetime.Enabled = false;
  562. #endregion
  563. /////付款后短信提醒
  564. //LYFZ.BLL.BLL_ErpSMSRecord.SendMsgByPayment(
  565. // dt.Rows[0]["Tsorder_Number"].ToString(),
  566. // dt.Rows[0]["Tsorder_Number"].ToString(),
  567. // Convert.ToDecimal(this.txtPay_AmountOf.Text).ToString("0.00"),
  568. // this.cmbPay_PaymentMethod.Text,
  569. // SDateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  570. // );
  571. }
  572. catch (Exception ex)
  573. { MessageBoxCustom.Show(ex.Message); }
  574. }
  575. LYFZ.BLL.MemberCardPaymentModel modelpm = null;
  576. /// <summary>
  577. /// 选择支付方式事件
  578. /// </summary>
  579. /// <param name="sender"></param>
  580. /// <param name="e"></param>
  581. void cmbPay_PaymentMethod_ComboBoxTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
  582. {
  583. guid = Guid.NewGuid().ToString().Replace("-", "").ToUpper();
  584. if (this.cmbPay_PaymentMethod.Text != "")
  585. {
  586. if (this.cmbPay_PaymentMethod.Tag.ToString() == "BEBACCAFEGECFBJFD")
  587. {
  588. if (!string.IsNullOrEmpty(this.txtPay_AmountOf.Text))
  589. {
  590. LYFZ.Software.MainBusiness.DoorCityProcess.SuperSmallForm.MemberCardDeductAmountSuperSmallForm frm = new DoorCityProcess.SuperSmallForm.MemberCardDeductAmountSuperSmallForm();
  591. frm.strOrdNumber = this.StrOrdNumber;//订单编号
  592. frm.PaymentAmount = Convert.ToDecimal(txtPay_AmountOf.Text);//支付金额
  593. frm.StrReturnType = "clist";
  594. frm.panelPerformance.Show();
  595. frm.btnDelPerformance.Click += BtnDelPerformance_Click;
  596. frm.btnPerformance.Click += BtnPerformance_Click;
  597. frm.ShowDialog();
  598. if (frm.IsSaveed)
  599. {
  600. modelpm = frm.model;
  601. this.btnSave_Click(this, null);
  602. }
  603. else
  604. { this.cmbPay_PaymentMethod.SetTextAndTag_ValueNull(); }
  605. }
  606. else
  607. { this.cmbPay_PaymentMethod.SetTextAndTag_ValueNull(); MessageBoxCustom.Show("请输入金额!"); }
  608. }
  609. else
  610. { modelpm = null; }
  611. }
  612. }
  613. }
  614. }