UCDressCustomer.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Windows.Forms;
  7. namespace LYFZ.Software.MainBusiness.Dresses.DressView
  8. {
  9. public class UCDressCustomer : LYFZ.Software.UI.Dresses.DressView.UCDressCustomer
  10. {
  11. LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
  12. LYFZ.BLL.BLL_ErpCustomer ctbll = new BLL.BLL_ErpCustomer();
  13. public UCDressCustomer()
  14. {
  15. this.txtClientName.KeyDown += txtClientName_KeyDown;
  16. this.txtClientName.KeyPress += txtClientName_KeyPress;
  17. this.txtClientFixedPhone.KeyPress += txtClientFixedPhone_KeyPress;
  18. this.txtClientQQ.KeyPress += txtClientQQ_KeyPress;
  19. this.txtClientWorkUnit.KeyPress += txtClientWorkUnit_KeyPress;
  20. this.btnDial.Click += btnDial_Click;
  21. this.btnQQCall.Click += btnQQCall_Click;
  22. this.btnClientSelect.Click += btnClientSelect_Click;
  23. this.btn_CustomerEdit.Click += btn_CustomerEdit_Click;
  24. btn_CustomerEdit.Visible = false;
  25. }
  26. /// <summary>
  27. /// 保存数据控制
  28. /// </summary>
  29. /// <returns></returns>
  30. public LYFZ.Command.Result SaveCustomerData(ref string StrClientName, ref string StrClientTelephone,int indx=1)
  31. {
  32. #region 客户
  33. LYFZ.Command.Result<List<Helper.CommandInfo>> resultSQL = new Command.Result<List<Helper.CommandInfo>>();
  34. List<Helper.CommandInfo> clist = new List<Helper.CommandInfo>();
  35. string StrTelephone = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.MaskedTextBoxExGetText(this.txtClientTelephone);
  36. string StrClientNumber = "";
  37. if (!string.IsNullOrEmpty(StrClientName))
  38. {
  39. StrClientName += "/";
  40. }
  41. if (!string.IsNullOrEmpty(StrClientTelephone))
  42. {
  43. StrClientTelephone += "/";
  44. }
  45. StrClientName += this.txtClientName.Text.ToString().Trim();
  46. StrClientTelephone += this.txtClientTelephone.Text.ToString().Trim().Replace(" ", "");
  47. if (this.txtClientName.Tag != null)
  48. {
  49. StrClientNumber = this.txtClientName.Tag.ToString().Trim();
  50. return new Command.Result<List<Helper.CommandInfo>>()
  51. {
  52. Status = true,
  53. StatusMsg = StrClientNumber
  54. };
  55. }
  56. else
  57. {
  58. if (ctbll.Exists("Cus_Telephone", StrTelephone) == true)//判断手机存在
  59. {
  60. MessageBoxCustom.Show("客户手机已经存在");
  61. return new Command.Result<List<Helper.CommandInfo>>()
  62. {
  63. Status = false,
  64. StatusMsg = "客户手机已经存在"
  65. };
  66. }
  67. LYFZ.Model.Model_ErpCustomer model = new Model.Model_ErpCustomer();
  68. model.Cus_CustomerNumber = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime().ToString("yyyyMMddHHmmssfff") + indx.ToString();//获取新编号
  69. model.Cus_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
  70. model.Cus_CustomizeNumber = "";
  71. model.Cus_Type = "订单客户";
  72. model.Cus_ServiceType = "Clothing";
  73. model.Cus_Name = this.txtClientName.Text.ToString().Trim();
  74. model.Cus_Telephone = this.txtClientTelephone.Text.ToString().Trim().Replace(" ","");
  75. model.Cus_QQ = this.txtClientQQ.Text.ToString().Trim();
  76. model.Cus_Address = this.txtClientAddress.Text.ToString().Trim();
  77. model.Cus_WorkUnit = this.txtClientWorkUnit.Text.ToString().Trim();
  78. model.Cus_Birthday = this.txtClientBirthday.StrValue.Trim();
  79. if (this.chkClientBirthdayLunar.Checked == true)
  80. { model.Cus_BirthdayLunar = "1"; }
  81. else
  82. { model.Cus_BirthdayLunar = "0"; }
  83. model.Cus_DayForMarriage = this.txtClientDayForMarriage.StrValue.ToString();
  84. if (this.chkClientDayForMarriageLunar.Checked == true)
  85. { model.Cus_DayForMarriageLunar = "1"; }
  86. else
  87. { model.Cus_DayForMarriageLunar = "0"; }
  88. model.Cus_CreateDateTime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
  89. model.Cus_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  90. clist.Add(ctbll.GetAddCommandInfo(model));
  91. StrClientNumber = model.Cus_CustomerNumber;
  92. return new Command.Result<List<Helper.CommandInfo>>()
  93. {
  94. Status = true,
  95. StatusMsg = StrClientNumber,
  96. clist = clist
  97. };
  98. }
  99. #endregion
  100. }
  101. public string StrOrderNumber { get; set; }
  102. public bool IsUpdateClientData = true;
  103. public void ReBindOrderNumber()
  104. {
  105. if (!string.IsNullOrEmpty(StrOrderNumber))
  106. {
  107. this.btnClientSelect.Visible = false;
  108. this.txtClientName.Width = this.txtClientQQ.Width;
  109. btn_CustomerEdit.Visible = false;
  110. //buttonForm1.Visible = false;
  111. }
  112. }
  113. public LYFZ.Command.Result CheckCustomerData()
  114. {
  115. if (string.IsNullOrEmpty(this.txtClientName.Text.Trim()))
  116. {
  117. MessageBoxCustom.Show("客户名称不能为空!");
  118. return new LYFZ.Command.Result()
  119. {
  120. Status = false,
  121. StatusMsg = "客户名称不能为空!"
  122. };
  123. }
  124. string StrTelephone = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.MaskedTextBoxExGetText(this.txtClientTelephone);
  125. if (string.IsNullOrEmpty(StrTelephone))
  126. {
  127. MessageBoxCustom.Show("客户手机号码不能为空!");
  128. return new LYFZ.Command.Result()
  129. {
  130. Status = false,
  131. StatusMsg = "客户手机号码不能为空!"
  132. };
  133. }
  134. else
  135. {
  136. if (StrTelephone.Length != 11)
  137. {
  138. MessageBoxCustom.Show("客户手机号码长度不足11位!");
  139. return new LYFZ.Command.Result()
  140. {
  141. Status = false,
  142. StatusMsg = "客户手机号码长度不足11位!"
  143. };
  144. }
  145. }
  146. int intMasse = this.txtClientBirthday.CheckDateValue(this.txtClientBirthday, this.chkClientBirthdayLunar);
  147. if (intMasse == 1)
  148. {
  149. MessageBoxCustom.Show("生日日期日期格式输入错误");
  150. return new LYFZ.Command.Result()
  151. {
  152. Status = false,
  153. StatusMsg = "生日日期日期格式输入错误"
  154. };
  155. }
  156. else if (intMasse == 2)
  157. {
  158. MessageBoxCustom.Show("生日日期:" + this.txtClientBirthday.StrValue.Trim() + "不是公历日期,若要保存请勾上农历");
  159. return new LYFZ.Command.Result()
  160. {
  161. Status = false,
  162. StatusMsg = "生日日期:" + this.txtClientBirthday.StrValue.Trim() + "不是公历日期,若要保存请勾上农历"
  163. };
  164. }
  165. intMasse = this.txtClientDayForMarriage.CheckDateValue(this.txtClientDayForMarriage, this.chkClientDayForMarriageLunar);
  166. if (intMasse == 1)
  167. {
  168. MessageBoxCustom.Show("婚期日期日期格式输入错误");
  169. return new LYFZ.Command.Result()
  170. {
  171. Status = false,
  172. StatusMsg = "婚期日期日期格式输入错误"
  173. };
  174. }
  175. else if (intMasse == 2)
  176. {
  177. MessageBoxCustom.Show("婚期日期:" + this.txtClientDayForMarriage.StrValue.Trim() + "不是公历日期,若要保存请勾上农历");
  178. return new LYFZ.Command.Result()
  179. {
  180. Status = false,
  181. StatusMsg = "婚期日期:" + this.txtClientDayForMarriage.StrValue.Trim() + "不是公历日期,若要保存请勾上农历"
  182. };
  183. }
  184. return new LYFZ.Command.Result()
  185. {
  186. Status = true
  187. };
  188. }
  189. /// <summary>
  190. /// 清空选择的客户
  191. /// </summary>
  192. /// <param name="sender"></param>
  193. /// <param name="e"></param>
  194. void txtClientName_KeyDown(object sender, KeyEventArgs e)
  195. {
  196. if (e.KeyCode == Keys.Back)
  197. {
  198. if (this.txtClientName.Tag != null && string.IsNullOrEmpty(this.StrOrderNumber) && this.IsUpdateClientData)
  199. { this.ClearClientData(); }
  200. }
  201. }
  202. /// <summary>
  203. /// 客户工作单位输入限制
  204. /// </summary>
  205. /// <param name="sender"></param>
  206. /// <param name="e"></param>
  207. void txtClientWorkUnit_KeyPress(object sender, KeyPressEventArgs e)
  208. {
  209. if (Convert.ToString(e.KeyChar) == "-")
  210. { }
  211. else if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar) && !Char.IsLetterOrDigit(e.KeyChar))
  212. { e.Handled = true; }
  213. }
  214. /// <summary>
  215. /// 客户姓名输入限制
  216. /// </summary>
  217. /// <param name="sender"></param>
  218. /// <param name="e"></param>
  219. void txtClientName_KeyPress(object sender, KeyPressEventArgs e)
  220. {
  221. if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar) && !Char.IsLetterOrDigit(e.KeyChar) && e.KeyChar != '_' && e.KeyChar != ' ')
  222. { e.Handled = true; }
  223. }
  224. /// <summary>
  225. /// 客户固定电话输入限制
  226. /// </summary>
  227. /// <param name="sender"></param>
  228. /// <param name="e"></param>
  229. void txtClientFixedPhone_KeyPress(object sender, KeyPressEventArgs e)
  230. {
  231. if (Convert.ToString(e.KeyChar) == "-")
  232. { }
  233. else if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar))
  234. { e.Handled = true; }
  235. }
  236. /// <summary>
  237. /// 客户QQ输入限制
  238. /// </summary>
  239. /// <param name="sender"></param>
  240. /// <param name="e"></param>
  241. void txtClientQQ_KeyPress(object sender, KeyPressEventArgs e)
  242. {
  243. if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar))
  244. { e.Handled = true; }
  245. }
  246. /// <summary>
  247. /// 清空客户信息
  248. /// </summary>
  249. void ClearClientData()
  250. {
  251. this.txtClientName.Text = "";
  252. this.txtClientName.Tag = null;
  253. this.txtClientTelephone.Text = "";
  254. this.txtClientFixedPhone.Text = "";
  255. this.txtClientQQ.Text = "";
  256. this.txtClientAddress.Text = "";
  257. this.txtClientWorkUnit.Text = "";
  258. this.txtClientBirthday.Text = "";
  259. this.chkClientBirthdayLunar.Checked = false;
  260. this.txtClientDayForMarriage.Text = "";
  261. this.chkClientDayForMarriageLunar.Checked = false;
  262. this.txtClientName.ReadOnly = false;
  263. this.txtClientTelephone.ReadOnly = false;
  264. this.txtClientQQ.ReadOnly = false;
  265. this.txtClientAddress.ReadOnly = false;
  266. this.txtClientWorkUnit.ReadOnly = false;
  267. this.txtClientBirthday.ReadOnly = false;
  268. this.chkClientBirthdayLunar.Enabled = true;
  269. this.txtClientDayForMarriage.ReadOnly = false;
  270. this.chkClientDayForMarriageLunar.Enabled = true;
  271. this.txtClientFixedPhone.ReadOnly = false;
  272. btn_CustomerEdit.Visible = false;
  273. btn_CustomerEdit.Text = " 编辑";
  274. //buttonForm1.Visible = false;
  275. }
  276. /// <summary>
  277. /// 拨打电话
  278. /// </summary>
  279. /// <param name="sender"></param>
  280. /// <param name="e"></param>
  281. void btnDial_Click(object sender, EventArgs e)
  282. {
  283. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.PhoneCall(LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.MaskedTextBoxExGetText(this.txtClientTelephone));
  284. }
  285. /// <summary>
  286. /// QQ呼叫
  287. /// </summary>
  288. /// <param name="sender"></param>
  289. /// <param name="e"></param>
  290. void btnQQCall_Click(object sender, EventArgs e)
  291. {
  292. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.QQCall(this.txtClientQQ.Text.Trim());
  293. }
  294. /// <summary>
  295. /// 选择客户
  296. /// </summary>
  297. /// <param name="sender"></param>
  298. /// <param name="e"></param>
  299. void btnClientSelect_Click(object sender, EventArgs e)
  300. {
  301. LYFZ.Software.MainBusiness.Dresses.DressManagement.FrmCusSelect frm = new DressManagement.FrmCusSelect();
  302. frm.ShowDialog();
  303. if (!string.IsNullOrEmpty(frm.StrClientNumber))
  304. { this.GetClientData(frm.StrClientNumber); }
  305. }
  306. /// <summary>
  307. /// 获取客户资料
  308. /// </summary>
  309. /// <param name="StrClientNumber"></param>
  310. /// <returns></returns>
  311. public void GetClientData(string StrClientNumber)
  312. {
  313. if (!string.IsNullOrEmpty(StrClientNumber))
  314. {
  315. DataTable dt = orbll.GetView_Custom("tb_ErpCustomer", StrWhere: "Cus_CustomerNumber='" + StrClientNumber + "'", ShowColumnName: "Cus_Name,Cus_CustomerNumber,Cus_Telephone,Cus_FixedPhone,Cus_QQ,Cus_Address,Cus_WorkUnit,Cus_Birthday,Cus_BirthdayLunar,Cus_DayForMarriage,Cus_DayForMarriageLunar").Tables[0];
  316. if (dt.Rows.Count > 0)
  317. {
  318. this.txtClientName.Text = dt.Rows[0]["Cus_Name"].ToString().Trim();
  319. this.txtClientName.Tag = dt.Rows[0]["Cus_CustomerNumber"].ToString().Trim();
  320. this.txtClientTelephone.Text = dt.Rows[0]["Cus_Telephone"].ToString().Trim();
  321. this.txtClientFixedPhone.Text = dt.Rows[0]["Cus_FixedPhone"].ToString().Trim();
  322. this.txtClientQQ.Text = dt.Rows[0]["Cus_QQ"].ToString().Trim();
  323. this.txtClientAddress.Text = dt.Rows[0]["Cus_Address"].ToString().Trim();
  324. this.txtClientWorkUnit.Text = dt.Rows[0]["Cus_WorkUnit"].ToString().Trim();
  325. this.txtClientBirthday.Text = dt.Rows[0]["Cus_Birthday"].ToString().Trim();
  326. if (dt.Rows[0]["Cus_BirthdayLunar"].ToString().Trim() == "1")
  327. { this.chkClientBirthdayLunar.Checked = true; }
  328. else
  329. { this.chkClientBirthdayLunar.Checked = false; }
  330. this.txtClientDayForMarriage.Text = dt.Rows[0]["Cus_DayForMarriage"].ToString().Trim();
  331. if (dt.Rows[0]["Cus_DayForMarriageLunar"].ToString().Trim() == "1")
  332. { this.chkClientDayForMarriageLunar.Checked = true; }
  333. else
  334. { this.chkClientDayForMarriageLunar.Checked = false; }
  335. this.txtClientName.ReadOnly = true;
  336. this.txtClientTelephone.ReadOnly = true;
  337. this.txtClientQQ.ReadOnly = true;
  338. this.txtClientAddress.ReadOnly = true;
  339. this.txtClientWorkUnit.ReadOnly = true;
  340. this.txtClientBirthday.ReadOnly = true;
  341. this.chkClientBirthdayLunar.Enabled = false;
  342. this.txtClientDayForMarriage.ReadOnly = true;
  343. this.chkClientDayForMarriageLunar.Enabled = false;
  344. this.txtClientFixedPhone.ReadOnly = true;
  345. btn_CustomerEdit.Visible = true;
  346. //buttonForm1.Visible = true;
  347. }
  348. }
  349. }
  350. void btn_CustomerEdit_Click(object sender, EventArgs e)
  351. {
  352. LYFZ.ComponentLibrary.ButtonEx btnEx = (LYFZ.ComponentLibrary.ButtonEx)sender;
  353. if (btnEx.Text.Trim() == "编辑")
  354. {
  355. this.SetCustomerEditEnable(false);
  356. btnEx.Text = " 保存";
  357. }
  358. else if (btnEx.Text.Trim() == "保存")
  359. {
  360. if (MessageBoxCustom.Show("如果修改客户信息,当前客户所关联的订单客户信息也会有变化\n是否继续?", "提示", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
  361. {
  362. LYFZ.Model.Model_ErpCustomer model = new Model.Model_ErpCustomer();
  363. BLL.BLL_ErpCustomer customerBll = new BLL.BLL_ErpCustomer();
  364. model = customerBll.GetModel("Cus_CustomerNumber", this.txtClientName.Tag.ToString().Trim());
  365. model.Cus_Name = this.txtClientName.Text.ToString().Trim();
  366. model.Cus_Telephone = this.txtClientTelephone.Text.ToString().Trim();
  367. model.Cus_QQ = this.txtClientQQ.Text.ToString().Trim();
  368. model.Cus_Address = this.txtClientAddress.Text.ToString().Trim();
  369. model.Cus_WorkUnit = this.txtClientWorkUnit.Text.ToString().Trim();
  370. model.Cus_Birthday = this.txtClientBirthday.StrValue.Trim();
  371. if (this.chkClientBirthdayLunar.Checked == true)
  372. { model.Cus_BirthdayLunar = "1"; }
  373. else
  374. { model.Cus_BirthdayLunar = "0"; }
  375. model.Cus_DayForMarriage = this.txtClientDayForMarriage.StrValue.ToString();
  376. if (this.chkClientDayForMarriageLunar.Checked == true)
  377. { model.Cus_DayForMarriageLunar = "1"; }
  378. else
  379. { model.Cus_DayForMarriageLunar = "0"; }
  380. if (customerBll.Update(model))
  381. {
  382. MessageBoxCustom.Show("修改成功!");
  383. }
  384. this.SetCustomerEditEnable(true);
  385. btnEx.Text = " 编辑";
  386. }
  387. }
  388. }
  389. public void SetCustomerEditEnable(bool bRead)
  390. {
  391. this.txtClientName.ReadOnly = bRead;
  392. this.txtClientTelephone.ReadOnly = bRead;
  393. this.txtClientQQ.ReadOnly = bRead;
  394. this.txtClientAddress.ReadOnly = bRead;
  395. this.txtClientWorkUnit.ReadOnly = bRead;
  396. this.txtClientBirthday.ReadOnly = bRead;
  397. this.chkClientBirthdayLunar.Enabled = true;
  398. this.txtClientDayForMarriage.ReadOnly = bRead;
  399. this.chkClientDayForMarriageLunar.Enabled = true;
  400. this.txtClientFixedPhone.ReadOnly = bRead;
  401. }
  402. public void BindShowAndHideDelete(bool b)
  403. {
  404. buttonForm1.Visible = b;
  405. }
  406. }
  407. }