DataSetServiceBoxSetSmallForm.cs 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Windows.Forms;
  10. namespace LYFZ.Software.MainBusiness.MembershipManage.SetSmallForm
  11. {
  12. public partial class DataSetServiceBoxSetSmallForm : LYFZ.Software.UI.MembershipManage.SetSmallForm.DataSetServiceBoxSetSmallForm
  13. {
  14. public DataSetServiceBoxSetSmallForm()
  15. {
  16. this.cmbtreevClass.ComboBoxTree_NodeMouseClick += cmbtreevClass_ComboBoxTree_NodeMouseClick;
  17. }
  18. LYFZ.BLL.BLL_ErpMemberCard mcbll = new BLL.BLL_ErpMemberCard();
  19. LYFZ.BLL.BLL_ErpSMSRecord rbll = new LYFZ.BLL.BLL_ErpSMSRecord();
  20. LYFZ.BLL.BLL_SMSTemplates smsTemplates = new BLL.BLL_SMSTemplates();
  21. LYFZ.BLL.BLL_ErpSystemCategory scbll = new BLL.BLL_ErpSystemCategory();
  22. LYFZ.BLL.BLL_ErpSystemConfigure sgbll = new BLL.BLL_ErpSystemConfigure();
  23. LYFZ.BLL.BLL_ErpMemberCardPoints mcptsbll = new BLL.BLL_ErpMemberCardPoints();
  24. LYFZ.BLL.BLL_ErpMemberCardPayment mcptbll = new BLL.BLL_ErpMemberCardPayment();
  25. LYFZ.BLL.BLL_ErpMemberCardPointsLOG mcpslogbll = new BLL.BLL_ErpMemberCardPointsLOG();
  26. LYFZ.BLL.BLL_ErpMemberCardPaymentOrder mcpobll = new BLL.BLL_ErpMemberCardPaymentOrder();
  27. LYFZ.BLL.BLL_ErpMemberCardServiceContent mcscbll = new BLL.BLL_ErpMemberCardServiceContent();
  28. LYFZ.BLL.BLL_ErpMemberCardAmountChangeLOG mcclogbll = new BLL.BLL_ErpMemberCardAmountChangeLOG();
  29. LYFZ.BLL.BLL_ErpMemberCardServicePackageSet mcpsbll = new BLL.BLL_ErpMemberCardServicePackageSet();
  30. LYFZ.BLL.BLL_ErpMemberCardPaymentContentDetail mcpcdbll = new BLL.BLL_ErpMemberCardPaymentContentDetail();
  31. LYFZ.BLL.BLL_ErpMemberCardServicePackageContent mcpcbll = new BLL.BLL_ErpMemberCardServicePackageContent();
  32. List<LYFZ.Model.Model_ErpMemberCardServiceContent> mlist = null;
  33. DataTable tblMc = new DataTable();
  34. /// <summary>
  35. /// 是否保存
  36. /// </summary>
  37. public bool IsSaveed = false;
  38. /// <summary>
  39. /// 会员编号
  40. /// </summary>
  41. public string StrNumber = "";
  42. /// <summary>
  43. /// 客户编号
  44. /// </summary>
  45. public string StrClientNumber = "";
  46. /// <summary>
  47. /// 本地分店ID
  48. /// </summary>
  49. string strInfoID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
  50. /// <summary>
  51. /// 窗体加载事件
  52. /// </summary>
  53. /// <param name="sender"></param>
  54. /// <param name="e"></param>
  55. protected override void DataSetServiceBoxSetSmallForm_Shown(object sender, EventArgs e)
  56. {
  57. this.txtCount.Visible = false;
  58. this.PackageData();
  59. this.tblMc = mcbll.GetView_Custom("BView_MemberMain_GoldMember", StrWhere: "Mc_Number = '" + this.StrNumber + "'").Tables[0];
  60. this.mlist = mcscbll.GetModelList("Mcse_Number = '" + this.StrNumber + "'");
  61. if (tblMc.Rows.Count > 0)
  62. { this.StrClientNumber = mcbll.GetView_Custom("tb_ErpCustomer", StrWhere: "ID = '" + tblMc.Rows[0]["Cus_ID"].ToString().Trim() + "'", ShowColumnName: "Cus_CustomerNumber").Tables[0].Rows[0]["Cus_CustomerNumber"].ToString().Trim(); }
  63. }
  64. /// <summary>
  65. /// 绑定下拉树数据
  66. /// </summary>
  67. private void PackageData()
  68. {
  69. //套系大类
  70. DataTable dt = new DataTable();
  71. DataTable tbl = scbll.GetCategory("ID", "Sc_ClassCode = 'BFAFADBEEJBAADDFE'").Tables[0];
  72. if (tbl.Rows.Count <= 0)
  73. { MessageBoxCustom.Show("系统类别数据库数据未升级"); return; }
  74. tbl = scbll.GetCategory("ID,Sc_ClassCode,Sc_ClassName", "Sc_ClassParentID = '" + tbl.Rows[0]["ID"].ToString().Trim() + "'").Tables[0];
  75. TreeNode root = null;
  76. this.cmbtreevClass.Nodes.Clear();
  77. for (int i = 0; i < tbl.Rows.Count; i++)
  78. {
  79. dt = scbll.GetCategory("Sc_ClassCode,Sc_ClassName", "Sc_ClassParentID=" + tbl.Rows[i]["ID"].ToString() + "").Tables[0];
  80. if (dt.Rows.Count > 0)
  81. {
  82. for (int j = 0; j < dt.Rows.Count; j++)
  83. {
  84. root = new TreeNode();
  85. root.Text = dt.Rows[j]["Sc_ClassName"].ToString();
  86. root.Tag = dt.Rows[j]["Sc_ClassCode"].ToString();
  87. root.Name = "Parent";
  88. this.CreateTreeViewDepartmentUser(root.Nodes, dt.Rows[j]["Sc_ClassCode"].ToString());
  89. }
  90. }
  91. else
  92. {
  93. root = new TreeNode();
  94. root.Text = tbl.Rows[i]["Sc_ClassName"].ToString();
  95. root.Tag = tbl.Rows[i]["Sc_ClassCode"].ToString();
  96. root.Name = "Parent";
  97. this.CreateTreeViewDepartmentUser(root.Nodes, tbl.Rows[i]["Sc_ClassCode"].ToString());
  98. this.cmbtreevClass.TreeView.Nodes.Add(root);
  99. }
  100. }
  101. }
  102. DataTable ustbl = new DataTable();
  103. /// <summary>
  104. /// 绑定第二级人员
  105. /// </summary>
  106. /// <param name="nodes">TreeView的节点集合</param>
  107. /// <param name="dataSource">数据源</param>
  108. /// <param name="parentid"></param>
  109. private void CreateTreeViewDepartmentUser(TreeNodeCollection nodes, string ClassCode)
  110. {
  111. if (ClassCode != "")
  112. {
  113. if (ustbl.Rows.Count <= 0)
  114. { ustbl = mcpsbll.GetList("MscPs_PackageStatus = '上架'").Tables[0]; }
  115. DataRow[] dtRow = ustbl.Select("MscPs_PackageClass='" + ClassCode + "'");
  116. if (dtRow.Length > 0)
  117. {
  118. TreeNode node;
  119. for (int i = 0; i < dtRow.Length; i++)
  120. {
  121. node = new TreeNode();
  122. node.Text = dtRow[i]["MscPs_PackageName"].ToString();
  123. node.Tag = dtRow[i]["MscPs_PackagePrice"].ToString();
  124. node.Name = dtRow[i]["MscPs_PackageNumber"].ToString();
  125. nodes.Add(node);
  126. }
  127. }
  128. }
  129. }
  130. private int cellValue = 0;
  131. /// <summary>
  132. /// 数据列表双击事件
  133. /// </summary>
  134. /// <param name="sender"></param>
  135. /// <param name="e"></param>
  136. protected override void dgvData_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
  137. {
  138. if (e.RowIndex != -1 && e.ColumnIndex != -1)
  139. {
  140. this.txtCount.Visible = false;
  141. if (this.dgvData.Columns[e.ColumnIndex].Name == "Column3")
  142. {
  143. DataGridViewCell cell = this.dgvData.Rows[e.RowIndex].Cells[e.ColumnIndex];
  144. Rectangle rect = this.dgvData.GetCellDisplayRectangle(cell.ColumnIndex, cell.RowIndex, true);
  145. this.txtCount.Location = new Point(rect.Location.X + this.dgvData.Location.X, rect.Location.Y + this.dgvData.Location.Y);
  146. this.txtCount.Size = rect.Size;
  147. this.txtCount.Text = cell.Value.ToString().Trim();
  148. this.cellValue = Convert.ToInt32(cell.Value);
  149. this.txtCount.Tag = "A";
  150. this.txtCount.Visible = true;
  151. this.txtCount.Focus();
  152. }
  153. }
  154. }
  155. /// <summary>
  156. /// 数据列表单击事件
  157. /// </summary>
  158. /// <param name="sender"></param>
  159. /// <param name="e"></param>
  160. protected override void dgvData_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
  161. { this.txtCount.Visible = false; }
  162. /// <summary>
  163. /// 服务次数离开事件
  164. /// </summary>
  165. /// <param name="sender"></param>
  166. /// <param name="e"></param>
  167. protected override void txtCount_Leave(object sender, EventArgs e)
  168. {
  169. if (this.txtCount.Tag != null)
  170. {
  171. if (this.txtCount.Tag.ToString().Trim() == "A")
  172. {
  173. if (this.txtCount.Text.Trim() == "0")
  174. { MessageBoxCustom.Show("新加服务项次数不能为 0 !"); return; }
  175. if (this.txtCount.Text.Trim() != "")
  176. { this.dgvData.CurrentRow.Cells["Column3"].Value = this.txtCount.Text.Trim(); }
  177. else
  178. { this.dgvData.CurrentRow.Cells["Column3"].Value = "1"; }
  179. this.dgvData.CurrentRow.Tag = "1";
  180. if (Convert.ToInt32(this.txtCount.Text.Trim()) != this.cellValue)
  181. {
  182. this.cmbtreevClass.Tag = null;
  183. this.cmbtreevClass.Text = "";
  184. this.cmbtreevClass.Enabled = false;
  185. }
  186. this.dgvData.CurrentRow.DefaultCellStyle.ForeColor = Color.Red;
  187. this.GetdgvDataStatistic();
  188. this.txtCount.Tag = null;
  189. this.txtCount.Text = "";
  190. }
  191. this.txtCount.Visible = false;
  192. }
  193. }
  194. /// <summary>
  195. /// 统计
  196. /// </summary>
  197. private void GetdgvDataStatistic()
  198. {
  199. if (this.dgvData.Rows.Count > 0)
  200. {
  201. if (this.cmbtreevClass.Tag != null)
  202. {
  203. this.txtStatistic.Text = "统计:总价格(" + Convert.ToDecimal(this.cmbtreevClass.Tag).ToString("#.00") + "元)";
  204. }
  205. else
  206. {
  207. decimal dec_TotalPrice = 0;
  208. for (int i = 0; i < this.dgvData.Rows.Count; i++)
  209. { dec_TotalPrice += Convert.ToInt32(this.dgvData.Rows[i].Cells["Column3"].Value) * Convert.ToDecimal(this.dgvData.Rows[i].Cells["Column4"].Value); }
  210. if (Convert.ToDecimal(tblMc.Rows[0]["折扣"]) > 0)
  211. {
  212. string dec_Preferential = (dec_TotalPrice - (dec_TotalPrice * (Convert.ToDecimal(tblMc.Rows[0]["折扣"]) / 10))).ToString().Trim();
  213. this.txtStatistic.Text = "统计:总价格(" + dec_TotalPrice.ToString("#.00") + "元) 当前会员折扣(" + Convert.ToDecimal(tblMc.Rows[0]["折扣"]).ToString("#.0") + ") 可优惠(" + dec_Preferential.Substring(0, dec_Preferential.IndexOf('.') + 2) + "元) 只须支付(" + (dec_TotalPrice - Convert.ToDecimal(dec_Preferential)).ToString("#.0") + ")";
  214. }
  215. else
  216. { this.txtStatistic.Text = "统计:总价格(" + dec_TotalPrice.ToString("#.0") + "元)"; }
  217. }
  218. }
  219. else { this.txtStatistic.Text = "统计:总价格(0元)"; }
  220. }
  221. /// <summary>
  222. /// 服务次数输入限制
  223. /// </summary>
  224. /// <param name="sender"></param>
  225. /// <param name="e"></param>
  226. protected override void txtCount_KeyPress(object sender, KeyPressEventArgs e)
  227. {
  228. if (Convert.ToString(e.KeyChar) == "0")
  229. {
  230. if (this.txtCount.Text.Trim() == "")
  231. { e.Handled = true; }
  232. }
  233. else if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar))
  234. { e.Handled = true; }
  235. }
  236. /// <summary>
  237. /// 服务套系选择变化事件
  238. /// </summary>
  239. /// <param name="sender"></param>
  240. /// <param name="e"></param>
  241. void cmbtreevClass_ComboBoxTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
  242. {
  243. if (this.cmbtreevClass.Text.Trim() != "")
  244. {
  245. DataTable tbl = mcpcbll.GetPackageContent_Left_ContentSet("MscPc_PackageNumber = '" + this.cmbtreevClass.StrGetName.ToString().Trim() + "'").Tables[0];
  246. if (tbl.Rows.Count == 0)
  247. { MessageBoxCustom.Show("套系未设置服务项!"); this.cmbtreevClass.Text = ""; this.cmbtreevClass.Tag = ""; }
  248. this.dgvData.Rows.Clear();
  249. for (int i = 0; i < tbl.Rows.Count; i++)
  250. {
  251. DataGridViewRow dgvr = new DataGridViewRow();
  252. dgvr.DefaultCellStyle.ForeColor = Color.Red;
  253. DataGridViewCell cell = null;
  254. cell = new DataGridViewTextBoxCell();
  255. cell.Value = tbl.Rows[i]["MscPc_MemberServiceNumber"].ToString().Trim();
  256. dgvr.Cells.Add(cell);
  257. cell = new DataGridViewTextBoxCell();
  258. cell.Value = tbl.Rows[i]["MscPc_MemberServiceContent"].ToString().Trim();
  259. dgvr.Cells.Add(cell);
  260. cell = new DataGridViewTextBoxCell();
  261. cell.Value = tbl.Rows[i]["MscPc_MemberServiceCount"].ToString().Trim();
  262. dgvr.Cells.Add(cell);
  263. cell = new DataGridViewTextBoxCell();
  264. cell.Value = tbl.Rows[i]["Msc_SalePrice"].ToString().Trim();
  265. dgvr.Cells.Add(cell);
  266. cell = new DataGridViewTextBoxCell();
  267. cell.Value = "";
  268. dgvr.Cells.Add(cell);
  269. this.dgvData.Rows.Add(dgvr);
  270. }
  271. GetdgvDataStatistic();
  272. }
  273. }
  274. /// <summary>
  275. /// 支付
  276. /// </summary>
  277. /// <param name="sender"></param>
  278. /// <param name="e"></param>
  279. protected override void btnPayment_Click(object sender, EventArgs e)
  280. {
  281. if (this.dgvData.Rows.Count > 0)
  282. {
  283. DateTime strTime = SDateTime.Now;
  284. string strUserID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  285. List<Helper.CommandInfo> clist = new List<Helper.CommandInfo>();
  286. LYFZ.Model.Model_ErpMemberCardServiceContent model = null;
  287. LYFZ.Model.Model_ErpMemberCardPaymentContentDetail modeldetail = null;
  288. string strPaymentNumber = "PN" + LYFZ.Command.Command_Validate.DateTimeToString(strTime, "yyyyMMddHHmmssfff");
  289. decimal PaymentAmount = 0;
  290. string StrContentText = "";
  291. for (int i = 0; i < this.dgvData.Rows.Count; i++)
  292. {
  293. if (this.dgvData.Rows[i].Cells["Column3"].Value.ToString().Trim() == "")
  294. { MessageBoxCustom.Show("有服务项次数为空,请输入次数后再支付!"); return; }
  295. if (Convert.ToInt32(this.dgvData.Rows[i].Cells["Column3"].Value) <= 0)
  296. { MessageBoxCustom.Show("有服务项次数为0,请输入次数后再支付!"); return; }
  297. bool Isbl = true;
  298. for (int j = 0; j < this.mlist.Count; j++)
  299. {
  300. if (mlist[j].Mcse_MemberServiceNumber.Trim() == this.dgvData.Rows[i].Cells["Column1"].Value.ToString().Trim())
  301. {
  302. model = mlist[j];
  303. model.Mcse_ServiceTotalCount = model.Mcse_ServiceTotalCount + Convert.ToInt32(this.dgvData.Rows[i].Cells["Column3"].Value);
  304. model.Mcse_ServiceCount = model.Mcse_ServiceCount + Convert.ToInt32(this.dgvData.Rows[i].Cells["Column3"].Value);
  305. model.Mcse_UpdateDateTime = strTime;
  306. model.Mcse_UpdateName = strUserID;
  307. clist.Add(mcscbll.GetUpdateCommandInfo(model));
  308. //服务内容详情
  309. modeldetail = new Model.Model_ErpMemberCardPaymentContentDetail();
  310. modeldetail.Mcpcd_PaymentNumber = strPaymentNumber;
  311. modeldetail.Mcpcd_ServiceNumber = this.dgvData.Rows[i].Cells["Column1"].Value.ToString().Trim();
  312. modeldetail.Mcpcd_ServiceContent = this.dgvData.Rows[i].Cells["Column2"].Value.ToString().Trim();
  313. modeldetail.Mcpcd_Count = Convert.ToInt32(this.dgvData.Rows[i].Cells["Column3"].Value);
  314. modeldetail.Mcpcd_SalePrice = Convert.ToDecimal(this.dgvData.Rows[i].Cells["Column4"].Value);
  315. modeldetail.Mcpcd_CreateDatetime = strTime;
  316. modeldetail.Mcpcd_CreateName = strUserID;
  317. clist.Add(mcpcdbll.GetAddCommandInfo(modeldetail));
  318. StrContentText += modeldetail.Mcpcd_ServiceContent + "(充值" + modeldetail.Mcpcd_Count + "次,可使用次数为" + model.Mcse_ServiceCount + "次);";
  319. PaymentAmount += modeldetail.Mcpcd_Count * modeldetail.Mcpcd_SalePrice;
  320. Isbl = false;
  321. continue;
  322. }
  323. }
  324. if (Isbl)
  325. {
  326. model = new Model.Model_ErpMemberCardServiceContent();
  327. model.Mcse_Number = this.StrNumber;
  328. model.Mcse_MemberServiceNumber = this.dgvData.Rows[i].Cells["Column1"].Value.ToString().Trim();
  329. model.Mcse_ServiceContent = this.dgvData.Rows[i].Cells["Column2"].Value.ToString().Trim();
  330. model.Mcse_ServiceTotalCount = Convert.ToInt32(this.dgvData.Rows[i].Cells["Column3"].Value);
  331. model.Mcse_ServiceCount = Convert.ToInt32(this.dgvData.Rows[i].Cells["Column3"].Value);
  332. model.Mcse_UpdateDateTime = strTime;
  333. model.Mcse_UpdateName = strUserID;
  334. clist.Add(mcscbll.GetAddCommandInfo(model));
  335. //服务内容详情
  336. modeldetail = new Model.Model_ErpMemberCardPaymentContentDetail();
  337. modeldetail.Mcpcd_PaymentNumber = strPaymentNumber;
  338. modeldetail.Mcpcd_ServiceNumber = this.dgvData.Rows[i].Cells["Column1"].Value.ToString().Trim();
  339. modeldetail.Mcpcd_ServiceContent = this.dgvData.Rows[i].Cells["Column2"].Value.ToString().Trim();
  340. modeldetail.Mcpcd_Count = Convert.ToInt32(this.dgvData.Rows[i].Cells["Column3"].Value);
  341. modeldetail.Mcpcd_SalePrice = Convert.ToDecimal(this.dgvData.Rows[i].Cells["Column4"].Value);
  342. modeldetail.Mcpcd_CreateDatetime = strTime;
  343. modeldetail.Mcpcd_CreateName = strUserID;
  344. clist.Add(mcpcdbll.GetAddCommandInfo(modeldetail));
  345. StrContentText += modeldetail.Mcpcd_ServiceContent + "(充值" + modeldetail.Mcpcd_Count + "次,可使用次数为" + model.Mcse_ServiceCount + "次);";
  346. PaymentAmount += modeldetail.Mcpcd_Count * modeldetail.Mcpcd_SalePrice;
  347. }
  348. }
  349. if (clist.Count == 0)
  350. { MessageBoxCustom.Show("没有添加服务项"); return; }
  351. Hashtable htData = new Hashtable();
  352. htData["PackageClass"] = "";
  353. if (this.cmbtreevClass.Text.Trim() != "")
  354. {
  355. PaymentAmount = Convert.ToDecimal(this.cmbtreevClass.Tag);
  356. htData["PackageClass"] = this.cmbtreevClass.StrGetName.Trim();
  357. }
  358. htData["PaymentAmount"] = PaymentAmount;
  359. htData["decCopeAmount"] = PaymentAmount;
  360. htData["StrNumber"] = this.StrNumber;
  361. LYFZ.Software.MainBusiness.MembershipManage.SuperSmallForm.MemberPaymentSuperSmallForm frm = new SuperSmallForm.MemberPaymentSuperSmallForm();
  362. frm.htData = htData;
  363. frm.ShowDialog();
  364. if (frm.IsSaveed)
  365. {
  366. LYFZ.Software.MainBusiness.MembershipManage.SuperSmallForm.MemberPaymentModel modelPm = frm.model;
  367. LYFZ.Model.Model_ErpMemberCard modelcard = mcbll.GetModel("Mc_Number", this.StrNumber);
  368. //如果是储值卡扣款,则减会员可用金额
  369. if (modelPm.StrPaymentMethod.Trim() == "BEBACCAFEGECFBJFD")
  370. {
  371. //会员金额变更
  372. LYFZ.Model.Model_ErpMemberCardAmountChangeLOG modelchangelog = new Model.Model_ErpMemberCardAmountChangeLOG();
  373. modelchangelog.Mcacl_OriginalAmount = modelcard.Mc_Money;
  374. modelcard.Mc_Money = modelcard.Mc_Money - modelPm.DelConfirmAmount;
  375. modelcard.Mc_UpdateDateTime = strTime;
  376. modelcard.Mc_UpdateName = strUserID;
  377. //clist.Add(mcbll.GetUpdateCommandInfo(modelcard));
  378. //会员卡金额变更记录表
  379. modelchangelog.Mcacl_Number = this.StrNumber;
  380. modelchangelog.Mcacl_Type = "5";
  381. modelchangelog.Mcacl_ExistingAmount = modelcard.Mc_Money;
  382. modelchangelog.Mcacl_UseAmount = modelPm.DelConfirmAmount;
  383. modelchangelog.Mcacl_GiveAmount = 0;
  384. modelchangelog.Mcacl_PaymentMethod = modelPm.StrPaymentMethod;
  385. modelchangelog.Mcacl_PaymentBank = "";
  386. modelchangelog.Mcacl_OrderNumber = "";
  387. modelchangelog.Mcacl_Remark = "购买服务,应付:" + PaymentAmount + ",会员折扣:" + modelPm.DelMemberDiscount.ToString("0.00") + ",支付:" + modelPm.DelConfirmAmount.ToString("0.00") + "元;具体详情请查询:(tb_ErpMemberCardPaymentContentDetail|会员收款内容详情)表,收款编号:" + strPaymentNumber;
  388. modelchangelog.Mcacl_CreateDatetime = strTime;
  389. modelchangelog.Mcacl_CreateName = strUserID;
  390. modelchangelog.Mcacl_Guid = Guid.NewGuid().ToString().Replace("-", "").ToUpper();
  391. clist.Add(mcclogbll.GetAddCommandInfo(modelchangelog));
  392. }
  393. //会员充值 服务消费 收款表
  394. LYFZ.Model.Model_ErpMemberCardPaymentOrder modelOrder = new Model.Model_ErpMemberCardPaymentOrder();
  395. modelOrder.Mcpo_Number = this.StrNumber;
  396. modelOrder.Mcpo_OrderNumber = strPaymentNumber;
  397. modelOrder.Mcpo_OrderAmount = PaymentAmount;
  398. modelOrder.Mcpo_OrderType = "服务消费";
  399. modelOrder.Mcpo_OrderPerson = modelPm.StrOrderPerson;
  400. modelOrder.Mcpo_PackageClass = htData["PackageClass"].ToString().Trim();
  401. if (this.cmbtreevClass.Text.Trim() != "")
  402. {
  403. modelOrder.Mcpo_PackagePrice = Convert.ToDecimal(this.cmbtreevClass.Tag);
  404. modelOrder.Mcpo_OrderDiscount = 0;
  405. }
  406. else
  407. { modelOrder.Mcpo_OrderDiscount = modelPm.DelMemberDiscount; }
  408. modelOrder.Mcpo_CreateDatetime = strTime;
  409. modelOrder.Mcpo_CreateName = strUserID;
  410. clist.Add(mcpobll.GetAddCommandInfo(modelOrder));
  411. LYFZ.Model.Model_ErpMemberCardPayment modelpayment = new Model.Model_ErpMemberCardPayment();
  412. modelpayment.Mcpt_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
  413. modelpayment.Mcpt_PaymentNumber = strPaymentNumber;
  414. modelpayment.Mcpt_Number = this.StrNumber;
  415. modelpayment.Mcpt_PaymentType = "服务消费";
  416. modelpayment.Mcpt_PaymentAmount = modelPm.DelConfirmAmount;
  417. modelpayment.Mcpt_PaymentMethod = modelPm.StrPaymentMethod;
  418. modelpayment.Mcpt_PaymentBank = "";
  419. modelpayment.Mcpt_PackageClass = htData["PackageClass"].ToString().Trim();
  420. if (this.cmbtreevClass.Text.Trim() != "")
  421. { modelpayment.Mcpt_PackagePrice = Convert.ToDecimal(this.cmbtreevClass.Tag); }
  422. else
  423. { modelpayment.Mcpt_PackagePrice = 0; }
  424. modelpayment.Mcpt_Discount = modelPm.DelMemberDiscount;
  425. modelpayment.Mcpt_DiscountAmount = modelPm.DelMemberDiscountAmount;
  426. modelpayment.Mcpt_OrderPerson = modelPm.StrOrderPerson;
  427. modelpayment.Mcpt_PaymentRemark = modelPm.StrRemark;
  428. modelpayment.Mcpt_FinancialAudit = "";
  429. modelpayment.Mcpt_FinancialAuditName = "";
  430. modelpayment.Mcpt_FinancialAuditRemark = "";
  431. modelpayment.Mcpt_CreateDatetime = strTime;
  432. modelpayment.Mcpt_CreateName = strUserID;
  433. modelpayment.Mcpt_CommissionRatio = modelPm.CommissionRatio;
  434. clist.Add(mcptbll.GetAddCommandInfo(modelpayment));
  435. //积分
  436. int IntGetPoints = LYFZ.BLL.BLL_ErpMemberCard.GetPoints_AgoPeriod(LYFZ.EnumPublic.MemberPointsType.LatePeriod_RMB, modelPm.DelConfirmAmount, strInfoID, StrClientNumber);
  437. LYFZ.Model.Model_ErpMemberCardPoints modelps = mcptsbll.GetModel("Mcps_Number", this.StrNumber);
  438. LYFZ.Model.Model_ErpMemberCardPointsLOG modelpslog = new Model.Model_ErpMemberCardPointsLOG();
  439. modelpslog.MPlg_DividedShop = LYFZ.BLL.OrderPayment_Member.StrInfoID;
  440. modelpslog.MPlg_Number = this.StrNumber;
  441. modelpslog.MPlg_Type = "1";
  442. modelpslog.MPlg_OriginalPoints = 0;
  443. modelpslog.MPlg_ExistingPoints = IntGetPoints;
  444. modelpslog.MPlg_UsePoints = IntGetPoints;
  445. modelpslog.MPlg_RedeemArticle = "";
  446. modelpslog.MPlg_RedeemAmount = 0;
  447. modelpslog.MPlg_OrderNumber = "";
  448. modelpslog.MPlg_ViceCardNumber = "";
  449. modelpslog.MPlg_Remark = "";
  450. modelpslog.MPlg_CreateDatetime = strTime;
  451. modelpslog.MPlg_CreateName = strUserID;
  452. if (modelps.ID <= 0)
  453. {
  454. modelps = new Model.Model_ErpMemberCardPoints();
  455. modelps.Mcps_Number = this.StrNumber;
  456. modelps.Mcps_TotalPoints = IntGetPoints;
  457. modelps.Mcps_AvailablePoints = IntGetPoints;
  458. modelps.Mcps_OpenCardSource = "服务箱付款办理积分," + new System.Diagnostics.StackTrace(new System.Diagnostics.StackFrame(true)).ToString();
  459. modelps.Mcps_UpdateDateTime = strTime;
  460. modelps.Mcps_UpdateName = strUserID;
  461. clist.Add(mcptsbll.GetAddCommandInfo(modelps));
  462. }
  463. else
  464. {
  465. modelpslog.MPlg_OriginalPoints = modelps.Mcps_AvailablePoints;
  466. modelpslog.MPlg_ExistingPoints = modelpslog.MPlg_ExistingPoints + modelps.Mcps_AvailablePoints;
  467. modelpslog.MPlg_UsePoints = modelpslog.MPlg_ExistingPoints + IntGetPoints;
  468. modelps.Mcps_TotalPoints = modelps.Mcps_TotalPoints + IntGetPoints;
  469. modelps.Mcps_AvailablePoints = modelps.Mcps_AvailablePoints + IntGetPoints;
  470. modelps.Mcps_UpdateDateTime = strTime;
  471. modelps.Mcps_UpdateName = strUserID;
  472. clist.Add(mcptsbll.GetUpdateCommandInfo(modelps));
  473. }
  474. clist.Add(mcpslogbll.GetAddCommandInfo(modelpslog));
  475. //会员服务卡使用给持卡人发短信
  476. LYFZ.BLL.OrderPayment_Member.MemberServiceCardUse(modelcard.Mc_CustomerNumber, modelcard.Mc_CradNumber, StrContentText: StrContentText);
  477. //积分有效期
  478. clist.AddRange(LYFZ.BLL.OrderPayment_Member.PointsChangeAutoValidity(modelcard.Mc_Number, modelcard.Mc_CradNumber));
  479. string StrGradeName = LYFZ.BLL.OrderPayment_Member.GetMemberUpgradeData(modelcard.Mc_Number, IntGetPoints);
  480. if (StrGradeName != "")
  481. { modelcard.Mc_CardType = StrGradeName; }
  482. clist.Add(mcbll.GetUpdateCommandInfo(modelcard));
  483. if (frm.clist.Count > 0)
  484. { clist.AddRange(frm.clist); }
  485. if (clist.Count > 0)
  486. {
  487. if (MessageBoxCustom.Show("确定要保存吗?", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.No)
  488. { return; }
  489. if (LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist) <= 0)
  490. { MessageBoxCustom.Show("保存失败"); return; }
  491. this.IsSaveed = true;
  492. #region 流程短信
  493. System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(delegate()
  494. {
  495. Model.SMSParameters sparameters = null;
  496. if (modelPm.StrPaymentMethod.Trim() == "BEBACCAFEGECFBJFD")
  497. {
  498. sparameters = new Model.SMSParameters();
  499. sparameters.CardNumber = modelcard.Mc_CradNumber;
  500. sparameters.CurrentSpendingMemberID = modelcard.Mc_CustomerNumber;
  501. sparameters.CurrentSpendingAmount = modelPm.DelConfirmAmount;
  502. sparameters.AvailableBalance = modelcard.Mc_Money;
  503. try { smsTemplates.GenerateEventSMS(EnumPublic.SmsSendEvent.现金卡消费后X分钟后发提醒短信, sparameters); }
  504. catch { }
  505. }
  506. sparameters = new Model.SMSParameters();
  507. sparameters.CurrentSpendingMemberID = modelcard.Mc_CustomerNumber;
  508. sparameters.AvailablePoints = modelps.Mcps_AvailablePoints;
  509. try
  510. { smsTemplates.GenerateEventSMS(EnumPublic.SmsSendEvent.当积分接近X的百分之80时, sparameters); }
  511. catch { }
  512. try
  513. { smsTemplates.GenerateEventSMS(EnumPublic.SmsSendEvent.当积分达到或超过X分时, sparameters); }
  514. catch { }
  515. }));
  516. t.Start();
  517. #endregion
  518. if (LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.MemberManage, LYFZ.CustomAttributes.OperatingAuthority.Print))
  519. {
  520. LYFZ.Software.MainBusiness.MembershipManage.SuperSmallForm.RechargePrintMessageSuperSmallForm frmMesg = new SuperSmallForm.RechargePrintMessageSuperSmallForm();
  521. frmMesg.ShowDialog();
  522. if (frmMesg.IsSaveed)
  523. {
  524. Hashtable htDataX = new Hashtable();
  525. htDataX["strNumber"] = strPaymentNumber;
  526. htDataX["strMcNumber"] = this.StrNumber;
  527. htDataX["strDate"] = strTime.ToString("yyyy-MM-dd HH:mm");
  528. LYFZ.Software.MainBusiness.ReportPrint.ReportFixedFormat.PrintFixedFormat(LYFZ.EnumPublic.PrintTypeEnum.会员服务收款, htDataX);
  529. }
  530. }
  531. this.Close();
  532. }
  533. }
  534. }
  535. }
  536. /// <summary>
  537. /// 服务工具箱
  538. /// </summary>
  539. /// <param name="sender"></param>
  540. /// <param name="e"></param>
  541. protected override void btnToolbox_Click(object sender, EventArgs e)
  542. {
  543. LYFZ.Software.MainBusiness.MembershipManage.SetSmallForm.DataSetServiceToolboxSetSmallForm frm = new DataSetServiceToolboxSetSmallForm();
  544. frm.ShowDialog();
  545. if (frm.IsSave)
  546. {
  547. ListBox listData = frm.listbox;
  548. DataTable tbl = new DataTable();
  549. //this.dgvData.Rows.Clear();
  550. for (int i = 0; i < listData.Items.Count; i++)
  551. {
  552. if (tbl.Rows.Count <= 0)
  553. { tbl = mcbll.GetView_Custom("tb_ErpMemberCardServiceContentSet", StrWhere: "Msc_Status = '上架'", ShowColumnName: "ID,Msc_MemberServiceNumber,Msc_MemberServiceContent,Msc_Type,Msc_CostPrice,Msc_SalePrice,Msc_Status,Msc_ServiceRemark,Msc_CreateDatetime,Msc_CreateName,Msc_UpdateDateTime,Msc_UpdateName").Tables[0]; }
  554. DataRow[] dtRow = tbl.Select("Msc_MemberServiceNumber = '" + listData.Items[i].ToString().Trim() + "'");
  555. if (dtRow.Length > 0)
  556. {
  557. if (this.dgvData.Rows.Count > 0)
  558. {
  559. if (this.cmbtreevClass.Text.Trim() != "")
  560. {
  561. this.cmbtreevClass.Text = "";
  562. this.cmbtreevClass.Tag = null;
  563. this.cmbtreevClass.Enabled = false;
  564. }
  565. bool Isbl = true;
  566. for (int j = 0; j < this.dgvData.Rows.Count; j++)
  567. {
  568. if (this.dgvData.Rows[j].Cells["Column1"].Value.ToString().Trim() == dtRow[0]["Msc_MemberServiceNumber"].ToString().Trim())
  569. {
  570. Isbl = false;
  571. this.dgvData.Rows[j].Cells["Column3"].Value = (Convert.ToInt32(this.dgvData.Rows[j].Cells["Column3"].Value) + 1).ToString();
  572. this.dgvData.Rows[j].DefaultCellStyle.ForeColor = Color.Blue;
  573. break;
  574. }
  575. }
  576. if (Isbl)
  577. {
  578. DataGridViewRow dgvr = new DataGridViewRow();
  579. dgvr.DefaultCellStyle.ForeColor = Color.Red;
  580. DataGridViewCell cell = null;
  581. cell = new DataGridViewTextBoxCell();
  582. cell.Value = dtRow[0]["Msc_MemberServiceNumber"].ToString().Trim();
  583. dgvr.Cells.Add(cell);
  584. cell = new DataGridViewTextBoxCell();
  585. cell.Value = dtRow[0]["Msc_MemberServiceContent"].ToString().Trim();
  586. dgvr.Cells.Add(cell);
  587. cell = new DataGridViewTextBoxCell();
  588. cell.Value = "1";
  589. dgvr.Cells.Add(cell);
  590. cell = new DataGridViewTextBoxCell();
  591. cell.Value = dtRow[0]["Msc_SalePrice"].ToString().Trim();
  592. dgvr.Cells.Add(cell);
  593. cell = new DataGridViewTextBoxCell();
  594. cell.Value = "";
  595. dgvr.Cells.Add(cell);
  596. this.dgvData.Rows.Add(dgvr);
  597. }
  598. }
  599. else
  600. {
  601. DataGridViewRow dgvr = new DataGridViewRow();
  602. dgvr.DefaultCellStyle.ForeColor = Color.Red;
  603. DataGridViewCell cell = null;
  604. cell = new DataGridViewTextBoxCell();
  605. cell.Value = dtRow[0]["Msc_MemberServiceNumber"].ToString().Trim();
  606. dgvr.Cells.Add(cell);
  607. cell = new DataGridViewTextBoxCell();
  608. cell.Value = dtRow[0]["Msc_MemberServiceContent"].ToString().Trim();
  609. dgvr.Cells.Add(cell);
  610. cell = new DataGridViewTextBoxCell();
  611. cell.Value = "1";
  612. dgvr.Cells.Add(cell);
  613. cell = new DataGridViewTextBoxCell();
  614. cell.Value = dtRow[0]["Msc_SalePrice"].ToString().Trim();
  615. dgvr.Cells.Add(cell);
  616. cell = new DataGridViewTextBoxCell();
  617. cell.Value = "1";
  618. dgvr.Cells.Add(cell);
  619. this.dgvData.Rows.Add(dgvr);
  620. }
  621. }
  622. }
  623. GetdgvDataStatistic();
  624. }
  625. }
  626. /// <summary>
  627. /// 移除
  628. /// </summary>
  629. /// <param name="sender"></param>
  630. /// <param name="e"></param>
  631. protected override void btnRemove_Click(object sender, EventArgs e)
  632. {
  633. if (this.dgvData.Rows.Count > 0)
  634. {
  635. if (this.cmbtreevClass.Text.Trim() != "")
  636. {
  637. if (MessageBoxCustom.Show("移除将失去套系!\r\n您确定要移除吗?", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.No)
  638. { return; }
  639. }
  640. for (int i = 0; i < this.dgvData.SelectedRows.Count; i++)
  641. { this.dgvData.Rows.RemoveAt(this.dgvData.SelectedRows[i].Index); }
  642. if (this.dgvData.Rows.Count > 0)
  643. { this.cmbtreevClass.Text = ""; this.cmbtreevClass.Name = null; this.cmbtreevClass.Enabled = false; }
  644. else { this.cmbtreevClass.Enabled = true; }
  645. for (int i = 0; i < this.dgvData.Rows.Count; i++)
  646. { this.dgvData.Rows[i].DefaultCellStyle.ForeColor = Color.Red; }
  647. GetdgvDataStatistic();
  648. }
  649. }
  650. /// <summary>
  651. /// 关闭
  652. /// </summary>
  653. /// <param name="sender"></param>
  654. /// <param name="e"></param>
  655. protected override void DataSetServiceBoxSetSmallForm_FormClosing(object sender, FormClosingEventArgs e)
  656. {
  657. if (this.dgvData.Rows.Count > 0)
  658. {
  659. if (!IsSaveed)
  660. {
  661. if (MessageBoxCustom.Show("确定要关闭吗?", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.No)
  662. { e.Cancel = true; }
  663. }
  664. }
  665. }
  666. }
  667. }