ViceCardConsumeSmallForm.cs 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521
  1. using LYFZ.Software.MainBusiness.DoorCityProcess;
  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.SetSmallForm
  11. {
  12. public partial class ViceCardConsumeSmallForm : LYFZ.Software.UI.MembershipManage.SetSmallForm.ViceCardConsumeSmallForm
  13. {
  14. public ViceCardConsumeSmallForm()
  15. {
  16. this.Load += ViceCardConsumeSmallForm_Load;
  17. this.btnClose.Click += btnClose_Click;
  18. this.btnUse.Click += btnUse_Click;
  19. this.btnFind.Click += btnFind_Click;
  20. this.btnOrderFind.Click += btnOrderFind_Click;
  21. this.txtInputViceCard.KeyDown += txtInputViceCard_KeyDown;
  22. this.txtInputViceCard.Leave += txtInputViceCard_Leave;
  23. this.lstTextQuery.MouseDoubleClick += lstTextQuery_MouseDoubleClick;
  24. this.lstTextQuery.KeyDown += lstTextQuery_KeyDown;
  25. this.panelEx1.Click += panelEx1_Click;
  26. this.panelEx8.Click += panelEx8_Click;
  27. this.txtTextQuery.EventTextBoxEx_TextChanged += txtTextQuery_EventTextBoxEx_TextChanged;
  28. this.txtTextQuery.Click += txtTextQuery_Click;
  29. this.txtTextQuery.KeyDown += txtTextQuery_KeyDown;
  30. }
  31. LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
  32. LYFZ.BLL.BLL_ErpMemberCard mcbll = new BLL.BLL_ErpMemberCard();
  33. LYFZ.BLL.BLL_SMSTemplates smsTemplates = new BLL.BLL_SMSTemplates();
  34. LYFZ.BLL.BLL_ErpCustomerGroup ctgpbll = new BLL.BLL_ErpCustomerGroup();
  35. LYFZ.BLL.BLL_ErpSystemConfigure scbll = new BLL.BLL_ErpSystemConfigure();
  36. LYFZ.BLL.BLL_ErpMemberCardPoints mcpsbll = new BLL.BLL_ErpMemberCardPoints();
  37. LYFZ.BLL.BLL_ErpMemberCardViceCard mcvbll = new BLL.BLL_ErpMemberCardViceCard();
  38. LYFZ.BLL.BLL_ErpMemberCardBackCash mcbcbll = new BLL.BLL_ErpMemberCardBackCash();
  39. LYFZ.BLL.BLL_ErpMemberCardOperateLOG mcopbll = new BLL.BLL_ErpMemberCardOperateLOG();
  40. LYFZ.BLL.BLL_ErpMemberCardPointsLOG mcpsLogbll = new BLL.BLL_ErpMemberCardPointsLOG();
  41. LYFZ.BLL.BLL_ErpMemberCardBackCashSet mcbcsetbll = new BLL.BLL_ErpMemberCardBackCashSet();
  42. LYFZ.BLL.BLL_ErpMemberCardAmountChangeLOG mcacbll = new BLL.BLL_ErpMemberCardAmountChangeLOG();
  43. string StrOrdNumber = "";
  44. decimal decBackCashCoefficient = 1;
  45. LYFZ.Model.Model_ErpMemberCardBackCashSet modelMcBcSet = null;
  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. void ViceCardConsumeSmallForm_Load(object sender, EventArgs e)
  56. {
  57. DataTable tbl = orbll.GetView_Custom("tb_ErpSystemConfigure", StrWhere: " Sconfig_Code = 'BackCashCoefficient'", ShowColumnName: "Sconfig_Value").Tables[0];
  58. if (tbl.Rows.Count > 0)
  59. { this.decBackCashCoefficient = Convert.ToDecimal(tbl.Rows[0]["Sconfig_Value"].ToString().Trim()); }
  60. else
  61. {
  62. LYFZ.Model.Model_ErpSystemConfigure model = new Model.Model_ErpSystemConfigure();
  63. model.Sconfig_Code = "BackCashCoefficient";
  64. model.Sconfig_Name = "返现系数";
  65. model.Sconfig_Value = "1";
  66. model.Sconfig_IsEnabled = true;
  67. model.Sconfig_Type = "";
  68. model.Sconfig_Remark = "返现系数(实现返现范围)";
  69. model.Sconfig_Order = 0;
  70. model.Sconfig_CreateDatetime = SDateTime.Now;
  71. model.Sconfig_CreateName = "";
  72. scbll.Add(model);
  73. }
  74. }
  75. /// <summary>
  76. /// 关闭
  77. /// </summary>
  78. /// <param name="sender"></param>
  79. /// <param name="e"></param>
  80. void btnClose_Click(object sender, EventArgs e)
  81. { this.Close(); }
  82. /// <summary>
  83. /// 使用
  84. /// </summary>
  85. /// <param name="sender"></param>
  86. /// <param name="e"></param>
  87. void btnUse_Click(object sender, EventArgs e)
  88. {
  89. if (this.txtViceCardNumber.Text.Trim() != "")
  90. {
  91. DateTime strTime = SDateTime.Now;
  92. string strUserID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  93. List<Helper.CommandInfo> clist = new List<Helper.CommandInfo>();
  94. LYFZ.Model.Model_ErpMemberCardViceCard modelViceCard = mcvbll.GetModel(Convert.ToInt32(this.txtViceCardNumber.Tag));
  95. decimal DecBackCashAmount = 0;
  96. Model.SMSParameters sparameters = new Model.SMSParameters();
  97. if (this.txtViceCardType.Text.Trim() == "返现副卡")
  98. {
  99. #region 返现副卡
  100. string StrRemark = "";
  101. bool IsValidity = LYFZ.BLL.OrderPayment_Member.VerifiedValidity(modelViceCard.Mvc_Number, LYFZ.EnumPublic.MemberFunctionAttribute.返现);
  102. if (!IsValidity)
  103. {
  104. StrRemark = "主卡返现有效期已过,不支持返现!";
  105. MessageBoxCustom.Show("对不起!您所持的副卡所属的主卡返现有效期已过期,即时副卡只作回收将无法返现!");
  106. }
  107. modelViceCard.Mvc_Status = "2";
  108. modelViceCard.Mvc_UpdateDateTime = strTime;
  109. modelViceCard.Mvc_UpdateName = strUserID;
  110. modelViceCard.Mvc_Remark = StrRemark;
  111. clist.Add(mcvbll.GetUpdateCommandInfo(modelViceCard));
  112. LYFZ.Model.Model_ErpMemberCardOperateLOG modelopLog = new Model.Model_ErpMemberCardOperateLOG();
  113. modelopLog.mcol_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
  114. modelopLog.mcol_Number = modelViceCard.Mvc_ViceNumber;
  115. modelopLog.mcol_Type = "4";
  116. modelopLog.mcol_Remark = StrRemark;
  117. modelopLog.mcol_CreateDatetime = strTime;
  118. modelopLog.mcol_CreateName = strUserID;
  119. clist.Add(mcopbll.GetAddCommandInfo(modelopLog));
  120. if (IsValidity)
  121. {
  122. if (this.txtBackCashAmount.Tag != null)
  123. {
  124. if (this.txtSeriesPrice.Text.Trim() == "")
  125. { MessageBoxCustom.Show("请选择您要返现订单!"); return; }
  126. if (Convert.ToDecimal(this.txtBackCashAmount.Tag) <= Convert.ToDecimal(this.txtSeriesPrice.Text))
  127. {
  128. if (this.modelMcBcSet == null)
  129. {
  130. if (MessageBoxCustom.Show("此返现副所属的主卡返现次数已经使用完,是否要回收副卡?", "温馨提示!", MessageBoxButtons.YesNo) == DialogResult.No)
  131. { return; }
  132. }
  133. else
  134. {
  135. this.modelMcBcSet.Mcb_IsSpending = 1;
  136. this.modelMcBcSet.Mcb_ViceNumber = modelViceCard.Mvc_ViceNumber;
  137. this.modelMcBcSet.Mcb_OrderNumber = this.StrOrdNumber.Trim();
  138. this.modelMcBcSet.Mcb_SpendingTime = strTime;
  139. this.modelMcBcSet.Mcb_UpdateDateTime = strTime;
  140. this.modelMcBcSet.Mcb_UpdateName = strUserID;
  141. LYFZ.Model.Model_ErpMemberCardBackCash modelBackCash = mcbcbll.GetModel("Mcbc_Number", modelViceCard.Mvc_Number);
  142. DataTable tbl = orbll.GetView_Custom("tb_ErpMemberCardBackCashSet", StrWhere: "Mcb_Number = '" + modelViceCard.Mvc_Number + "' and Mcb_CashBackGroup = '" + modelViceCard.Mvc_CashBackGroup + "'", ShowColumnName: "Mcb_CashBackAmount,Mcb_IsSpending").Tables[0];
  143. DataRow[] dtRow = tbl.Select("Mcb_IsSpending = '0'");
  144. if (dtRow.Length == 1)
  145. {
  146. for (int i = 0; i < tbl.Rows.Count; i++)
  147. {
  148. if (tbl.Rows[i]["Mcb_IsSpending"].ToString().Trim() == "1")
  149. {
  150. if (tbl.Rows[i]["Mcb_CashBackAmount"].ToString().Trim() != "")
  151. { DecBackCashAmount += Convert.ToDecimal(tbl.Rows[i]["Mcb_CashBackAmount"]); }
  152. }
  153. }
  154. DecBackCashAmount = Convert.ToDecimal(this.txtBackCashAmount.Text) - DecBackCashAmount;
  155. }
  156. else
  157. { DecBackCashAmount = (this.modelMcBcSet.Mcb_Proportion / 100) * Convert.ToDecimal(this.txtBackCashAmount.Text); }
  158. List<LYFZ.Model.Model_ErpMemberCardViceCard> mlist = mcvbll.GetModelList("Mvc_Number = '" + modelViceCard.Mvc_Number + "' and Mvc_ViceCardType = '返现副卡' and Mvc_CashBackGroup = '" + modelViceCard.Mvc_CashBackGroup + "' and Mvc_Status = '1'");
  159. if (mlist.Count == 1)
  160. {
  161. modelBackCash.Mcbc_PackagesMoney = 0;
  162. modelBackCash.Mcbc_CashBackNumber = 0;
  163. modelBackCash.Mcbc_CashBackProportion = "";
  164. }
  165. modelBackCash.Mcbc_AlreadyCashBack += DecBackCashAmount;
  166. modelBackCash.Mcbc_UpdateDateTime = strTime;
  167. modelBackCash.Mcbc_UpdateName = strUserID;
  168. clist.Add(mcbcbll.GetUpdateCommandInfo(modelBackCash));
  169. this.modelMcBcSet.Mcb_CashBackAmount = DecBackCashAmount;
  170. clist.Add(mcbcsetbll.GetUpdateCommandInfo(this.modelMcBcSet));
  171. }
  172. }
  173. else
  174. { MessageBoxCustom.Show("订单套系不在返现套系范围内!"); return; }
  175. }
  176. }
  177. #endregion
  178. }
  179. else if (this.txtViceCardType.Text.Trim() == "积分副卡")
  180. {
  181. if (string.IsNullOrEmpty(this.StrOrdNumber))
  182. { MessageBoxCustom.Show("请选择使用的订单!"); return; }
  183. clist.AddRange(LYFZ.Software.MainBusiness.MembershipManage.MemberPublicClass.ViceCardUse_MainCardPoints(modelViceCard.Mvc_ViceNumber, ref sparameters, StrOrdNumber: this.StrOrdNumber, strTime: strTime));
  184. }
  185. if (clist.Count > 0)
  186. {
  187. if (MessageBoxCustom.Show("是否要使用?", "温馨提示!", MessageBoxButtons.YesNo) == DialogResult.No)
  188. { return; }
  189. if (LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist) <= 0)
  190. { MessageBoxCustom.Show("使用失败!"); }
  191. else
  192. {
  193. System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(delegate()
  194. {
  195. DataTable dt = orbll.GetView_Custom("tb_ErpMemberCard", StrWhere: "Mc_Number = '" + modelViceCard.Mvc_Number + "' And Mc_CradNumber != ''", ShowColumnName: "Mc_CustomerNumber,Mc_CradNumber").Tables[0];
  196. if (dt.Rows.Count > 0)
  197. {
  198. if (this.txtViceCardType.Text.Trim() == "返现副卡")
  199. {
  200. //XXX 为客户姓名;XXN 为会员卡号;TEXT 为获得返现金内容(如:本次某某朋友为您返现金5000元); XXT 为获得返现金时间
  201. sparameters = new Model.SMSParameters();
  202. sparameters.CurrentSpendingMemberID = dt.Rows[0]["Mc_CustomerNumber"].ToString().Trim();
  203. sparameters.CardNumber = dt.Rows[0]["Mc_CradNumber"].ToString().Trim();
  204. sparameters.XXT = strTime;
  205. sparameters.TEXT = "您朋友持返现副卡" + this.txtInputViceCard.Text.Trim() + "来订单,获得返现" + DecBackCashAmount + "元";
  206. sparameters.ReferralsBonusPoints = 0;
  207. try
  208. { smsTemplates.GenerateEventSMS(EnumPublic.SmsSendEvent.会员返现卡获得返现金后X分钟, sparameters); }
  209. catch { }
  210. }
  211. else
  212. {
  213. try
  214. { smsTemplates.GenerateEventSMS(EnumPublic.SmsSendEvent.当积分达到或超过X分时, sparameters); }
  215. catch { }
  216. try
  217. { smsTemplates.GenerateEventSMS(EnumPublic.SmsSendEvent.当积分接近X的百分之80时, sparameters); }
  218. catch { }
  219. try
  220. {
  221. if (!string.IsNullOrEmpty(sparameters.TEXT))
  222. { smsTemplates.GenerateEventSMS(EnumPublic.SmsSendEvent.会员积分变动后X分钟, sparameters); }
  223. }
  224. catch { }
  225. //DataTable tbl = orbll.GetView_Custom("tempTB_AggregationCustomer", StrWhere: "GP_OrderNumber = '" + this.StrOrdNumber + "'", ShowColumnName: "M_Cus_CustomerNumber").Tables[0];
  226. //if (tbl.Rows.Count > 0)
  227. //{
  228. // int IntPointsIntr = LYFZ.BLL.BLL_ErpMemberCard.GetPoints_AgoPeriod(LYFZ.EnumPublic.MemberPointsType.txtReferral_RMB, Convert.ToDecimal(this.txtSeriesPrice.Text), LYFZ.BLL.OrderPayment_Member.StrInfoID, tbl.Rows[0]["M_Cus_CustomerNumber"].ToString().Trim());
  229. // sparameters.CurrentSpendingMemberID = dt.Rows[0]["Mc_CustomerNumber"].ToString().Trim();
  230. // sparameters.CardNumber = dt.Rows[0]["Mc_CradNumber"].ToString().Trim();
  231. // sparameters.XXT = strTime;
  232. // sparameters.TEXT = "您朋友持积分副卡" + modelViceCard.Mvc_ViceCardNumber + "来订单,获得" + IntPointsIntr + "积分";
  233. // sparameters.ReferralsBonusPoints = IntPointsIntr;
  234. // try
  235. // { smsTemplates.GenerateEventSMS(EnumPublic.SmsSendEvent.会员返现卡获得返现金后X分钟, sparameters); }
  236. // catch { }
  237. //}
  238. }
  239. }
  240. }));
  241. t.Start();
  242. MessageBoxCustom.Show("使用完成!");
  243. this.GetClearData();
  244. }
  245. }
  246. }
  247. else
  248. { MessageBoxCustom.Show("请输入你要消费的副卡号"); }
  249. }
  250. /// <summary>
  251. /// 副卡查找
  252. /// </summary>
  253. /// <param name="sender"></param>
  254. /// <param name="e"></param>
  255. void btnFind_Click(object sender, EventArgs e)
  256. { this.GetViceCardData(); }
  257. /// <summary>
  258. /// 订单查找
  259. /// </summary>
  260. /// <param name="sender"></param>
  261. /// <param name="e"></param>
  262. void btnOrderFind_Click(object sender, EventArgs e)
  263. {
  264. LYFZ.Software.MainBusiness.CameraControlBook.PublicClass.InputQueryClient(this.txtTextQuery, this.lstTextQuery, 180);
  265. }
  266. /// <summary>
  267. /// 副卡输入回车
  268. /// </summary>
  269. /// <param name="sender"></param>
  270. /// <param name="e"></param>
  271. void txtInputViceCard_KeyDown(object sender, KeyEventArgs e)
  272. {
  273. if (e.KeyCode == Keys.Enter)
  274. { this.GetViceCardData(); }
  275. }
  276. /// <summary>
  277. /// 副卡输入离开事件
  278. /// </summary>
  279. /// <param name="sender"></param>
  280. /// <param name="e"></param>
  281. void txtInputViceCard_Leave(object sender, EventArgs e)
  282. {
  283. //this.GetViceCardData();
  284. }
  285. /// <summary>
  286. /// 获取副卡资料
  287. /// </summary>
  288. void GetViceCardData()
  289. {
  290. if (this.txtInputViceCard.Text.Trim() != "")
  291. {
  292. DataTable tbl = orbll.GetView_Custom("tb_ErpMemberCardViceCard left join tb_ErpMemberCard on Mc_Number = Mvc_Number left join tb_ErpCustomer on Cus_CustomerNumber = Mc_CustomerNumber left join tb_ErpMemberCardBackCash on Mc_Number = Mcbc_Number", StrWhere: "Mvc_ViceCardNumber = '" + this.txtInputViceCard.Text.Trim() + "' and Mvc_Status = '1'", ShowColumnName: "tb_ErpMemberCardViceCard.ID,Mvc_Number,Mvc_ViceCardNumber,Mvc_ViceCardType,Cus_Name,Cus_Telephone,Mcbc_PackagesMoney").Tables[0];
  293. if (tbl.Rows.Count > 0)
  294. {
  295. this.txtViceCardNumber.Text = tbl.Rows[0]["Mvc_ViceCardNumber"].ToString().Trim();
  296. this.txtViceCardNumber.Tag = tbl.Rows[0]["ID"].ToString().Trim();
  297. this.txtViceCardType.Text = tbl.Rows[0]["Mvc_ViceCardType"].ToString().Trim();
  298. this.txtHolder.Text = tbl.Rows[0]["Cus_Name"].ToString().Trim();
  299. if (tbl.Rows[0]["Mvc_ViceCardType"].ToString().Trim() == "返现副卡")
  300. {
  301. this.txtBackCashAmount.Text = tbl.Rows[0]["Mcbc_PackagesMoney"].ToString().Trim();
  302. this.txtBackCashAmount.Tag = Convert.ToDecimal(tbl.Rows[0]["Mcbc_PackagesMoney"]) * decBackCashCoefficient;
  303. this.panelBackCashAmount.Visible = true;
  304. List<LYFZ.Model.Model_ErpMemberCardBackCashSet> mlistBackCashSet = mcbcsetbll.GetModelList("Mcb_Number = '" + tbl.Rows[0]["Mvc_Number"].ToString().Trim() + "' and (Mcb_ViceNumber = '' or Mcb_ViceNumber is NULL)");
  305. if (mlistBackCashSet.Count > 0)
  306. { this.modelMcBcSet = mlistBackCashSet[0]; }
  307. if (!this.panelEx1.Visible)
  308. {
  309. this.panelEx1.Visible = true;
  310. this.Height += this.panelEx1.Height;
  311. }
  312. }
  313. else if (tbl.Rows[0]["Mvc_ViceCardType"].ToString().Trim() == "积分副卡")
  314. { this.panelBackCashAmount.Visible = false; }
  315. else
  316. {
  317. this.panelBackCashAmount.Visible = false;
  318. this.txtBackCashAmount.Tag = null;
  319. this.modelMcBcSet = null;
  320. if (this.panelEx1.Visible)
  321. {
  322. this.panelEx1.Visible = false;
  323. this.Height -= this.panelEx1.Height;
  324. }
  325. }
  326. }
  327. else
  328. {
  329. MessageBoxCustom.Show("未找到副卡'" + this.txtInputViceCard.Text.Trim() + "',或已回收,请核对!");
  330. this.GetClearData();
  331. return;
  332. }
  333. }
  334. else
  335. { this.GetClearData(); }
  336. }
  337. /// <summary>
  338. /// 清空数据
  339. /// </summary>
  340. void GetClearData()
  341. {
  342. this.txtViceCardNumber.Text = "";
  343. this.txtViceCardNumber.Tag = "";
  344. this.txtViceCardType.Text = "";
  345. this.txtHolder.Text = "";
  346. this.txtBackCashAmount.Text = "";
  347. this.txtBackCashAmount.Tag = null;
  348. this.modelMcBcSet = null;
  349. this.txtOrderNumber.Text = "";
  350. this.txtSeriesName.Text = "";
  351. this.txtOrdersPerson.Text = "";
  352. this.txtSeriesPrice.Text = "";
  353. this.txtManName.Text = "";
  354. this.txtWomanName.Text = "";
  355. this.txtInputViceCard.Text = "";
  356. this.txtTextQuery.Text = "";
  357. this.StrOrdNumber = "";
  358. this.lstTextQuery.Visible = false;
  359. }
  360. /// <summary>
  361. /// 列表事件双击
  362. /// </summary>
  363. /// <param name="sender"></param>
  364. /// <param name="e"></param>
  365. void lstTextQuery_MouseDoubleClick(object sender, MouseEventArgs e)
  366. {
  367. if (this.lstTextQuery.Items.Count > 0)
  368. {
  369. if (((ListItem)this.lstTextQuery.SelectedItem) != null)
  370. {
  371. if (string.IsNullOrEmpty(this.txtViceCardNumber.Text.Trim()) || this.txtViceCardNumber.Tag == null)
  372. { MessageBoxCustom.Show("请先输入副卡"); return; }
  373. this.GetOrdNumberGetData(((ListItem)this.lstTextQuery.SelectedItem).StrValue.ToString().Trim());
  374. this.txtTextQuery.Text = ((ListItem)this.lstTextQuery.SelectedItem).StrText;
  375. }
  376. }
  377. this.lstTextQuery.Visible = false;
  378. }
  379. /// <summary>
  380. /// 回车
  381. /// </summary>
  382. /// <param name="sender"></param>
  383. /// <param name="e"></param>
  384. void lstTextQuery_KeyDown(object sender, KeyEventArgs e)
  385. {
  386. if (e.KeyCode == Keys.Enter)
  387. { this.lstTextQuery_MouseDoubleClick(this, null); }
  388. }
  389. /// <summary>
  390. /// 列表失去焦点
  391. /// </summary>
  392. /// <param name="sender"></param>
  393. /// <param name="e"></param>
  394. void panelEx1_Click(object sender, EventArgs e)
  395. { this.lstTextQuery.Visible = false; }
  396. /// <summary>
  397. /// 列表失去焦点
  398. /// </summary>
  399. /// <param name="sender"></param>
  400. /// <param name="e"></param>
  401. void panelEx8_Click(object sender, EventArgs e)
  402. { this.lstTextQuery.Visible = false; }
  403. /// <summary>
  404. /// 输入值变化
  405. /// </summary>
  406. /// <param name="sender"></param>
  407. /// <param name="e"></param>
  408. void txtTextQuery_EventTextBoxEx_TextChanged(object sender, EventArgs e)
  409. {
  410. if (this.txtTextQuery.Text.Trim() == "")
  411. { this.lstTextQuery.Visible = true; }
  412. }
  413. /// <summary>
  414. /// 点击输入框
  415. /// </summary>
  416. /// <param name="sender"></param>
  417. /// <param name="e"></param>
  418. void txtTextQuery_Click(object sender, EventArgs e)
  419. { this.txtTextQuery_EventTextBoxEx_TextChanged(null, null); }
  420. /// <summary>
  421. /// 按键盘上的下健时
  422. /// </summary>
  423. /// <param name="sender"></param>
  424. /// <param name="e"></param>
  425. void txtTextQuery_KeyDown(object sender, KeyEventArgs e)
  426. {
  427. if (e.KeyCode == Keys.Down || e.KeyCode == Keys.Up)
  428. { this.lstTextQuery.SelectedIndex = 0; this.lstTextQuery.Focus(); }
  429. else if (e.KeyCode == Keys.Enter)
  430. { this.btnOrderFind_Click(this, null); }
  431. }
  432. /// <summary>
  433. /// 查询获取订单信息
  434. /// </summary>
  435. /// <param name="StrNumber"></param>
  436. void GetOrdNumberGetData(string OrdNumber)
  437. {
  438. string strViewName = "tb_ErpOrder left join dbo.tempTB_AggregationCustomer on Ord_Number = GP_OrderNumber";
  439. 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";
  440. DataTable tbl = orbll.GetView_Custom(strViewName, StrWhere: "Ord_Number = '" + OrdNumber + "'", filedOrder: "Ord_Number ASC", ShowColumnName: strColumnName).Tables[0];
  441. if (tbl.Rows.Count > 0)
  442. {
  443. this.txtOrderNumber.Text = tbl.Rows[0]["ShowOrdNumber"].ToString().Trim();
  444. this.txtSeriesName.Text = tbl.Rows[0]["Ord_SeriesName"].ToString().Trim();
  445. this.txtOrdersPerson.Text = tbl.Rows[0]["OrdPe_OrdersPerson"].ToString().Trim();
  446. this.txtSeriesPrice.Text = tbl.Rows[0]["Ord_SeriesPrice"].ToString().Trim();
  447. string[] StrNameArray = tbl.Rows[0]["Cus_Name"].ToString().Trim().Split('/');
  448. string[] StrSexArray = tbl.Rows[0]["Cus_Sex_cs"].ToString().Trim().Split('/');
  449. if (tbl.Rows[0]["Ord_Type"].ToString().Trim() == "0")
  450. {
  451. if (StrNameArray.Length > 1)
  452. {
  453. if (StrSexArray[0].Trim() == "男")
  454. { this.lblName1.Text = "男宾姓名:"; }
  455. else if (StrSexArray[0].Trim() == "女")
  456. { this.lblName2.Text = "女宾姓名:"; }
  457. this.txtManName.Text = StrNameArray[0].Trim();
  458. if (StrSexArray[1].Trim() == "男")
  459. { this.lblName1.Text = "男宾姓名:"; }
  460. else if (StrSexArray[1].Trim() == "女")
  461. { this.lblName2.Text = "女宾姓名:"; }
  462. this.txtWomanName.Text = StrNameArray[1].Trim();
  463. }
  464. else
  465. {
  466. this.lblName1.Text = "男宾姓名:";
  467. this.lblName2.Text = "女宾姓名:";
  468. if (StrSexArray[0].Trim() == "男")
  469. { this.txtManName.Text = StrNameArray[0].Trim(); }
  470. else if (StrSexArray[0].Trim() == "女")
  471. { this.txtWomanName.Text = StrNameArray[0].Trim(); }
  472. }
  473. this.lblName1.Location = new Point(15, this.lblName1.Location.Y);
  474. this.lblName2.Location = new Point(218, this.lblName2.Location.Y);
  475. }
  476. else if (tbl.Rows[0]["Ord_Type"].ToString().Trim() == "1")
  477. {
  478. this.lblName1.Text = "宝贝姓名:";
  479. this.lblName2.Text = "家长姓名:";
  480. this.txtManName.Text = StrNameArray[0].Trim();
  481. this.txtWomanName.Text = StrNameArray[1].Trim();
  482. this.lblName1.Location = new Point(26, this.lblName1.Location.Y);
  483. this.lblName2.Location = new Point(229, this.lblName2.Location.Y);
  484. }
  485. else if (tbl.Rows[0]["Ord_Type"].ToString().Trim() == "2" || tbl.Rows[0]["Ord_Type"].ToString().Trim() == "3")
  486. {
  487. this.lblName1.Text = "客户姓名:";
  488. this.lblName2.Text = "客户性别:";
  489. this.txtManName.Text = StrNameArray[0].Trim();
  490. this.txtWomanName.Text = StrSexArray[0].Trim();
  491. this.lblName1.Location = new Point(26, this.lblName1.Location.Y);
  492. this.lblName2.Location = new Point(229, this.lblName2.Location.Y);
  493. }
  494. this.btnUse.Enabled = true;
  495. if (this.txtViceCardType.Text.Trim() == "积分副卡")
  496. {
  497. if (!LYFZ.BLL.OrderPayment_Member.IsFriendIntroducedPoints(OrdNumber))
  498. { this.btnUse.Enabled = false; MessageBoxCustom.Show("此订单已经使用朋友转介绍过,不能再使用!"); return; }
  499. }
  500. else if (this.txtViceCardType.Text.Trim() == "返现副卡")
  501. {
  502. string ExecuteSql = orbll.GetView_CustomReturnExecuteSql("tb_ErpMemberCardBackCashSet", StrWhere: "Mcb_OrderNumber = '" + OrdNumber + "'", ShowColumnName: "ID");
  503. DataSet dtSet = orbll.GetView_Custom(ExecuteSql);
  504. if (dtSet.Tables["ds"].Rows.Count > 0)
  505. { this.btnUse.Enabled = false; MessageBoxCustom.Show("此订单已经返现过,不能再使用!"); return; }
  506. }
  507. this.StrOrdNumber = OrdNumber;
  508. }
  509. }
  510. }
  511. }