CashbackInfoSuperSmallForm.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. using LYFZ.Software.MainBusiness.MembershipManage.SetSmallForm;
  2. using System;
  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.SuperSmallForm
  11. {
  12. public partial class CashbackInfoSuperSmallForm : LYFZ.Software.UI.MembershipManage.SuperSmallForm.CashbackInfoSuperSmallForm
  13. {
  14. LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
  15. LYFZ.BLL.BLL_ErpMemberCard mcbll = new BLL.BLL_ErpMemberCard();
  16. LYFZ.BLL.BLL_ErpMemberCardBackCash mcbcbll = new BLL.BLL_ErpMemberCardBackCash();
  17. LYFZ.BLL.BLL_ErpMemberCardViceCard bll_ViceCard = new BLL.BLL_ErpMemberCardViceCard();
  18. LYFZ.BLL.BLL_ErpMemberCardBackCashTakeCash mcbctcbll = new BLL.BLL_ErpMemberCardBackCashTakeCash();
  19. // <summary>
  20. /// 登录者姓名
  21. /// </summary>
  22. string loginUserName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_Name;
  23. /// <summary>
  24. /// 登录者员工ID
  25. /// </summary>
  26. string loginUserID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  27. public CashbackInfoSuperSmallForm()
  28. {
  29. this.tabControlEx1.SelectedIndexChanged += tabControlEx1_SelectedIndexChanged;
  30. this.btnDelete.Click += btnDelete_Click;
  31. this.FormClosing += CashbackInfoSuperSmallForm_FormClosing;
  32. this.btnDelete.Visible = false;
  33. }
  34. /// <summary>
  35. /// 会员编号
  36. /// </summary>
  37. public string StrNumber;
  38. /// <summary>
  39. /// 是否保存
  40. /// </summary>
  41. public bool IsSaveed = false;
  42. DataTable tbl = new DataTable();
  43. /// <summary>
  44. /// 窗体加载事件
  45. /// </summary>
  46. /// <param name="sender"></param>
  47. /// <param name="e"></param>
  48. protected override void CashbackInfoSuperSmallForm_Load(object sender, EventArgs e)
  49. {
  50. LYFZ.Model.Model_ErpMemberCardBackCash model = mcbcbll.GetModel("Mcbc_Number", this.StrNumber);
  51. if (model.ID > 0)
  52. {
  53. this.txtCashBackNumber.Text = model.Mcbc_CashBackNumber.ToString().Trim();
  54. string[] strSpilt = model.Mcbc_CashBackProportion.Trim().Split(',');
  55. string StrProportion = "";
  56. for (int i = 0; i < strSpilt.Length; i++)
  57. {
  58. StrProportion += "(" + (i + 1) + ")." + strSpilt[i].Trim() + "% ";
  59. }
  60. this.txtCashBackProportion.Text = StrProportion;
  61. this.txtHaveBeenTakenOutAmount.Text = model.Mcbc_AlreadyWithdrawCash.ToString("#,##0.00");
  62. this.txtHaveReturnedAmount.Text = model.Mcbc_AlreadyCashBack.ToString("#,##0.00");
  63. this.txtPackagesAmount.Text = model.Mcbc_PackagesMoney.ToString("#,##0.00");
  64. }
  65. string StrTableName = "select tb_ErpMemberCardBackCashSet.ID," +
  66. "Mcb_Number," +
  67. "Mcb_No," +
  68. "Mcb_Proportion," +
  69. "Mcb_IsSpending," +
  70. "(select Ord_SinceOrderNumber from tb_ErpOrder Where Ord_Number = Mcb_OrderNumber) as Mcb_OrderNumber," +
  71. "(select top 1 Cus_Name from tempTB_AggregationCustomer Where GP_OrderNumber = Mcb_OrderNumber) AS Cus_Name," +
  72. "Mcb_SpendingTime," +
  73. "Mcb_CreateDatetime," +
  74. "Mcb_CreateName," +
  75. "Mcb_UpdateDateTime," +
  76. "Mcb_UpdateName," +
  77. "Mcb_ViceNumber," +
  78. "Mcb_CashBackGroup," +
  79. "Mvc_ViceCardNumber," +
  80. "Mcb_CashBackAmount " +
  81. "from tb_ErpMemberCardBackCashSet " +
  82. "Left Join tb_ErpMemberCardViceCard on Mcb_ViceNumber = Mvc_ViceNumber Where Mcb_Number = '" + this.StrNumber + "' order by Mcb_CashBackGroup DESC,Mcb_No ASC";
  83. DataTable tbl = orbll.GetView_Custom(StrTableName).Tables[0];
  84. this.dgvData1.DataColumns("序号,比例,返现金额,返现状态,使用副卡,消费订单,消费日期");
  85. System.Drawing.Color PowderBlue = this.dgvData1.DataGridViewRowsBackColor_Single();
  86. for (int i = 0; i < tbl.Rows.Count; i++)
  87. {
  88. DataGridViewRow dgvl = new DataGridViewRow();
  89. DataGridViewCell cell = null;
  90. if (i > 0)
  91. {
  92. if (tbl.Rows[i]["Mcb_CashBackGroup"].ToString().Trim() != tbl.Rows[i - 1]["Mcb_CashBackGroup"].ToString().Trim())
  93. {
  94. if (PowderBlue == this.dgvData1.DataGridViewRowsBackColor_Single())
  95. { PowderBlue = this.dgvData1.DataGridViewRowsBackColor_Double(); }
  96. else
  97. { PowderBlue = this.dgvData1.DataGridViewRowsBackColor_Single(); }
  98. }
  99. }
  100. dgvl.DefaultCellStyle.BackColor = PowderBlue;
  101. cell = new DataGridViewTextBoxCell();
  102. cell.Value = tbl.Rows[i]["Mcb_No"].ToString().Trim();
  103. dgvl.Cells.Add(cell);
  104. cell = new DataGridViewTextBoxCell();
  105. cell.Value = tbl.Rows[i]["Mcb_Proportion"].ToString().Trim();
  106. dgvl.Cells.Add(cell);
  107. cell = new DataGridViewTextBoxCell();
  108. cell.Value = tbl.Rows[i]["Mcb_CashBackAmount"].ToString();
  109. dgvl.Cells.Add(cell);
  110. cell = new DataGridViewTextBoxCell();
  111. cell.Value = tbl.Rows[i]["Mcb_IsSpending"].ToString().Trim() == "0" ? "未使用" : tbl.Rows[i]["Mcb_IsSpending"].ToString().Trim() == "1" ? "已返现" : "已失效";
  112. dgvl.Cells.Add(cell);
  113. cell = new DataGridViewTextBoxCell();
  114. cell.Value = tbl.Rows[i]["Mvc_ViceCardNumber"].ToString().Trim();
  115. dgvl.Cells.Add(cell);
  116. cell = new DataGridViewTextBoxCell();
  117. cell.Value = tbl.Rows[i]["Mcb_OrderNumber"].ToString().Trim() + " " + tbl.Rows[i]["Cus_Name"].ToString().Trim();
  118. dgvl.Cells.Add(cell);
  119. cell = new DataGridViewTextBoxCell();
  120. if (tbl.Rows[i]["Mcb_SpendingTime"].ToString().Trim() == "")
  121. { cell.Value = ""; }
  122. else { cell.Value = Convert.ToDateTime(tbl.Rows[i]["Mcb_SpendingTime"]).ToString("yyyy-MM-dd HH:mm"); }
  123. dgvl.Cells.Add(cell);
  124. this.dgvData1.Rows.Add(dgvl);
  125. }
  126. this.dgvData1.Columns["序号"].Width = 40;
  127. this.dgvData1.Columns["比例"].Width = 50;
  128. this.dgvData1.Columns["返现状态"].Width = 60;
  129. this.dgvData1.Columns["返现金额"].Width = 80;
  130. this.dgvData1.Columns["消费订单"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
  131. this.dgvData1.Columns["消费日期"].Width = 110;
  132. DataTable tblA = mcbll.GetView_Custom("tb_ErpMemberCardBackCashTakeCash", StrWhere: "Mctc_Number = '" + StrNumber + "'", ShowColumnName: "ID,Mctc_Number,Mctc_PackagesMoney,Mctc_CashAmount,Mctc_UpdateDateTime,dbo.fn_CheckUserIDGetUserName(Mctc_UpdateName) AS Mctc_UpdateName").Tables[0];
  133. this.dgvData2.DataColumns("序号,ID,套系金额,提现金额,提现日期,经手人", strHideField: "ID,套系金额");
  134. for (int i = 0; i < tblA.Rows.Count; i++)
  135. {
  136. DataGridViewRow dgvl = new DataGridViewRow();
  137. DataGridViewCell cell = null;
  138. cell = new DataGridViewTextBoxCell();
  139. cell.Value = (i + 1);
  140. dgvl.Cells.Add(cell);
  141. cell = new DataGridViewTextBoxCell();
  142. cell.Value = tblA.Rows[i]["ID"].ToString().Trim();
  143. dgvl.Cells.Add(cell);
  144. cell = new DataGridViewTextBoxCell();
  145. cell.Value = tblA.Rows[i]["Mctc_PackagesMoney"].ToString().Trim();
  146. dgvl.Cells.Add(cell);
  147. cell = new DataGridViewTextBoxCell();
  148. cell.Value = tblA.Rows[i]["Mctc_CashAmount"].ToString().Trim();
  149. dgvl.Cells.Add(cell);
  150. cell = new DataGridViewTextBoxCell();
  151. cell.Value = Convert.ToDateTime(tblA.Rows[i]["Mctc_UpdateDateTime"]).ToString("yyyy-MM-dd HH:mm");
  152. dgvl.Cells.Add(cell);
  153. cell = new DataGridViewTextBoxCell();
  154. cell.Value = tblA.Rows[i]["Mctc_UpdateName"].ToString().Trim();
  155. dgvl.Cells.Add(cell);
  156. this.dgvData2.Rows.Add(dgvl);
  157. }
  158. DataTable tbl_ViceCard = mcbll.GetView_Custom("tb_ErpMemberCardViceCard", StrWhere: "Mvc_ViceCardType = '返现副卡' and Mvc_Status != '3' and Mvc_Number = '" + StrNumber + "'", filedOrder: "Mvc_CashBackGroup DESC,ID ASC", ShowColumnName: "Mvc_ViceNumber,Mvc_ViceCardNumber,Mvc_ViceCardType,Mvc_Status,Mvc_Remark,Mvc_CreateDatetime,Mvc_UpdateDateTime").Tables[0];
  159. string StrColumn = "副卡号,副卡类型,状态,发卡日期,使用日期,副卡编号";
  160. this.dgvData3.DataColumns(StrColumn, strHideField: "副卡编号");
  161. PowderBlue = this.dgvData1.DataGridViewRowsBackColor_Single();
  162. for (int i = 0; i < tbl_ViceCard.Rows.Count; i++)
  163. {
  164. DataGridViewRow dgvr = new DataGridViewRow();
  165. DataGridViewCell cell = null;
  166. if (i > 0)
  167. {
  168. if (tbl.Rows[i]["Mcb_CashBackGroup"].ToString().Trim() != tbl.Rows[i - 1]["Mcb_CashBackGroup"].ToString().Trim())
  169. {
  170. if (PowderBlue == this.dgvData1.DataGridViewRowsBackColor_Single())
  171. { PowderBlue = this.dgvData1.DataGridViewRowsBackColor_Double(); }
  172. else
  173. { PowderBlue = this.dgvData1.DataGridViewRowsBackColor_Single(); }
  174. }
  175. }
  176. dgvr.DefaultCellStyle.BackColor = PowderBlue;
  177. cell = new DataGridViewTextBoxCell();
  178. cell.Value = tbl_ViceCard.Rows[i]["Mvc_ViceCardNumber"].ToString().Trim();
  179. dgvr.Cells.Add(cell);
  180. cell = new DataGridViewTextBoxCell();
  181. cell.Value = tbl_ViceCard.Rows[i]["Mvc_ViceCardType"].ToString().Trim();
  182. dgvr.Cells.Add(cell);
  183. cell = new DataGridViewTextBoxCell();
  184. string StrStatus = tbl_ViceCard.Rows[i]["Mvc_Status"].ToString().Trim() == "0" ? "已注销" : tbl_ViceCard.Rows[i]["Mvc_Status"].ToString().Trim() == "1" ? "正在使用" : "已使用";
  185. if (!string.IsNullOrEmpty(tbl_ViceCard.Rows[i]["Mvc_Remark"].ToString().Trim()))
  186. { cell.Value = StrStatus + "_" + tbl_ViceCard.Rows[i]["Mvc_Remark"].ToString().Trim(); }
  187. else
  188. { cell.Value = StrStatus; }
  189. dgvr.Cells.Add(cell);
  190. cell = new DataGridViewTextBoxCell();
  191. cell.Value = LYFZ.Command.Command_Validate.DateTimeToString(tbl_ViceCard.Rows[i]["Mvc_CreateDatetime"], "yyyy-MM-dd HH:mm");
  192. dgvr.Cells.Add(cell);
  193. cell = new DataGridViewTextBoxCell();
  194. cell.Value = LYFZ.Command.Command_Validate.DateTimeToString(tbl_ViceCard.Rows[i]["Mvc_UpdateDateTime"], "yyyy-MM-dd HH:mm");
  195. dgvr.Cells.Add(cell);
  196. cell = new DataGridViewTextBoxCell();
  197. cell.Value = tbl_ViceCard.Rows[i]["Mvc_ViceNumber"].ToString().Trim();
  198. dgvr.Cells.Add(cell);
  199. this.dgvData3.Rows.Add(dgvr);
  200. }
  201. }
  202. /// <summary>
  203. /// 选项卡选择
  204. /// </summary>
  205. /// <param name="sender"></param>
  206. /// <param name="e"></param>
  207. void tabControlEx1_SelectedIndexChanged(object sender, EventArgs e)
  208. {
  209. if (this.tabControlEx1.SelectedIndex == 1 || this.tabControlEx1.SelectedIndex == 2)
  210. { this.btnDelete.Visible = true; }
  211. else
  212. { this.btnDelete.Visible = false; }
  213. }
  214. /// <summary>
  215. /// 删除
  216. /// </summary>
  217. /// <param name="sender"></param>
  218. /// <param name="e"></param>
  219. void btnDelete_Click(object sender, EventArgs e)
  220. {
  221. if (this.tabControlEx1.SelectedIndex == 1)
  222. {
  223. if (this.dgvData2.Rows.Count > 0 && this.dgvData2.CurrentRow.Index >= 0)
  224. {
  225. DateTime StrTime = new DateTime();
  226. string StrUserID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  227. List<Helper.CommandInfo> clist = new List<Helper.CommandInfo>();
  228. LYFZ.Model.Model_ErpMemberCardBackCashTakeCash modeltc = mcbctcbll.GetModel(Convert.ToInt32(this.dgvData2.CurrentRow.Cells["ID"].Value));
  229. if (modeltc.Mctc_CashAmountAudit.Trim() == "已审核")
  230. { MessageBoxCustom.Show("返现已审核,不能删除!"); return; }
  231. clist.Add(mcbctcbll.GetDeleteCommandInfo("ID", "=", modeltc.ID));
  232. LYFZ.Model.Model_ErpMemberCardBackCash model = mcbcbll.GetModel("Mcbc_Number", modeltc.Mctc_Number);
  233. model.Mcbc_AlreadyWithdrawCash = model.Mcbc_AlreadyWithdrawCash - Convert.ToDecimal(this.dgvData2.CurrentRow.Cells["提现金额"].Value);
  234. model.Mcbc_UpdateDateTime = StrTime;
  235. model.Mcbc_UpdateName = StrUserID;
  236. clist.Add(mcbcbll.GetUpdateCommandInfo(model));
  237. if (clist.Count > 0)
  238. {
  239. LYFZ.BLL.BLL_ErpSystemLogs.WriteSystemLog(EnumPublic.SystemLogsType.删除会员副卡记录, "删除会员副卡"+ modeltc.Mctc_Number + " 的提现记录,提现金额:"+ this.dgvData2.CurrentRow.Cells["提现金额"].Value, loginUserID, loginUserName);
  240. if (MessageBoxCustom.Show("你确定要删除吗?删除后,删除金额会退回卡里!", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.No)
  241. { return; }
  242. if (LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist) <= 0)
  243. { MessageBoxCustom.Show("提现失败"); return; }
  244. this.IsSaveed = true;
  245. MessageBoxCustom.Show("提现成功");
  246. this.CashbackInfoSuperSmallForm_Load(this, null);
  247. }
  248. }
  249. }
  250. else if (this.tabControlEx1.SelectedIndex == 2)
  251. {
  252. if (this.dgvData3.Rows.Count > 0 && this.dgvData3.CurrentRow.Index >= 0)
  253. {
  254. LYFZ.Model.Model_ErpMemberCardViceCard model = bll_ViceCard.GetModel("Mvc_ViceNumber", this.dgvData3.CurrentRow.Cells["副卡编号"].Value.ToString().Trim());
  255. if (model.Mvc_Status.Trim() == "0")
  256. { MessageBoxCustom.Show("此副卡已注销,不能删除!"); return; }
  257. if (model.Mvc_Status.Trim() == "2")
  258. { MessageBoxCustom.Show("此副卡已使用,不能删除!"); return; }
  259. if (!LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.MemberManage, LYFZ.CustomAttributes.OperatingAuthority.Member_ViceCardDelete))
  260. { MessageBoxCustom.Show("您无权限删除副卡!"); return; }
  261. if (MessageBoxCustom.Show("您确定要删除 副卡:" + this.dgvData3.CurrentRow.Cells["副卡号"].Value.ToString().Trim() + " 吗?", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.No)
  262. { return; }
  263. if (!bll_ViceCard.Delete(model.ID))
  264. { MessageBoxCustom.Show("删除失败!"); return; }
  265. else
  266. {
  267. LYFZ.BLL.BLL_ErpSystemLogs.WriteSystemLog(EnumPublic.SystemLogsType.删除会员副卡记录, "删除会员副卡" + this.dgvData3.CurrentRow.Cells["副卡号"].Value.ToString().Trim() + " ", loginUserID,loginUserName);
  268. MessageBoxCustom.Show("删除成功!"); this.CashbackInfoSuperSmallForm_Load(this, null);
  269. }
  270. }
  271. }
  272. }
  273. /// <summary>
  274. /// 关闭窗体后发生事件
  275. /// </summary>
  276. /// <param name="sender"></param>
  277. /// <param name="e"></param>
  278. void CashbackInfoSuperSmallForm_FormClosing(object sender, FormClosingEventArgs e)
  279. {
  280. GoldManagementSmallForm frm1 = (GoldManagementSmallForm)this.Owner;
  281. frm1.RefreshParentForm = IsSaveed;
  282. }
  283. }
  284. }