FrmOldCustomerRecordBaby.cs 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653
  1. using LYFZ.BLL;
  2. using LYFZ.ComponentLibrary;
  3. using LYFZ.DAL;
  4. using LYFZ.Model;
  5. using LYFZ.Software.MainBusiness.Customers.OldCustomer;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.ComponentModel;
  9. using System.Data;
  10. using System.Drawing;
  11. using System.Globalization;
  12. using System.Linq;
  13. using System.Text;
  14. using System.Windows.Forms;
  15. namespace LYFZ.Software.MainBusiness.Customers
  16. {
  17. public partial class FrmOldCustomerRecordBaby : LYFZ.Software.UI.Customers.FrmOldCustomerRecordBaby
  18. {
  19. LYFZ.BLL.BLL_ErpSystemCategory scbll = new BLL.BLL_ErpSystemCategory();
  20. LYFZ.Model.Model_ErpCustomer model = new Model.Model_ErpCustomer();
  21. LYFZ.BLL.BLL_ErpOrder orbll = new BLL_ErpOrder();
  22. LYFZ.BLL.BLL_ErpCustomer ctbll = new BLL_ErpCustomer();
  23. LYFZ.BLL.BLL_OrderCustomer octbll = new BLL_OrderCustomer();
  24. /// <summary>
  25. /// 订单编号
  26. /// </summary>
  27. public string Theorderno;
  28. /// <summary>
  29. /// 客户组编号
  30. /// </summary>
  31. string Customergroup;
  32. /// <summary>
  33. /// 宝宝ID
  34. /// </summary>
  35. string BabyID = "";
  36. /// <summary>
  37. /// 检查是否有修改
  38. /// </summary>
  39. public bool IsSaved = false;
  40. /// <summary>
  41. /// 客户组ID
  42. /// </summary>
  43. public string GMID = "";
  44. /// <summary>
  45. /// 首页联系人ID
  46. /// </summary>
  47. public string oldID = "";
  48. public FrmOldCustomerRecordBaby()
  49. {
  50. this.dgv2.CellDoubleClick += dgv2_CellDoubleClick;
  51. this.chkLKH.Click += chkLKH_Click;
  52. this.chkPYJS.Click += chkPYJS_Click;
  53. this.chkQT.Click += chkQT_Click;
  54. this.btnCustomerSource.Click += btnCustomerSource_Click;
  55. this.btnRegion.Click += btnRegion_Click;
  56. this.txtBaby_Birthday.Leave += txtBaby_Birthday_Leave;
  57. this.btnQQCall.Click += btnQQCall_Click;
  58. this.btnDial.Click += btnDial_Click;
  59. this.txtCus_FixedPhone.KeyPress += txtCus_FixedPhone_KeyPress;
  60. this.btnUnbind.Click += btnUnbind_Click;
  61. }
  62. /// <summary>
  63. /// 客户微信绑定
  64. /// </summary>
  65. void BindMicroData(string customerID)
  66. {
  67. BLL_CustomerAndWxOpen bllWxOpen = new BLL_CustomerAndWxOpen();
  68. DataTable dt = bllWxOpen.GetCustomerDataByCustomerID(customerID);
  69. BLL.BLL_ErpMicroInterface bllInterface = new BLL.BLL_ErpMicroInterface();
  70. LYFZ.Model.Model_ErpMicroInterface modInterFace = new Model.Model_ErpMicroInterface();
  71. modInterFace = bllInterface.GetModelMicroInterface(LYFZ.BLL.BLL_ErpCompanyInfo.CurrentCompanyInfoID);
  72. if (string.IsNullOrEmpty(modInterFace.AppID))
  73. {
  74. modInterFace.AppID = "";
  75. }
  76. DataRow[] drList = dt.Select(" APPID = '" + modInterFace.AppID + "' ");
  77. if (drList.Length > 0)
  78. { this.txtMicroID.Text = "已绑定"; }
  79. else
  80. { this.txtMicroID.Text = "未绑定"; }
  81. }
  82. /// <summary>
  83. /// 解除客户微信绑定
  84. /// </summary>
  85. /// <param name="customerID"></param>
  86. bool UnBindMicroData(string customerID)
  87. {
  88. BLL_CustomerAndWxOpen bllWxOpen = new BLL_CustomerAndWxOpen();
  89. DataTable dt = bllWxOpen.GetCustomerDataByCustomerID(customerID);
  90. BLL.BLL_ErpMicroInterface bllInterface = new BLL.BLL_ErpMicroInterface();
  91. LYFZ.Model.Model_ErpMicroInterface modInterFace = new Model.Model_ErpMicroInterface();
  92. modInterFace = bllInterface.GetModelMicroInterface(LYFZ.BLL.BLL_ErpCompanyInfo.CurrentCompanyInfoID);
  93. if (string.IsNullOrEmpty(modInterFace.AppID))
  94. {
  95. modInterFace.AppID = "";
  96. }
  97. DataRow[] drList = dt.Select(" APPID = '" + modInterFace.AppID + "' ");
  98. if (drList.Length > 0)
  99. {
  100. bllWxOpen.Delete(drList[0]["ID"]);
  101. dt = bllWxOpen.GetCustomerDataByCustomerID(customerID);
  102. string strOpenID = "";
  103. for (int i = 0; i < dt.Rows.Count; i++)
  104. {
  105. if (!string.IsNullOrEmpty(strOpenID))
  106. {
  107. strOpenID += "/";
  108. }
  109. strOpenID += dt.Rows[i]["APPID"] + ":" + dt.Rows[i]["WxOpenId"];
  110. }
  111. Model_ErpCustomer model = ctbll.GetModel(Convert.ToInt32(this.oldID));
  112. model.Cus_OpenID = strOpenID;
  113. ctbll.Update(model);
  114. return true;
  115. //this.txtMicroID.Text = "已绑定";
  116. }
  117. else
  118. {
  119. return false;
  120. }
  121. }
  122. /// <summary>
  123. /// 窗体加载事件
  124. /// </summary>
  125. /// <param name="sender"></param>
  126. /// <param name="e"></param>
  127. protected override void FrmOldCustomerRecordBaby_Load(object sender, EventArgs e)
  128. {
  129. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.HidePhoneControls(this.txtCus_Telephone);
  130. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.HidePhoneControls(this.txtCus_FixedPhone);
  131. this.btnUpdate.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.OrdersCustomerCompetence, CustomAttributes.OperatingAuthority.Update);
  132. this.btnUnbind.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.MicroInfo, CustomAttributes.OperatingAuthority.MicroInfo_Unbind);
  133. this.Text = "编辑";
  134. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_ClientSourec("AAAAAAC", this.cmbCus_Region, strHideFiled: "");
  135. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_ClientSourec("AAAAAAF", this.cmbCus_CustomerSource, strHideFiled: "BFACBABGBGBJGDHIE,BFAFBCBADBDCABFDD");
  136. DataTable dt_tbl = scbll.GetList(" Sc_ClassParentID = '" + scbll.GetModel("BFABDBAJBJCEBDJCJ").ID.ToString().Trim() + "'").Tables[0];
  137. for (int i = 0; i < dt_tbl.Rows.Count; i++)
  138. { this.cmbCus_Relations.Items.Add(dt_tbl.Rows[i]["Sc_ClassName"].ToString().Trim()); }
  139. DataTable dt2 = orbll.GetView_Custom("tb_ErpCustomerGroup", StrWhere: "GP_OrderNumber = '" + Theorderno + "'", ShowColumnName: "GP_CustomerSource,GP_CustomerGroupID,GP_CustomerType").Tables[0];
  140. if (dt2.Rows.Count > 0)
  141. {
  142. switch (dt2.Rows[0]["GP_CustomerSource"].ToString().Trim())
  143. {
  144. case "老客户":
  145. this.chkLKH.Checked = true;
  146. this.chkLKH_Click(null, null);
  147. break;
  148. case "朋友介绍":
  149. this.chkPYJS.Checked = true;
  150. this.chkPYJS_Click(null, null);
  151. break;
  152. default:
  153. this.chkQT.Checked = true;
  154. this.chkQT_Click(null, null);
  155. this.cmbCus_CustomerSource.TextFindTag(dt2.Rows[0]["GP_CustomerSource"].ToString().Trim());
  156. break;
  157. }
  158. this.dgv2.Rows.Clear();
  159. this.Text = "编辑儿童客户";
  160. this.Customergroup = dt2.Rows[0]["GP_CustomerGroupID"].ToString();
  161. DataTable dt = orbll.GetView_Custom("tb_ErpCustomerGroupMembers Left Join tb_ErpCustomer on GM_CustomerID = Cus_CustomerNumber", StrWhere: "GM_CustomerGroupID = '" + Customergroup + "'", ShowColumnName: "tb_ErpCustomer.ID,Cus_Name,Cus_Sex,Cus_Birthday,Cus_BirthdayLunar,Cus_QQ,Cus_MicroSignal,Cus_Zodiac,Cus_DayForMarriage,Cus_DayForMarriageLunar,Cus_Telephone,Cus_FixedPhone,Cus_Region,Cus_Address,Cus_WorkUnit,Cus_CustomerNumber,Cus_Grade,Cus_Type,Cus_OpenID,GM_CustomerGroupID,GM_CustomerID,GM_RelatedPersonID,GM_Relation,tb_ErpCustomerGroupMembers.ID as GMID", filedOrder: "tb_ErpCustomer.ID").Tables[0];
  162. bool IsTrue = false;
  163. for (int t = 0; t < dt.Rows.Count; t++)
  164. {
  165. if (dt.Rows[t]["GM_Relation"].ToString().Trim() != "本人")
  166. {
  167. if (!IsTrue)
  168. {
  169. //性别
  170. if (!Convert.ToBoolean(dt.Rows[t]["Cus_Sex"]))
  171. { this.radCus_Nan.Checked = true; }
  172. else
  173. { radCus_Nv.Checked = true; }
  174. //公历
  175. if (dt.Rows[t]["Cus_BirthdayLunar"].ToString().Trim() == "1")
  176. { this.chkCus_Lunar.Checked = true; }
  177. //客户组ID
  178. this.GMID = dt.Rows[t]["GMID"].ToString().Trim();
  179. //ID
  180. this.oldID = dt.Rows[t]["ID"].ToString().Trim();
  181. //获取姓名
  182. this.txtCus_Name.Text = dt.Rows[t]["Cus_Name"].ToString().Trim();
  183. //生日
  184. this.txtCus_Birthday.StrValue = dt.Rows[t]["Cus_Birthday"].ToString().Trim();
  185. //区域
  186. this.cmbCus_Region.Text = dt.Rows[t]["Cus_Region"].ToString().Trim();
  187. //手机
  188. this.txtCus_Telephone.Text = dt.Rows[t]["Cus_Telephone"].ToString().Trim();
  189. //固话
  190. this.txtCus_FixedPhone.Text = dt.Rows[t]["Cus_FixedPhone"].ToString().Trim();
  191. //QQ
  192. this.txtCus_QQ.Text = dt.Rows[t]["Cus_QQ"].ToString().Trim();
  193. //微信
  194. this.txtCus_MicroSignal.Text = dt.Rows[t]["Cus_MicroSignal"].ToString().Trim();
  195. //单位
  196. this.txtCus_WorkUnit.Text = dt.Rows[t]["Cus_WorkUnit"].ToString().Trim();
  197. //地址
  198. this.txtCus_Address.Text = dt.Rows[t]["Cus_Address"].ToString().Trim();
  199. //关系
  200. this.cmbCus_Relations.Text = dt.Rows[t]["GM_Relation"].ToString().Trim();
  201. BindMicroData(dt.Rows[t]["Cus_CustomerNumber"].ToString().Trim());
  202. /*if (!string.IsNullOrEmpty(dt.Rows[t]["Cus_OpenID"].ToString().Trim()))
  203. { this.txtMicroID.Text = "已绑定"; }
  204. else
  205. { this.txtMicroID.Text = "未绑定"; }
  206. */
  207. //this.model.ID = Convert.ToInt32(dt.Rows[t]["ID"].ToString().Trim());
  208. //this.CustomerNumber = dt.Rows[t]["GMID"].ToString().Trim();
  209. IsTrue = true;
  210. }
  211. else
  212. {
  213. DataGridViewRow dgvr = new DataGridViewRow();
  214. DataGridViewCell cell = null;
  215. //姓名 0
  216. cell = new DataGridViewTextBoxCell();
  217. cell.Value = dt.Rows[t]["Cus_Name"].ToString().Trim();
  218. dgvr.Cells.Add(cell);
  219. //性别 1
  220. cell = new DataGridViewTextBoxCell();
  221. cell.Value = dt.Rows[t]["Cus_Sex"].ToString().Trim() == "False" ? "男" : "女";
  222. dgvr.Cells.Add(cell);
  223. //生日 2
  224. cell = new DataGridViewTextBoxCell();
  225. cell.Value = dt.Rows[t]["Cus_Birthday"].ToString().Trim();
  226. dgvr.Cells.Add(cell);
  227. //生日历类 3
  228. cell = new DataGridViewTextBoxCell();
  229. cell.Value = Lunar(dt.Rows[t]["Cus_BirthdayLunar"].ToString().Trim());
  230. dgvr.Cells.Add(cell);
  231. //QQ 4
  232. cell = new DataGridViewTextBoxCell();
  233. cell.Value = dt.Rows[t]["Cus_QQ"].ToString().Trim();
  234. dgvr.Cells.Add(cell);
  235. //微信 5
  236. cell = new DataGridViewTextBoxCell();
  237. cell.Value = dt.Rows[t]["Cus_MicroSignal"].ToString().Trim();
  238. dgvr.Cells.Add(cell);
  239. //手机 6
  240. cell = new DataGridViewTextBoxCell();
  241. cell.Value = dt.Rows[t]["Cus_Telephone"].ToString().Trim();
  242. dgvr.Cells.Add(cell);
  243. //固定电话 7
  244. cell = new DataGridViewTextBoxCell();
  245. cell.Value = dt.Rows[t]["Cus_FixedPhone"].ToString().Trim();
  246. dgvr.Cells.Add(cell);
  247. //地区 8
  248. cell = new DataGridViewTextBoxCell();
  249. cell.Value = dt.Rows[t]["Cus_Region"].ToString().Trim();
  250. dgvr.Cells.Add(cell);
  251. //地址 9
  252. cell = new DataGridViewTextBoxCell();
  253. cell.Value = dt.Rows[t]["Cus_Address"].ToString().Trim();
  254. dgvr.Cells.Add(cell);
  255. //工作单位 10
  256. cell = new DataGridViewTextBoxCell();
  257. cell.Value = dt.Rows[t]["Cus_WorkUnit"].ToString().Trim();
  258. dgvr.Cells.Add(cell);
  259. //ID 11
  260. cell = new DataGridViewTextBoxCell();
  261. cell.Value = dt.Rows[t]["ID"].ToString().Trim();
  262. dgvr.Cells.Add(cell);
  263. //联系人 12
  264. cell = new DataGridViewTextBoxCell();
  265. cell.Value = dt.Rows[t]["GM_Relation"].ToString().Trim();
  266. dgvr.Cells.Add(cell);
  267. //客户编号 14
  268. cell = new DataGridViewTextBoxCell();
  269. cell.Value = dt.Rows[t]["Cus_CustomerNumber"].ToString().Trim();
  270. dgvr.Cells.Add(cell);
  271. //订单号 13
  272. cell = new DataGridViewTextBoxCell();
  273. cell.Value = dt.Rows[t]["GMID"].ToString().Trim();
  274. dgvr.Cells.Add(cell);
  275. this.dgv2.Rows.Add(dgvr);
  276. }
  277. }
  278. else if (dt.Rows[t]["GM_Relation"].ToString().Trim() == "本人")
  279. {
  280. //宝宝ID
  281. this.BabyID = dt.Rows[t]["ID"].ToString().Trim();
  282. //宝贝姓名
  283. this.txtBaby_name.Text = dt.Rows[t]["Cus_Name"].ToString();
  284. //宝贝性别
  285. if (!Convert.ToBoolean(dt.Rows[t]["Cus_Sex"]))
  286. { this.radCus_Nan.Checked = true; }
  287. else
  288. { this.radioBaby_nv.Checked = true; }
  289. //农历新历
  290. string i = dt.Rows[t]["Cus_BirthdayLunar"].ToString();
  291. if (dt.Rows[t]["Cus_BirthdayLunar"].ToString().Trim() == "1")
  292. { this.chkBaby_Lunar.Checked = true; }
  293. //宝贝生日
  294. this.txtBaby_Birthday.StrValue = dt.Rows[t]["Cus_Birthday"].ToString();
  295. //宝宝生肖
  296. this.cmbBaby.Text = dt.Rows[t]["Cus_Zodiac"].ToString();
  297. }
  298. }
  299. }
  300. else
  301. { MessageBoxCustom.Show("此订单没有用户"); }
  302. }
  303. /// <summary>
  304. /// 修改
  305. /// </summary>
  306. /// <param name="sender"></param>
  307. /// <param name="e"></param>
  308. protected override void btnUpdate_Click(object sender, EventArgs e)
  309. {
  310. List<Helper.CommandInfo> clist = new List<Helper.CommandInfo>();
  311. string StrPhone = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.MaskedTextBoxExGetText(this.txtCus_Telephone);
  312. #region 验证输入框不能为空
  313. if (string.IsNullOrEmpty(this.txtCus_Name.Text))
  314. { MessageBoxCustom.Show("客户姓名不能为空!"); return; }
  315. if (this.txtCus_Telephone.Text == "")
  316. { MessageBoxCustom.Show("客户客户手机不能为空!"); return; }
  317. if (!string.IsNullOrEmpty(StrPhone))
  318. {
  319. if (StrPhone.Length != 11)
  320. { MessageBoxCustom.Show("手机号码必须为11位数!"); return; }
  321. DataTable tblClient = orbll.GetView_Custom("tb_ErpCustomer", StrWhere: "Cus_Telephone = '" + StrPhone + "' and ID != '" + this.oldID + "'", ShowColumnName: "ID").Tables[0];
  322. if (tblClient.Rows.Count > 0)
  323. { MessageBoxCustom.Show("手机号已存在"); return; }
  324. }
  325. if (this.txtCus_Birthday.Text.Trim() != "")
  326. {
  327. int intMasse1 = this.txtCus_Birthday.CheckDateValue(this.txtCus_Birthday, this.chkCus_Lunar);
  328. if (intMasse1 == 1) { MessageBoxCustom.Show("客户生日日期格式输入错误!"); return; }
  329. else if (intMasse1 == 2)
  330. { MessageBoxCustom.Show("客户生日:" + this.txtCus_Birthday.StrValue.Trim() + "不是公历日期,若要保存请勾上农历!"); return; }
  331. }
  332. if (this.txtBaby_Birthday.Text.Trim() != "")
  333. {
  334. int intMasse = this.txtBaby_Birthday.CheckDateValue(this.txtBaby_Birthday, this.chkBaby_Lunar);
  335. if (intMasse == 1) { MessageBoxCustom.Show("宝宝生日日期格式输入错误!"); return; }
  336. else if (intMasse == 2)
  337. { MessageBoxCustom.Show("宝宝生日:" + this.txtBaby_Birthday.StrValue.Trim() + "不是公历日期,若要保存请勾上农历!"); return; }
  338. }
  339. if (this.chkLKH.Checked == false && this.chkQT.Checked == false && this.chkPYJS.Checked == false)
  340. {
  341. MessageBoxCustom.Show("请选择客户来源");
  342. return;
  343. }
  344. if (this.cmbCus_Relations.Text == "")
  345. { MessageBoxCustom.Show("请选着与宝宝的关系"); return; }
  346. #endregion
  347. #region 修改客户资料
  348. try
  349. {
  350. model = ctbll.GetModel(Convert.ToInt32(oldID));
  351. model.Cus_Name = LYFZ.BLL.OtherCommonModel.ClearSpecialCharacter(this.txtCus_Name.Text.ToString());
  352. model.Cus_NamePinyin = LYFZ.Command.Command_ChineseToPinyin.GetChineseSpellPinyin(model.Cus_Name).ToLower();
  353. if (this.radCus_Nan.Checked)
  354. { model.Cus_Sex = false; }
  355. else
  356. { model.Cus_Sex = true; }
  357. model.Cus_Birthday = "";
  358. model.Cus_BirthdayLunar = "";
  359. model.Cus_Zodiac = "";
  360. if (txtCus_Birthday.StrValue.Trim() != "")
  361. {
  362. model.Cus_Birthday = txtCus_Birthday.StrValue.Trim();
  363. model.Cus_Zodiac = LYFZ.Command.Command_CalendarTurnLunar.GetZodiac(this.txtCus_Birthday.StrValue.Trim(), this.chkCus_Lunar.Checked);
  364. if (chkCus_Lunar.Checked)
  365. { model.Cus_BirthdayLunar = "1"; }
  366. else
  367. { model.Cus_BirthdayLunar = "0"; }
  368. }
  369. model.Cus_QQ = this.txtCus_QQ.Text.ToString();
  370. model.Cus_MicroSignal = this.txtCus_MicroSignal.Text.ToString();
  371. model.Cus_Telephone = StrPhone;
  372. model.Cus_FixedPhone = this.txtCus_FixedPhone.Text.ToString();
  373. model.Cus_Region = this.cmbCus_Region.Text.ToString();
  374. model.Cus_Address = this.txtCus_Address.Text.ToString();
  375. model.Cus_WorkUnit = this.txtCus_WorkUnit.Text.ToString();
  376. model.Cus_UpdateDateTime = SDateTime.Now;
  377. model.Cus_UpdateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  378. //客人信息放入集合
  379. clist.Add(ctbll.GetUpdateCommandInfo(model));
  380. //获得宝宝信息
  381. model = ctbll.GetModel(Convert.ToInt32(BabyID));
  382. model.Cus_Name = txtBaby_name.Text;
  383. model.Cus_Birthday = txtBaby_Birthday.StrValue.ToString();
  384. if (model.Cus_Birthday != "")
  385. {
  386. if (chkBaby_Lunar.Checked)
  387. { model.Cus_BirthdayLunar = "1"; }
  388. else { model.Cus_BirthdayLunar = "0"; }
  389. model.Cus_Zodiac = LYFZ.Command.Command_CalendarTurnLunar.GetZodiac(this.txtBaby_Birthday.StrValue.Trim(), this.chkBaby_Lunar.Checked);
  390. }
  391. else
  392. {
  393. model.Cus_BirthdayLunar = "";
  394. model.Cus_Zodiac = "";
  395. }
  396. if (radioBaby_nan.Checked)
  397. { model.Cus_Sex = false; }
  398. else
  399. { model.Cus_Sex = true; }
  400. //宝宝数据
  401. clist.Add(ctbll.GetUpdateCommandInfo(model));
  402. //修改客户关系
  403. BLL_ErpCustomerGroupMembers GMbll = new BLL_ErpCustomerGroupMembers();
  404. Model.Model_ErpCustomerGroupMembers modelGM = GMbll.GetModel(Convert.ToInt32(GMID));
  405. modelGM.GM_Relation = cmbCus_Relations.Text;
  406. clist.Add(GMbll.GetUpdateCommandInfo(modelGM));
  407. //修改客户来源
  408. BLL_ErpCustomerGroup GPbll = new BLL_ErpCustomerGroup();
  409. Model.Model_ErpCustomerGroup modelGP = GPbll.GetModel("GP_OrderNumber", Theorderno);
  410. if (this.chkLKH.Checked)
  411. {
  412. modelGP.GP_CustomerSource = "老客户";
  413. modelGP.GP_IntroducerCustomerID = "";
  414. }
  415. if (this.chkPYJS.Checked)
  416. { modelGP.GP_CustomerSource = "朋友介绍"; }
  417. if (chkQT.Checked)
  418. {
  419. modelGP.GP_CustomerSource = cmbCus_CustomerSource.Text;
  420. modelGP.GP_IntroducerCustomerID = "";
  421. }
  422. clist.Add(GPbll.GetUpdateCommandInfo(modelGP));
  423. if (LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist) > 0)
  424. {
  425. //日志
  426. LYFZ.BLL.BLL_ErpSystemLogs.WriteSystemLog(LYFZ.EnumPublic.SystemLogsType.修改客户资料, "联系人:" + model.Cus_Name + ",修改联系人资料的客户组:" + modelGP.GP_CustomerGroupID + ",时间:" + SDateTime.Now, LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID, LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name);
  427. DAL_ErpCustomer.UpdateAggregationCustomer(Theorderno);
  428. MessageBoxCustom.Show("保存成功");
  429. IsSaved = true;
  430. }
  431. else
  432. { MessageBoxCustom.Show("保存失败"); }
  433. }
  434. catch (Exception ex) { MessageBoxCustom.Show(ex.Message); }
  435. #endregion
  436. }
  437. /// <summary>
  438. /// 解绑
  439. /// </summary>
  440. /// <param name="sender"></param>
  441. /// <param name="e"></param>
  442. void btnUnbind_Click(object sender, EventArgs e)
  443. {
  444. if (this.txtMicroID.Text.Trim() == "已绑定")
  445. {
  446. if (MessageBoxCustom.Show("是否要解除绑定?", "温馨提示!", MessageBoxButtons.YesNo) == DialogResult.No)
  447. { return; }
  448. LYFZ.Model.Model_ErpCustomer model = ctbll.GetModel(Convert.ToInt32(this.oldID));
  449. model.Cus_OpenID = "";
  450. model.Cus_UpdateDateTime = SDateTime.Now;
  451. model.Cus_UpdateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  452. ctbll.Update(model);
  453. if (UnBindMicroData(model.Cus_CustomerNumber))
  454. {
  455. MessageBoxCustom.Show("解绑成功!");
  456. this.txtMicroID.Text = "未绑定";
  457. }
  458. else
  459. { MessageBoxCustom.Show("解绑失败"); }
  460. }
  461. }
  462. /// <summary>
  463. /// 列表双击事件
  464. /// </summary>
  465. /// <param name="sender"></param>
  466. /// <param name="e"></param>
  467. void dgv2_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  468. {
  469. try
  470. {
  471. if (this.dgv2.SelectedRows.Count > 0)
  472. {
  473. FrmAddContacts from = new FrmAddContacts();
  474. from.btnSave.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.OrdersCustomerCompetence, CustomAttributes.OperatingAuthority.Update);
  475. from.YouID = dgv2.CurrentRow.Cells["ID"].Value.ToString().Trim();
  476. from.GP = Customergroup;
  477. from.GMID = dgv2.CurrentRow.Cells["GMID"].Value.ToString().Trim();
  478. from.Zhuangtai = "编辑";
  479. if (from.ShowDialog() == DialogResult.OK)
  480. {
  481. this.IsSaved = true;
  482. this.FrmOldCustomerRecordBaby_Load(null, null);
  483. }
  484. }
  485. }
  486. catch (Exception ex)
  487. { MessageBoxCustom.Show(ex.Message); }
  488. }
  489. /// <summary>
  490. /// 打电话
  491. /// </summary>
  492. /// <param name="sender"></param>
  493. /// <param name="e"></param>
  494. void btnDial_Click(object sender, EventArgs e)
  495. {
  496. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.PhoneCall(this.txtCus_Telephone);
  497. }
  498. /// <summary>
  499. /// QQ呼叫
  500. /// </summary>
  501. /// <param name="sender"></param>
  502. /// <param name="e"></param>
  503. void btnQQCall_Click(object sender, EventArgs e)
  504. {
  505. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.QQCall(this.txtCus_QQ.Text.Trim());
  506. }
  507. /// <summary>
  508. /// 生日离开验证
  509. /// </summary>
  510. /// <param name="sender"></param>
  511. /// <param name="e"></param>
  512. void txtBaby_Birthday_Leave(object sender, EventArgs e)
  513. {
  514. this.cmbBaby.Text = LYFZ.Command.Command_CalendarTurnLunar.GetZodiac(this.txtBaby_Birthday.StrValue.Trim(), this.chkBaby_Lunar.Checked);
  515. }
  516. /// <summary>
  517. /// 关闭
  518. /// </summary>
  519. /// <param name="sender"></param>
  520. /// <param name="e"></param>
  521. protected override void btnClose_Click(object sender, EventArgs e)
  522. {
  523. this.Close();
  524. }
  525. /// <summary>
  526. /// 设置客户来源
  527. /// </summary>
  528. /// <param name="sender"></param>
  529. /// <param name="e"></param>
  530. void btnCustomerSource_Click(object sender, EventArgs e)
  531. {
  532. LYFZ.Software.MainBusiness.InitialSet.FrmSystemSet frm = new InitialSet.FrmSystemSet();
  533. frm.TypeName = "AAAAAAF";
  534. frm.Version = "Version";
  535. if (frm.ShowDialog() == DialogResult.OK)
  536. { LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_ClientSourec("AAAAAAF", this.cmbCus_CustomerSource, strHideFiled: "BFACBABGBGBJGDHIE,BFAFBCBADBDCABFDD"); }
  537. }
  538. /// <summary>
  539. /// 设置客户区域
  540. /// </summary>
  541. /// <param name="sender"></param>
  542. /// <param name="e"></param>
  543. void btnRegion_Click(object sender, EventArgs e)
  544. {
  545. LYFZ.Software.MainBusiness.InitialSet.FrmSystemSet frm = new InitialSet.FrmSystemSet();
  546. frm.TypeName = "AAAAAAC";
  547. frm.Version = "Version";
  548. if (frm.ShowDialog() == DialogResult.OK)
  549. { LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_ClientSourec("AAAAAAC", this.cmbCus_Region, strHideFiled: ""); }
  550. }
  551. /// <summary>
  552. /// 单选框事件
  553. /// </summary>
  554. /// <param name="sender"></param>
  555. /// <param name="e"></param>
  556. void chkQT_Click(object sender, EventArgs e)
  557. {
  558. this.chkLKH.Checked = false;
  559. this.chkPYJS.Checked = false;
  560. this.cmbCus_CustomerSource.Enabled = true;
  561. }
  562. /// <summary>
  563. /// 单选框事件
  564. /// </summary>
  565. /// <param name="sender"></param>
  566. /// <param name="e"></param>
  567. void chkPYJS_Click(object sender, EventArgs e)
  568. {
  569. this.cmbCus_CustomerSource.Enabled = false;
  570. this.chkLKH.Checked = false;
  571. this.chkQT.Checked = false;
  572. }
  573. /// <summary>
  574. /// 单选框事件
  575. /// </summary>
  576. /// <param name="sender"></param>
  577. /// <param name="e"></param>
  578. void chkLKH_Click(object sender, EventArgs e)
  579. {
  580. this.chkPYJS.Checked = false;
  581. this.chkQT.Checked = false;
  582. this.cmbCus_CustomerSource.Enabled = false;
  583. }
  584. /// <summary>
  585. /// 输入框设置
  586. /// </summary>
  587. /// <param name="sender"></param>
  588. /// <param name="e"></param>
  589. void txtCus_FixedPhone_KeyPress(object sender, KeyPressEventArgs e)
  590. {
  591. if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar))
  592. { e.Handled = true; }
  593. }
  594. /// <summary>
  595. /// 输入框设置
  596. /// </summary>
  597. /// <param name="sender"></param>
  598. /// <param name="e"></param>
  599. protected override void txtCus_QQ_KeyPress(object sender, KeyPressEventArgs e)
  600. {
  601. if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar))
  602. { e.Handled = true; }
  603. }
  604. /// <summary>
  605. /// 输入框设置
  606. /// </summary>
  607. /// <param name="sender"></param>
  608. /// <param name="e"></param>
  609. protected override void txtCus_Telephone_KeyPress(object sender, KeyPressEventArgs e)
  610. {
  611. if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar))
  612. { e.Handled = true; }
  613. }
  614. /// <summary>
  615. /// 返回日历类别
  616. /// </summary>
  617. /// <param name="lun"></param>
  618. /// <returns></returns>
  619. string Lunar(string lun)
  620. {
  621. string luns = "";
  622. switch (lun)
  623. {
  624. case "0":
  625. luns = "公历";
  626. break;
  627. case "1":
  628. luns = "农历";
  629. break;
  630. case "2":
  631. luns = "农历润月";
  632. break;
  633. }
  634. return luns;
  635. }
  636. }
  637. }