ReferralPointsSuperSmallForm.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. using LYFZ.Helper;
  2. using LYFZ.Software.MainBusiness.DoorCityProcess;
  3. using LYFZ.Software.MainBusiness.MembershipManage.SetSmallForm;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.ComponentModel;
  7. using System.Data;
  8. using System.Drawing;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Windows.Forms;
  12. namespace LYFZ.Software.MainBusiness.MembershipManage.SuperSmallForm
  13. {
  14. public partial class ReferralPointsSuperSmallForm : LYFZ.Software.UI.MembershipManage.SuperSmallForm.ReferralPointsSuperSmallForm
  15. {
  16. public ReferralPointsSuperSmallForm()
  17. {
  18. }
  19. LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
  20. LYFZ.BLL.BLL_ErpCustomer ctbll = new BLL.BLL_ErpCustomer();
  21. LYFZ.BLL.BLL_ErpMemberCard mcbll = new BLL.BLL_ErpMemberCard();
  22. LYFZ.BLL.BLL_ErpCustomerGroup cgbll = new BLL.BLL_ErpCustomerGroup();
  23. LYFZ.BLL.BLL_ErpSystemConfigure sgbll = new BLL.BLL_ErpSystemConfigure();
  24. LYFZ.BLL.BLL_ErpMemberCardPoints mcpbll = new BLL.BLL_ErpMemberCardPoints();
  25. LYFZ.BLL.BLL_ErpMemberCardViceCard mcvcbll = new BLL.BLL_ErpMemberCardViceCard();
  26. LYFZ.BLL.BLL_ErpMemberCardPointsLOG mcplogbll = new BLL.BLL_ErpMemberCardPointsLOG();
  27. /// <summary>
  28. /// 会员卡编号
  29. /// </summary>
  30. public string StrNumber;
  31. /// <summary>
  32. /// 会员卡号
  33. /// </summary>
  34. public string CradNumber;
  35. /// <summary>
  36. /// 持卡人
  37. /// </summary>
  38. public string CradName;
  39. /// <summary>
  40. /// 会员卡积分
  41. /// </summary>
  42. public string CradPoints;
  43. /// <summary>
  44. /// 是否保存
  45. /// </summary>
  46. public bool IsSaveed = false;
  47. /// <summary>
  48. /// 订单号
  49. /// </summary>
  50. private string StrOrdNumber = "";
  51. /// <summary>
  52. /// 本地分店ID
  53. /// </summary>
  54. string strInfoID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
  55. /// <summary>
  56. /// 窗体加载事件
  57. /// </summary>
  58. /// <param name="sender"></param>
  59. /// <param name="e"></param>
  60. protected override void ReferralPointsSuperSmallForm_Load(object sender, EventArgs e)
  61. {
  62. this.txtCardName.Text = this.CradName;
  63. this.txtCardNumber.Text = this.CradNumber;
  64. this.txtPoints.Text = this.CradPoints;
  65. }
  66. /// <summary>
  67. /// 关闭窗体后发生事件
  68. /// </summary>
  69. /// <param name="sender"></param>
  70. /// <param name="e"></param>
  71. protected override void ReferralPointsSuperSmallForm_FormClosing(object sender, FormClosingEventArgs e)
  72. {
  73. GoldManagementSmallForm frm1 = (GoldManagementSmallForm)this.Owner;
  74. frm1.RefreshParentForm = IsSaveed;
  75. }
  76. /// <summary>
  77. /// 确定
  78. /// </summary>
  79. /// <param name="sender"></param>
  80. /// <param name="e"></param>
  81. protected override void btnOK_Click(object sender, EventArgs e)
  82. {
  83. if (this.StrOrdNumber.Trim() == "")
  84. { MessageBoxCustom.Show("请选择订单"); return; }
  85. DateTime StrTime = SDateTime.Now;
  86. string StrUserName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  87. List<CommandInfo> clist = new List<CommandInfo>();
  88. #region 将持卡人编号填到订单客户组的转介绍ID列去
  89. LYFZ.Model.Model_ErpCustomerGroup modelClientGroup = cgbll.GetModel("GP_OrderNumber", this.StrOrdNumber.Trim());
  90. if (modelClientGroup.GP_IntroducerCustomerID.Trim() != "")
  91. { MessageBoxCustom.Show("此订单号已经赠送过,不能再赠送!"); return; }
  92. modelClientGroup.GP_IntroducerCustomerID = "";
  93. DataTable tbl = orbll.GetView_Custom("tb_ErpMemberCard", StrWhere: "Mc_Number = '" + this.StrNumber + "'", ShowColumnName: "Mc_CustomerNumber").Tables[0];
  94. if (tbl.Rows.Count > 0)
  95. { modelClientGroup.GP_IntroducerCustomerID = tbl.Rows[0]["Mc_CustomerNumber"].ToString().Trim(); }
  96. modelClientGroup.GP_UpdateDatetime = StrTime;
  97. modelClientGroup.GP_UpdateName = StrUserName;
  98. clist.Add(cgbll.GetUpdateCommandInfo(modelClientGroup));
  99. #endregion
  100. #region 主卡积分与积分记录
  101. int IntPointsIntr = Convert.ToInt32(this.txtGetPoints.Text.Trim());
  102. LYFZ.Model.Model_ErpMemberCardPoints model = mcpbll.GetModel("Mcps_Number", this.StrNumber);
  103. LYFZ.Model.Model_ErpMemberCardPointsLOG modelog = new Model.Model_ErpMemberCardPointsLOG();
  104. modelog.MPlg_DividedShop = LYFZ.BLL.OrderPayment_Member.StrInfoID;
  105. modelog.MPlg_Number = this.StrNumber;
  106. modelog.MPlg_Type = "3";
  107. modelog.MPlg_OriginalPoints = model.Mcps_AvailablePoints;
  108. model.Mcps_AvailablePoints = model.Mcps_AvailablePoints + IntPointsIntr;
  109. model.Mcps_TotalPoints = model.Mcps_TotalPoints + IntPointsIntr;
  110. model.Mcps_UpdateDateTime = StrTime;
  111. model.Mcps_UpdateName = StrUserName;
  112. modelog.MPlg_ExistingPoints = model.Mcps_AvailablePoints;
  113. modelog.MPlg_UsePoints = Convert.ToInt32(this.txtGetPoints.Text.Trim());
  114. modelog.MPlg_OrderNumber = this.StrOrdNumber;
  115. modelog.MPlg_ViceCardNumber = "";
  116. modelog.MPlg_Remark = "介绍" + this.lblName1.Text.Trim() + this.txtManName.Text.Trim() + "," + this.lblName2.Text.Trim() + this.txtWomanName.Text.Trim() + "," + this.lblOrderNumber.Text.Trim() + this.txtOrderNumber.Text.Trim() + ",消费" + this.lblPackagesPrice.Text.Trim() + this.txtSeriesPrice.Text.Trim() + ",本次共获取转介绍积分:" + this.txtGetPoints.Text.Trim();
  117. modelog.MPlg_CreateDatetime = StrTime;
  118. modelog.MPlg_CreateName = StrUserName;
  119. clist.Add(mcplogbll.GetAddCommandInfo(modelog));
  120. if (model.ID <= 0)
  121. {
  122. model.Mcps_Number = this.StrNumber;
  123. clist.Add(mcpbll.GetAddCommandInfo(model));
  124. }
  125. else
  126. { clist.Add(mcpbll.GetUpdateCommandInfo(model)); }
  127. #endregion
  128. if (clist.Count > 0)
  129. {
  130. if (MessageBoxCustom.Show("您确定要赠送吗?", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.No)
  131. { return; }
  132. if (LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist) > 0)
  133. {
  134. IsSaveed = true;
  135. LYFZ.Model.Model_ErpMemberCard modelCard = mcbll.GetModel("Mc_Number", this.StrNumber);
  136. DataTable tblClient = orbll.GetView_Custom("tb_ErpCustomerGroupMembers", StrWhere: "GM_CustomerGroupID = '" + modelClientGroup.GP_CustomerGroupID + "' and GM_Master = '1'", ShowColumnName: "GM_CustomerID").Tables[0];
  137. //积分到达后发短信、介绍获得积分
  138. string StrContentText = "您介绍朋友订单" + this.StrOrdNumber + ",您获得转介绍积分(" + IntPointsIntr + ")分,当前可用积分(" + model.Mcps_AvailablePoints + ")分。";
  139. // LYFZ.BLL.OrderPayment_Member.MemberPointsSendSMS("", modelCard.Mc_CradNumber, modelCard.Mc_CustomerNumber, AvailablePoints: model.Mcps_AvailablePoints, GetReferralPoints: IntPointsIntr, StrContentText: StrContentText);
  140. //2017-03-24 刘工修改
  141. if (tblClient != null && tblClient.Rows.Count>0)
  142. LYFZ.BLL.OrderPayment_Member.MemberPointsSendSMS(tblClient.Rows[0]["GM_CustomerID"].ToString(), modelCard.Mc_CradNumber, modelCard.Mc_CustomerNumber, AvailablePoints: model.Mcps_AvailablePoints, GetReferralPoints: IntPointsIntr, StrContentText: StrContentText);
  143. MessageBoxCustom.Show("赠送成功");
  144. this.Close();
  145. }
  146. else { MessageBoxCustom.Show("赠送失败"); }
  147. }
  148. }
  149. /// <summary>
  150. /// 取消
  151. /// </summary>
  152. /// <param name="sender"></param>
  153. /// <param name="e"></param>
  154. protected override void btnCancel_Click(object sender, EventArgs e)
  155. { this.Close(); }
  156. /// <summary>
  157. /// 列表事件双击
  158. /// </summary>
  159. /// <param name="sender"></param>
  160. /// <param name="e"></param>
  161. protected override void lstTextQuery_MouseDoubleClick(object sender, MouseEventArgs e)
  162. {
  163. if (this.lstTextQuery.Items.Count > 0)
  164. {
  165. if (((ListItem)this.lstTextQuery.SelectedItem) != null)
  166. {
  167. this.GetOrdNumberGetData(((ListItem)this.lstTextQuery.SelectedItem).StrValue.ToString().Trim());
  168. this.txtTextQuery.Text = ((ListItem)this.lstTextQuery.SelectedItem).StrText;
  169. }
  170. }
  171. this.lstTextQuery.Visible = false;
  172. }
  173. /// <summary>
  174. /// 回车
  175. /// </summary>
  176. /// <param name="sender"></param>
  177. /// <param name="e"></param>
  178. protected override void lstTextQuery_KeyDown(object sender, KeyEventArgs e)
  179. {
  180. if (e.KeyCode == Keys.Enter)
  181. { this.lstTextQuery_MouseDoubleClick(this, null); }
  182. }
  183. /// <summary>
  184. /// 列表失去焦点
  185. /// </summary>
  186. /// <param name="sender"></param>
  187. /// <param name="e"></param>
  188. protected override void panelEx2_Click(object sender, EventArgs e)
  189. { this.lstTextQuery.Visible = false; }
  190. /// <summary>
  191. /// 输入值变化
  192. /// </summary>
  193. /// <param name="sender"></param>
  194. /// <param name="e"></param>
  195. protected override void txtTextQuery_EventTextBoxEx_TextChanged(object sender, EventArgs e)
  196. {
  197. if (this.txtTextQuery.Text.Trim() == "")
  198. { this.lstTextQuery.Visible = true; }
  199. }
  200. /// <summary>
  201. /// 点击输入框
  202. /// </summary>
  203. /// <param name="sender"></param>
  204. /// <param name="e"></param>
  205. protected override void txtTextQuery_Click(object sender, EventArgs e)
  206. { this.txtTextQuery_EventTextBoxEx_TextChanged(null, null); }
  207. /// <summary>
  208. /// 按键盘上的下健时
  209. /// </summary>
  210. /// <param name="sender"></param>
  211. /// <param name="e"></param>
  212. protected override void txtTextQuery_KeyDown(object sender, KeyEventArgs e)
  213. {
  214. if (e.KeyCode == Keys.Down || e.KeyCode == Keys.Up)
  215. { this.lstTextQuery.SelectedIndex = 0; this.lstTextQuery.Focus(); }
  216. else if (e.KeyCode == Keys.Enter)
  217. { LYFZ.Software.MainBusiness.CameraControlBook.PublicClass.InputQueryClient(this.txtTextQuery, this.lstTextQuery); }
  218. }
  219. /// <summary>
  220. /// 查询获取订单信息
  221. /// </summary>
  222. /// <param name="StrNumber"></param>
  223. void GetOrdNumberGetData(string OrdNumber)
  224. {
  225. string strViewName = "tb_ErpOrder Left Join dbo.tb_ErpOrderDigital ON Ord_Number = Ordv_Number left join dbo.tempTB_AggregationCustomer on Ord_Number = GP_OrderNumber";
  226. string strColumnName = "Ord_SeriesPrice,Cus_Name,Cus_Sex_cs,CASE [Ord_SinceOrderNumber] WHEN '' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS ShowOrdNumber,Ord_SeriesName,Ord_Type,(select stuff((select ',' + dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('')),1,1,'')) as OrdPe_OrdersPerson,Ordv_ViceNumber,Case when Ord_Type = '1' then (select top 1 Ordpg_Sights from dbo.tb_ErpOrdersPhotography where Ordpg_Number = Ordv_Number and Ordpg_ViceNumber = Ordv_ViceNumber) else '' end AS Ordpg_Sights";
  227. DataTable tbl = orbll.GetView_Custom(strViewName, StrWhere: "Ordv_Number = '" + OrdNumber + "'", filedOrder: "Ordv_DigitalNumber ASC", ShowColumnName: strColumnName).Tables[0];
  228. if (tbl.Rows.Count > 0)
  229. {
  230. this.txtOrderNumber.Text = tbl.Rows[0]["ShowOrdNumber"].ToString().Trim();
  231. this.txtSeriesName.Text = tbl.Rows[0]["Ord_SeriesName"].ToString().Trim();
  232. this.txtOrdersPerson.Text = tbl.Rows[0]["OrdPe_OrdersPerson"].ToString().Trim();
  233. this.txtSeriesPrice.Text = tbl.Rows[0]["Ord_SeriesPrice"].ToString().Trim();
  234. if (Convert.ToDecimal(tbl.Rows[0]["Ord_SeriesPrice"]) > 0)
  235. {
  236. DataTable dt = orbll.GetView_Custom("tb_ErpMemberCard", StrWhere: "Mc_Number = '" + this.StrNumber + "'", ShowColumnName: "Mc_CustomerNumber").Tables[0];
  237. this.txtGetPoints.Text = LYFZ.BLL.BLL_ErpMemberCard.GetPoints_AgoPeriod(LYFZ.EnumPublic.MemberPointsType.txtReferral_RMB, Convert.ToDecimal(tbl.Rows[0]["Ord_SeriesPrice"]), strInfoID, dt.Rows[0]["Mc_CustomerNumber"].ToString().Trim()).ToString();
  238. }
  239. else
  240. { this.txtGetPoints.Text = "0"; }
  241. string[] StrNameArray = tbl.Rows[0]["Cus_Name"].ToString().Trim().Split('/');
  242. string[] StrSexArray = tbl.Rows[0]["Cus_Sex_cs"].ToString().Trim().Split('/');
  243. if (tbl.Rows[0]["Ord_Type"].ToString().Trim() == "0")
  244. {
  245. if (StrNameArray.Length > 1)
  246. {
  247. if (StrSexArray[0].Trim() == "男")
  248. { this.lblName1.Text = "男宾姓名:"; }
  249. else if (StrSexArray[0].Trim() == "女")
  250. { this.lblName2.Text = "女宾姓名:"; }
  251. this.txtManName.Text = StrNameArray[0].Trim();
  252. if (StrSexArray[1].Trim() == "男")
  253. { this.lblName1.Text = "男宾姓名:"; }
  254. else if (StrSexArray[1].Trim() == "女")
  255. { this.lblName2.Text = "女宾姓名:"; }
  256. this.txtWomanName.Text = StrNameArray[1].Trim();
  257. }
  258. else
  259. {
  260. this.lblName1.Text = "男宾姓名:";
  261. this.lblName2.Text = "女宾姓名:";
  262. if (StrSexArray[0].Trim() == "男")
  263. { this.txtManName.Text = StrNameArray[0].Trim(); }
  264. else if (StrSexArray[0].Trim() == "女")
  265. { this.txtWomanName.Text = StrNameArray[0].Trim(); }
  266. }
  267. this.lblName1.Location = new Point(26, lblName1.Location.Y);
  268. this.lblName2.Location = new Point(229, lblName2.Location.Y);
  269. }
  270. else if (tbl.Rows[0]["Ord_Type"].ToString().Trim() == "1")
  271. {
  272. this.lblName1.Text = "宝贝姓名:";
  273. this.lblName2.Text = "家长姓名:";
  274. this.txtManName.Text = StrNameArray[0].Trim();
  275. this.txtWomanName.Text = StrNameArray[1].Trim();
  276. this.lblName1.Location = new Point(26, lblName1.Location.Y);
  277. this.lblName2.Location = new Point(229, lblName2.Location.Y);
  278. }
  279. else if (tbl.Rows[0]["Ord_Type"].ToString().Trim() == "2" || tbl.Rows[0]["Ord_Type"].ToString().Trim() == "3")
  280. {
  281. this.lblName1.Text = "客户姓名:";
  282. this.lblName2.Text = "客户性别:";
  283. this.txtManName.Text = StrNameArray[0].Trim();
  284. this.txtWomanName.Text = StrSexArray[0].Trim();
  285. this.lblName1.Location = new Point(26, lblName1.Location.Y);
  286. this.lblName2.Location = new Point(229, lblName2.Location.Y);
  287. }
  288. DataTable tblCLientGroup = orbll.GetView_Custom("tb_ErpCustomerGroup", StrWhere: "GP_OrderNumber = '" + OrdNumber + "'", ShowColumnName: "GP_IntroducerCustomerID").Tables[0];
  289. this.btnOK.Enabled = true;
  290. if (tblCLientGroup.Rows.Count > 0)
  291. {
  292. if (tblCLientGroup.Rows[0]["GP_IntroducerCustomerID"].ToString().Trim() != "")
  293. { this.btnOK.Enabled = false; MessageBoxCustom.Show("此订单号已经赠送过,不能再赠送!"); return; }
  294. }
  295. this.StrOrdNumber = OrdNumber;
  296. }
  297. }
  298. }
  299. }