FrmOldCustomerEditBaby.cs 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828
  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.Linq;
  12. using System.Text;
  13. using System.Windows.Forms;
  14. namespace LYFZ.Software.MainBusiness.Customers
  15. {
  16. public partial class FrmOldCustomerEditBaby : LYFZ.Software.UI.Customers.FrmOldCustomerEditBaby
  17. {
  18. Boolean bl = false;
  19. public FrmOldCustomerEditBaby()
  20. {
  21. this.Load += FrmOldCustomerEditBaby_Load;
  22. this.FormClosed += FrmOldCustomerEditBaby_FormClosed;
  23. this.dgvData.CellDoubleClick += dgv2_CellDoubleClick;
  24. this.chkLKH.Click += chkLKH_Click;
  25. this.chkPYJS.Click += chkPYJS_Click;
  26. this.chkQT.Click += chkQT_Click;
  27. this.btnCustomerSource.Click += btnCustomerSource_Click;
  28. this.btnRegion.Click += btnRegion_Click;
  29. this.txtBaby_Birthday.Leave += txtBaby_Birthday_Leave;
  30. this.btnSave.Click += btnSave_Click;
  31. this.btnlevel.Click += btnlevel_Click;
  32. this.btnAdding.Click += btnAdding_Click;
  33. this.btnDelete.Click += btnDelete_Click;
  34. this.btnClose.Click += btnClose_Click;
  35. this.btnQQCall.Click += btnQQCall_Click;
  36. this.btnDial.Click += btnDial_Click;
  37. this.txtCus_FixedPhone.KeyPress += txtCus_FixedPhone_KeyPress;
  38. this.txtHistory_Money.KeyPress += txtHistory_Money_KeyPress;
  39. this.btnUnbind.Click += btnUnbind_Click;
  40. this.chkBaby_Lunar.Click += chkBaby_Lunar_Click;
  41. }
  42. void chkBaby_Lunar_Click(object sender, EventArgs e)
  43. {
  44. txtBaby_Birthday_Leave(this, null);
  45. }
  46. /// <summary>
  47. /// 客户类型 1老客户 2意向客户
  48. /// </summary>
  49. public int type;
  50. /// <summary>
  51. /// 拨打电话
  52. /// </summary>
  53. /// <param name="sender"></param>
  54. /// <param name="e"></param>
  55. void btnDial_Click(object sender, EventArgs e)
  56. {
  57. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.PhoneCall(this.txtCus_Telephone);
  58. }
  59. /// <summary>
  60. /// QQ呼叫
  61. /// </summary>
  62. /// <param name="sender"></param>
  63. /// <param name="e"></param>
  64. void btnQQCall_Click(object sender, EventArgs e)
  65. {
  66. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.QQCall(txtCus_QQ.Text.Trim());
  67. }
  68. /// <summary>
  69. /// 客户组编号
  70. /// </summary>
  71. public string GM;
  72. /// <summary>
  73. /// 主联系人ID
  74. /// </summary>
  75. string BabyID = "";
  76. /// <summary>
  77. /// 主联系人编号
  78. /// </summary>
  79. string SerialnumberID = "";
  80. /// <summary>
  81. /// 页面联系人ID
  82. /// </summary>
  83. string aincontactID = "";
  84. /// <summary>
  85. /// 客户组ID
  86. /// </summary>
  87. string GMID = "";
  88. LYFZ.BLL.BLL_ErpCustomer ctbll = new BLL.BLL_ErpCustomer();
  89. LYFZ.BLL.BLL_ErpCustomerGroupMembers gmbll = new BLL_ErpCustomerGroupMembers();
  90. LYFZ.BLL.BLL_ErpOrder orbll = new BLL_ErpOrder();
  91. BLL.BLL_OldOrderHistory Bll_ooh = new BLL_OldOrderHistory();
  92. Model.Model_OldOrderHistory model_ooh = null;
  93. /// <summary>
  94. /// 窗体关闭事件
  95. /// </summary>
  96. /// <param name="sender"></param>
  97. /// <param name="e"></param>
  98. void FrmOldCustomerEditBaby_FormClosed(object sender, FormClosedEventArgs e)
  99. {
  100. if (bl)
  101. {
  102. this.DialogResult = DialogResult.OK;
  103. }
  104. }
  105. /// <summary>
  106. /// 窗体加载事件
  107. /// </summary>
  108. /// <param name="sender"></param>
  109. /// <param name="e"></param>
  110. void FrmOldCustomerEditBaby_Load(object sender, EventArgs e)
  111. {
  112. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.HidePhoneControls(this.txtCus_Telephone);
  113. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.HidePhoneControls(this.txtCus_FixedPhone);
  114. this.Text = "修改儿童版老客户";
  115. this.dgvData.Rows.Clear();
  116. if (type != 2)
  117. {
  118. if (Bll_ooh.Exists("History_ID", GM))
  119. { model_ooh = Bll_ooh.GetModel("History_ID", GM); }
  120. }
  121. this.btnUnbind.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.MicroInfo, CustomAttributes.OperatingAuthority.MicroInfo_Unbind);
  122. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory("BFADBIBEFCFCIDCDG", this.cmbtreevlevel, IsFirstNodeNull: true);
  123. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_ClientSourec("AAAAAAC", this.cmbCus_Region, strHideFiled: "");
  124. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_ClientSourec("AAAAAAF", this.cmbCus_CustomerSource, strHideFiled: "BFACBABGBGBJGDHIE,BFAFBCBADBDCABFDD");
  125. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory("BFABDBAJBJCEBDJCJ", this.cmbtreevRelations);
  126. LYFZ.BLL.BLL_OrderCustomer bll = new BLL_OrderCustomer();
  127. LYFZ.BLL.BLL_ErpCustomerGroup GPbll = new BLL_ErpCustomerGroup();
  128. LYFZ.Model.Model_ErpCustomerGroup ModelGP = GPbll.GetModel("GP_CustomerGroupID", GM);
  129. if (ModelGP.ID > 0)
  130. {
  131. switch (ModelGP.GP_CustomerSource.Trim())
  132. {
  133. case "老客户":
  134. this.chkLKH.Checked = true;
  135. this.chkLKH_Click(null, null);
  136. break;
  137. case "朋友介绍":
  138. this.chkPYJS.Checked = true;
  139. this.chkPYJS_Click(null, null);
  140. break;
  141. default:
  142. this.chkQT.Checked = true;
  143. this.chkQT_Click(null, null);
  144. cmbCus_CustomerSource.TextFindTag(ModelGP.GP_CustomerSource);
  145. break;
  146. }
  147. DataTable dt = orbll.GetView_Custom("tb_ErpCustomerGroupMembers Left Join tb_ErpCustomer on GM_CustomerID = Cus_CustomerNumber", StrWhere: "GM_CustomerGroupID = '" + GM + "'", 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];
  148. if (dt.Rows.Count > 0)
  149. {
  150. bool IsTrue = false;
  151. for (int t = 0; t < dt.Rows.Count; t++)
  152. {
  153. if (dt.Rows[t]["Cus_Type"].ToString().Trim() != "儿童")
  154. {
  155. if (!IsTrue)
  156. {
  157. //性别
  158. if (!Convert.ToBoolean(dt.Rows[t]["Cus_Sex"]))
  159. { this.radCus_Nan.Checked = true; }
  160. else
  161. { radCus_Nv.Checked = true; }
  162. //公历
  163. if (dt.Rows[t]["Cus_BirthdayLunar"].ToString().Trim() == "1")
  164. { this.chkCus_Lunar.Checked = true; }
  165. //客户组ID
  166. this.GMID = dt.Rows[t]["GMID"].ToString().Trim();
  167. //ID
  168. this.aincontactID = dt.Rows[t]["ID"].ToString().Trim();
  169. //获取姓名
  170. this.txtCus_Name.Text = dt.Rows[t]["Cus_Name"].ToString().Trim();
  171. //生日
  172. this.txtCus_Birthday.StrValue = dt.Rows[t]["Cus_Birthday"].ToString().Trim();
  173. //区域
  174. this.cmbCus_Region.Text = dt.Rows[t]["Cus_Region"].ToString().Trim();
  175. //手机
  176. this.txtCus_Telephone.Text = dt.Rows[t]["Cus_Telephone"].ToString().Trim();
  177. //固话
  178. this.txtCus_FixedPhone.Text = dt.Rows[t]["Cus_FixedPhone"].ToString().Trim();
  179. //QQ
  180. this.txtCus_QQ.Text = dt.Rows[t]["Cus_QQ"].ToString().Trim();
  181. //微信
  182. this.txtCus_MicroSignal.Text = dt.Rows[t]["Cus_MicroSignal"].ToString().Trim();
  183. //单位
  184. this.txtCus_WorkUnit.Text = dt.Rows[t]["Cus_WorkUnit"].ToString().Trim();
  185. //地址
  186. this.txtCus_Address.Text = dt.Rows[t]["Cus_Address"].ToString().Trim();
  187. //关系
  188. this.cmbtreevRelations.TextFindTag(dt.Rows[t]["GM_Relation"].ToString());
  189. BindMicroData(dt.Rows[t]["Cus_CustomerNumber"].ToString().Trim());
  190. /*if (!string.IsNullOrEmpty(dt.Rows[t]["Cus_OpenID"].ToString().Trim()))
  191. { this.txtMicroID.Text = "已绑定"; }
  192. else
  193. { this.txtMicroID.Text = "未绑定"; }*/
  194. IsTrue = true;
  195. }
  196. else
  197. {
  198. DataGridViewRow dgvr = new DataGridViewRow();
  199. DataGridViewCell cell = null;
  200. //姓名 0
  201. cell = new DataGridViewTextBoxCell();
  202. cell.Value = dt.Rows[t]["Cus_Name"].ToString().Trim();
  203. dgvr.Cells.Add(cell);
  204. //性别 1
  205. cell = new DataGridViewTextBoxCell();
  206. cell.Value = dt.Rows[t]["Cus_Sex"].ToString().Trim() == "False" ? "男" : "女";
  207. dgvr.Cells.Add(cell);
  208. //生日 2
  209. cell = new DataGridViewTextBoxCell();
  210. cell.Value = dt.Rows[t]["Cus_Birthday"].ToString().Trim();
  211. dgvr.Cells.Add(cell);
  212. //生日历类 3
  213. cell = new DataGridViewTextBoxCell();
  214. cell.Value = Lunar(dt.Rows[t]["Cus_BirthdayLunar"].ToString().Trim());
  215. dgvr.Cells.Add(cell);
  216. //QQ 4
  217. cell = new DataGridViewTextBoxCell();
  218. cell.Value = dt.Rows[t]["Cus_QQ"].ToString().Trim();
  219. dgvr.Cells.Add(cell);
  220. //微信 5
  221. cell = new DataGridViewTextBoxCell();
  222. cell.Value = dt.Rows[t]["Cus_MicroSignal"].ToString().Trim();
  223. dgvr.Cells.Add(cell);
  224. //手机 6
  225. cell = new DataGridViewTextBoxCell();
  226. cell.Value = dt.Rows[t]["Cus_Telephone"].ToString().Trim();
  227. dgvr.Cells.Add(cell);
  228. //固定电话 7
  229. cell = new DataGridViewTextBoxCell();
  230. cell.Value = dt.Rows[t]["Cus_FixedPhone"].ToString().Trim();
  231. dgvr.Cells.Add(cell);
  232. //地区 8
  233. cell = new DataGridViewTextBoxCell();
  234. cell.Value = dt.Rows[t]["Cus_Region"].ToString().Trim();
  235. dgvr.Cells.Add(cell);
  236. //地址 9
  237. cell = new DataGridViewTextBoxCell();
  238. cell.Value = dt.Rows[t]["Cus_Address"].ToString().Trim();
  239. dgvr.Cells.Add(cell);
  240. //工作单位 10
  241. cell = new DataGridViewTextBoxCell();
  242. cell.Value = dt.Rows[t]["Cus_WorkUnit"].ToString().Trim();
  243. dgvr.Cells.Add(cell);
  244. //ID 11
  245. cell = new DataGridViewTextBoxCell();
  246. cell.Value = dt.Rows[t]["ID"].ToString().Trim();
  247. dgvr.Cells.Add(cell);
  248. //联系人 12
  249. cell = new DataGridViewTextBoxCell();
  250. cell.Value = dt.Rows[t]["GM_Relation"].ToString().Trim();
  251. dgvr.Cells.Add(cell);
  252. //客户编号 14
  253. cell = new DataGridViewTextBoxCell();
  254. cell.Value = dt.Rows[t]["Cus_CustomerNumber"].ToString().Trim();
  255. dgvr.Cells.Add(cell);
  256. //GMID 13
  257. cell = new DataGridViewTextBoxCell();
  258. cell.Value = dt.Rows[t]["GMID"].ToString().Trim();
  259. dgvr.Cells.Add(cell);
  260. //等级
  261. cell = new DataGridViewTextBoxCell();
  262. cell.Value = dt.Rows[t]["Cus_Grade"].ToString().Trim();
  263. dgvr.Cells.Add(cell);
  264. dgvData.Rows.Add(dgvr);
  265. }
  266. }
  267. else
  268. {
  269. if (model_ooh != null)
  270. {
  271. this.txtHistory_Type.Text = model_ooh.History_Type;
  272. this.txtHistory_Money.Text = model_ooh.History_Money.ToString();
  273. DateTime ti1 = Convert.ToDateTime("1900-01-01");
  274. if (DateTime.Compare(model_ooh.History_OrderTime, ti1) < 0)
  275. { this.txtHistory_OrderTime.StrValue = ""; }
  276. else
  277. { this.txtHistory_OrderTime.StrValue = model_ooh.History_OrderTime.ToString("yyyy-MM-dd"); }
  278. }
  279. //宝宝ID
  280. this.BabyID = dt.Rows[t]["ID"].ToString().Trim();
  281. //宝贝姓名
  282. this.txtBaby_name.Text = dt.Rows[t]["Cus_Name"].ToString();
  283. //宝贝性别
  284. if (!Convert.ToBoolean(dt.Rows[t]["Cus_Sex"]))
  285. { this.radCus_Nan.Checked = true; }
  286. else
  287. { this.radioBaby_nv.Checked = true; }
  288. //农历新历
  289. string i = dt.Rows[t]["Cus_BirthdayLunar"].ToString();
  290. if (dt.Rows[t]["Cus_BirthdayLunar"].ToString().Trim() == "1")
  291. { this.chkBaby_Lunar.Checked = true; }
  292. //宝贝生日
  293. this.txtBaby_Birthday.StrValue = dt.Rows[t]["Cus_Birthday"].ToString();
  294. //宝宝生肖
  295. this.cmbBaby.Text = dt.Rows[t]["Cus_Zodiac"].ToString();
  296. //等级
  297. this.cmbtreevlevel.TextFindTag(dt.Rows[t]["Cus_Grade"].ToString());
  298. }
  299. }
  300. }
  301. }
  302. }
  303. /// <summary>
  304. /// 客户微信绑定
  305. /// </summary>
  306. void BindMicroData(string customerID)
  307. {
  308. BLL_CustomerAndWxOpen bllWxOpen = new BLL_CustomerAndWxOpen();
  309. DataTable dt = bllWxOpen.GetCustomerDataByCustomerID(customerID);
  310. BLL.BLL_ErpMicroInterface bllInterface = new BLL.BLL_ErpMicroInterface();
  311. LYFZ.Model.Model_ErpMicroInterface modInterFace = new Model.Model_ErpMicroInterface();
  312. modInterFace = bllInterface.GetModelMicroInterface(LYFZ.BLL.BLL_ErpCompanyInfo.CurrentCompanyInfoID);
  313. if (string.IsNullOrEmpty(modInterFace.AppID))
  314. {
  315. modInterFace.AppID = "";
  316. }
  317. DataRow[] drList = dt.Select(" APPID = '" + modInterFace.AppID + "' ");
  318. if (drList.Length > 0)
  319. { this.txtMicroID.Text = "已绑定"; }
  320. else
  321. { this.txtMicroID.Text = "未绑定"; }
  322. }
  323. /// <summary>
  324. /// 解除客户微信绑定
  325. /// </summary>
  326. /// <param name="customerID"></param>
  327. bool UnBindMicroData(string customerID)
  328. {
  329. BLL_CustomerAndWxOpen bllWxOpen = new BLL_CustomerAndWxOpen();
  330. DataTable dt = bllWxOpen.GetCustomerDataByCustomerID(customerID);
  331. BLL.BLL_ErpMicroInterface bllInterface = new BLL.BLL_ErpMicroInterface();
  332. LYFZ.Model.Model_ErpMicroInterface modInterFace = new Model.Model_ErpMicroInterface();
  333. modInterFace = bllInterface.GetModelMicroInterface(LYFZ.BLL.BLL_ErpCompanyInfo.CurrentCompanyInfoID);
  334. if (string.IsNullOrEmpty(modInterFace.AppID))
  335. {
  336. modInterFace.AppID = "";
  337. }
  338. DataRow[] drList = dt.Select(" APPID = '" + modInterFace.AppID + "' ");
  339. if (drList.Length > 0)
  340. {
  341. bllWxOpen.Delete(drList[0]["ID"]);
  342. dt = bllWxOpen.GetCustomerDataByCustomerID(customerID);
  343. string strOpenID = "";
  344. for (int i = 0; i < dt.Rows.Count; i++)
  345. {
  346. if (!string.IsNullOrEmpty(strOpenID))
  347. {
  348. strOpenID += "/";
  349. }
  350. strOpenID += dt.Rows[i]["APPID"] + ":" + dt.Rows[i]["WxOpenId"];
  351. }
  352. Model_ErpCustomer model = ctbll.GetModel(Convert.ToInt32(this.aincontactID));
  353. model.Cus_OpenID = strOpenID;
  354. ctbll.Update(model);
  355. return true;
  356. //this.txtMicroID.Text = "已绑定";
  357. }
  358. else
  359. {
  360. return false;
  361. }
  362. }
  363. /// <summary>
  364. /// 解绑微信
  365. /// </summary>
  366. /// <param name="sender"></param>
  367. /// <param name="e"></param>
  368. void btnUnbind_Click(object sender, EventArgs e)
  369. {
  370. if (this.txtMicroID.Text.Trim() == "已绑定")
  371. {
  372. if (MessageBoxCustom.Show("是否要解除绑定?", "温馨提示!", MessageBoxButtons.YesNo) == DialogResult.No)
  373. { return; }
  374. LYFZ.Model.Model_ErpCustomer model = ctbll.GetModel(Convert.ToInt32(this.aincontactID));
  375. model.Cus_OpenID = "";
  376. model.Cus_UpdateDateTime = SDateTime.Now;
  377. model.Cus_UpdateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  378. ctbll.Update(model);
  379. if (UnBindMicroData(model.Cus_CustomerNumber))
  380. {
  381. MessageBoxCustom.Show("解绑成功!");
  382. this.txtMicroID.Text = "未绑定";
  383. }
  384. else
  385. { MessageBoxCustom.Show("解绑失败"); }
  386. }
  387. }
  388. /// <summary>
  389. /// 获取生肖
  390. /// </summary>
  391. void txtBaby_Birthday_Leave(object sender, EventArgs e)
  392. {
  393. int intMasse = this.txtBaby_Birthday.CheckDateValue(this.txtBaby_Birthday, chkBaby_Lunar);
  394. if (intMasse == 1) { MessageBoxCustom.Show("宝贝生日日期格式输入错误"); return; }
  395. else if (intMasse == 2)
  396. { MessageBoxCustom.Show("宝贝生日:" + this.txtBaby_Birthday.StrValue.Trim() + "不是公历日期,若要保存请勾上农历"); return; }
  397. if (this.txtBaby_Birthday.StrValue.Trim().Length > 0)
  398. {
  399. string[] StrArrayList = this.txtBaby_Birthday.StrValue.Trim().Split('-');
  400. if (SDateTime.Now.Year < Convert.ToInt32(StrArrayList[0]))
  401. { MessageBoxCustom.Show("您输入的宝贝生日不能大于今年!"); return; }
  402. this.cmbBaby.Text = LYFZ.Command.Command_CalendarTurnLunar.GetZodiac(this.txtBaby_Birthday.StrValue.Trim(), this.chkBaby_Lunar.Checked);
  403. }
  404. else
  405. { this.cmbBaby.Text = ""; }
  406. //this.cmbBaby.Text = LYFZ.Command.Command_CalendarTurnLunar.GetZodiac(this.txtBaby_Birthday.StrValue.Trim(), this.chkBaby_Lunar.Checked);
  407. }
  408. /// <summary>
  409. /// 双击dgv事件
  410. /// </summary>
  411. void dgv2_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  412. {
  413. if (dgvData.SelectedRows.Count > 0)
  414. {
  415. FrmAddContacts from = new FrmAddContacts();
  416. from.YouID = dgvData.CurrentRow.Cells["ID"].Value.ToString().Trim();
  417. from.GP = GM;
  418. from.GMID = dgvData.CurrentRow.Cells["GMID"].Value.ToString().Trim();
  419. from.Zhuangtai = "编辑";
  420. if (from.ShowDialog() == DialogResult.OK)
  421. {
  422. if (dgvData.Rows.Count > 0)
  423. { dgvData.Rows.Clear(); }
  424. FrmOldCustomerEditBaby_Load(null, null);
  425. bl = true;
  426. }
  427. }
  428. }
  429. /// <summary>
  430. /// 添加联系人
  431. /// </summary>
  432. /// <param name="sender"></param>
  433. /// <param name="e"></param>
  434. void btnAdding_Click(object sender, EventArgs e)
  435. {
  436. FrmAddContacts frm = new FrmAddContacts();
  437. //状态
  438. frm.Zhuangtai = "添加";
  439. if (frm.ShowDialog() == DialogResult.OK)
  440. {
  441. if (frm.model != null)
  442. {
  443. List<Helper.CommandInfo> clist = new List<Helper.CommandInfo>();
  444. Model_ErpCustomer model = frm.model;
  445. Model_ErpCustomerGroupMembers modelGMitem = new Model_ErpCustomerGroupMembers();
  446. modelGMitem.GM_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
  447. modelGMitem.GM_CustomerGroupID = GM;
  448. modelGMitem.GM_CustomerID = model.Cus_CustomerNumber;
  449. modelGMitem.GM_Master = 0;
  450. modelGMitem.GM_ProtagonistCustomer = 0;
  451. modelGMitem.GM_RelatedPersonID = SerialnumberID;
  452. modelGMitem.GM_Relation = model.Cus_Relations;
  453. modelGMitem.GM_IsOrder = 0;
  454. modelGMitem.GM_IsOrderNumber = "";
  455. clist.Add(ctbll.GetAddCommandInfo(model));
  456. clist.Add(gmbll.GetAddCommandInfo(modelGMitem));
  457. if (clist.Count > 0)
  458. {
  459. if (LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist) >= 0)
  460. {
  461. DAL_ErpCustomer.UpdateAggregationCustomer(GM);
  462. bl = true;
  463. //日志
  464. LYFZ.BLL.BLL_ErpSystemLogs.WriteSystemLog(LYFZ.EnumPublic.SystemLogsType.添加客户资料, "联系人:" + frm.model.Cus_Name + ",添加联系人资料客户组:" + modelGMitem.GM_CustomerGroupID + ",时间:" + SDateTime.Now, LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID, LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name);
  465. MessageBoxCustom.Show("添加成功");
  466. if (dgvData.Rows.Count > 0)
  467. { dgvData.Rows.Clear(); }
  468. FrmOldCustomerEditBaby_Load(null, null);
  469. }
  470. else { MessageBoxCustom.Show("添加失败"); }
  471. return;
  472. }
  473. }
  474. }
  475. }
  476. /// <summary>
  477. /// 保存
  478. /// </summary>
  479. /// <param name="sender"></param>
  480. /// <param name="e"></param>
  481. void btnSave_Click(object sender, EventArgs e)
  482. {
  483. try
  484. {
  485. if (string.IsNullOrEmpty(this.txtCus_Name.Text))
  486. { MessageBoxCustom.Show("姓名不能为空"); return; }
  487. string StrPhone = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.MaskedTextBoxExGetText(this.txtCus_Telephone);
  488. if (!string.IsNullOrEmpty(StrPhone))
  489. {
  490. if (StrPhone.Length != 11)
  491. { MessageBoxCustom.Show("手机号码必须为11位数!"); return; }
  492. DataTable tblClient = orbll.GetView_Custom("tb_ErpCustomer", StrWhere: "Cus_Telephone = '" + StrPhone + "' and ID <> '" + aincontactID + "' ", ShowColumnName: "ID").Tables[0];
  493. if (tblClient.Rows.Count > 0)
  494. { MessageBoxCustom.Show("手机号已存在"); return; }
  495. }
  496. if (txtBaby_Birthday.StrValue.ToString() != "")
  497. {
  498. int intMasse1 = this.txtBaby_Birthday.CheckDateValue(this.txtBaby_Birthday, this.chkBaby_Lunar);
  499. if (intMasse1 == 1) { MessageBoxCustom.Show("宝宝生日日期格式输入错误!"); return; }
  500. else if (intMasse1 == 2)
  501. { MessageBoxCustom.Show("宝宝生日:" + this.txtBaby_Birthday.StrValue.Trim() + "不是公历日期,若要保存请勾上农历!"); return; }
  502. }
  503. int intMasse = this.txtCus_Birthday.CheckDateValue(this.txtCus_Birthday, chkCus_Lunar);
  504. if (intMasse == 1) { MessageBoxCustom.Show("客户日期日期格式输入错误"); return; }
  505. else if (intMasse == 2)
  506. { MessageBoxCustom.Show("客户日期:" + this.txtCus_Birthday.StrValue.Trim() + "不是公历日期,若要保存请勾上农历"); return; }
  507. List<Helper.CommandInfo> clist = new List<Helper.CommandInfo>();
  508. //儿童
  509. Model_ErpCustomer model = ctbll.GetModel(Convert.ToInt32(BabyID.Trim()));
  510. model.Cus_Name = LYFZ.BLL.OtherCommonModel.ClearSpecialCharacter(this.txtBaby_name.Text);
  511. model.Cus_NamePinyin = LYFZ.Command.Command_ChineseToPinyin.GetChineseSpellPinyin(model.Cus_Name).ToLower();
  512. if (this.radioBaby_nan.Checked == true)
  513. { model.Cus_Sex = false; }
  514. else
  515. { model.Cus_Sex = true; }
  516. model.Cus_Birthday = txtBaby_Birthday.StrValue.ToString();
  517. if (model.Cus_Birthday != "")
  518. {
  519. model.Cus_Zodiac = cmbBaby.Text;
  520. if (chkBaby_Lunar.Checked == true)
  521. { model.Cus_BirthdayLunar = "1"; }
  522. else { model.Cus_BirthdayLunar = "0"; }
  523. }
  524. else
  525. {
  526. model.Cus_Zodiac = "";
  527. model.Cus_BirthdayLunar = "";
  528. }
  529. model.Cus_Grade = this.cmbtreevlevel.Text.Trim();
  530. model.Cus_Type = "儿童";
  531. model.Cus_UpdateDateTime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
  532. model.Cus_UpdateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  533. clist.Add(ctbll.GetUpdateCommandInfo(model));
  534. //客户
  535. model = ctbll.GetModel(Convert.ToInt32(aincontactID));
  536. model.Cus_Type = "";
  537. model.Cus_Name = LYFZ.BLL.OtherCommonModel.ClearSpecialCharacter(this.txtCus_Name.Text);
  538. model.Cus_NamePinyin = LYFZ.Command.Command_ChineseToPinyin.GetChineseSpellPinyin(model.Cus_Name).ToLower();
  539. if (this.radCus_Nan.Checked)
  540. { model.Cus_Sex = false; }
  541. else { model.Cus_Sex = true; }
  542. model.Cus_Birthday = txtCus_Birthday.StrValue.Trim();
  543. if (model.Cus_Birthday != "")
  544. {
  545. model.Cus_Zodiac = LYFZ.Command.Command_CalendarTurnLunar.GetZodiac(this.txtCus_Birthday.StrValue.Trim(), this.chkCus_Lunar.Checked);
  546. if (chkCus_Lunar.Checked == true)
  547. { model.Cus_BirthdayLunar = "1"; }
  548. else
  549. { model.Cus_BirthdayLunar = "0"; }
  550. }
  551. else
  552. {
  553. model.Cus_Zodiac = "";
  554. model.Cus_BirthdayLunar = "";
  555. }
  556. model.Cus_QQ = this.txtCus_QQ.Text.ToString();
  557. model.Cus_MicroSignal = this.txtCus_MicroSignal.Text.ToString();
  558. model.Cus_Telephone = StrPhone;
  559. model.Cus_FixedPhone = this.txtCus_FixedPhone.Text.ToString();
  560. model.Cus_Region = this.cmbCus_Region.Text.ToString();
  561. model.Cus_Address = this.txtCus_Address.Text.ToString();
  562. model.Cus_WorkUnit = this.txtCus_WorkUnit.Text.ToString();
  563. model.Cus_Grade = "";
  564. model.Cus_UpdateDateTime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
  565. model.Cus_UpdateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  566. //客人信息放入集合
  567. clist.Add(ctbll.GetUpdateCommandInfo(model));
  568. string laiyuan = "";
  569. if (this.chkLKH.Checked == true)
  570. { laiyuan = "老客户"; }
  571. if (this.chkPYJS.Checked == true)
  572. { laiyuan = "朋友介绍"; }
  573. if (chkQT.Checked == true)
  574. { laiyuan = cmbCus_CustomerSource.Text; }
  575. //修改客户关系
  576. Model.Model_ErpCustomerGroupMembers modelGM = gmbll.GetModel(Convert.ToInt32(GMID));
  577. modelGM.GM_Relation = this.cmbtreevRelations.Text.Trim();
  578. clist.Add(gmbll.GetUpdateCommandInfo(modelGM));
  579. //修改客户来源
  580. BLL_ErpCustomerGroup GPbll = new BLL_ErpCustomerGroup();
  581. Model.Model_ErpCustomerGroup modelGP = GPbll.GetModel("GP_CustomerGroupID", GM);
  582. modelGP.GP_CustomerSource = laiyuan;
  583. clist.Add(GPbll.GetUpdateCommandInfo(modelGP));
  584. //新增 老客户历史记录表
  585. if (model_ooh != null)
  586. {
  587. model_ooh.History_Type = txtHistory_Type.Text;
  588. if (txtHistory_Money.Text != "")
  589. { model_ooh.History_Money = Convert.ToInt32(txtHistory_Money.Text); }
  590. else { model_ooh.History_Money = 0; }
  591. if (txtHistory_OrderTime.StrValue != "")
  592. {
  593. if (txtHistory_OrderTime.CheckDateValue(this.txtHistory_OrderTime) != 1)
  594. { model_ooh.History_OrderTime = Convert.ToDateTime(txtHistory_OrderTime.Text); }
  595. else
  596. { model_ooh.History_OrderTime = LYFZ.WinAPI.CustomPublicMethod.GetNullDateTime(); }
  597. }
  598. else
  599. { model_ooh.History_OrderTime = LYFZ.WinAPI.CustomPublicMethod.GetNullDateTime(); }
  600. clist.Add(Bll_ooh.GetUpdateCommandInfo(model_ooh));
  601. }//如果等于空 判断是否新建
  602. else if (txtHistory_Type.Text != "" && txtHistory_Money.Text != "")
  603. {
  604. model_ooh = new Model_OldOrderHistory();
  605. model_ooh.History_ID = GM;
  606. model_ooh.History_Type = txtHistory_Type.Text;
  607. model_ooh.History_Money = Convert.ToInt32(txtHistory_Money.Text);
  608. if (txtHistory_OrderTime.StrValue != "")
  609. {
  610. if (txtHistory_OrderTime.CheckDateValue(this.txtHistory_OrderTime) != 1)
  611. { model_ooh.History_OrderTime = Convert.ToDateTime(txtHistory_OrderTime.Text); }
  612. else { model_ooh.History_OrderTime = LYFZ.WinAPI.CustomPublicMethod.GetNullDateTime(); }
  613. }
  614. else { model_ooh.History_OrderTime = LYFZ.WinAPI.CustomPublicMethod.GetNullDateTime(); }
  615. model_ooh.History_CurrentTime = SDateTime.Now;
  616. model_ooh.History_CurrentID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  617. clist.Add(Bll_ooh.GetAddCommandInfo(model_ooh));
  618. }
  619. if (clist.Count > 0)
  620. {
  621. if (MessageBoxCustom.Show("您确定要保存吗?", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.No)
  622. { return; }
  623. if (LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist) > 0)
  624. {
  625. DAL_ErpCustomer.UpdateAggregationCustomer(GM);
  626. bl = true;
  627. //日志
  628. 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);
  629. MessageBoxCustom.Show("保存成功");
  630. clist.Clear();
  631. }
  632. else
  633. { MessageBoxCustom.Show("保存失败"); }
  634. }
  635. }
  636. catch (Exception ex)
  637. { MessageBoxCustom.Show(ex.Message); }
  638. }
  639. /// <summary>
  640. /// 删除
  641. /// </summary>
  642. /// <param name="sender"></param>
  643. /// <param name="e"></param>
  644. void btnDelete_Click(object sender, EventArgs e)
  645. {
  646. if (this.dgvData.SelectedRows.Count > 0)
  647. {
  648. if (MessageBoxCustom.Show("是否删除?", "删除", MessageBoxButtons.YesNo) == DialogResult.Yes)
  649. {
  650. if (gmbll.Delete(Convert.ToInt32(this.dgvData.CurrentRow.Cells["GMID"].Value.ToString().Trim())) && ctbll.Delete(Convert.ToInt32(this.dgvData.CurrentRow.Cells["ID"].Value.ToString().Trim())))
  651. {
  652. DAL_ErpCustomer.UpdateAggregationCustomer(GM);
  653. //日志
  654. LYFZ.BLL.BLL_ErpSystemLogs.WriteSystemLog(LYFZ.EnumPublic.SystemLogsType.删除客户资料, "联系人:" + this.dgvData.CurrentRow.Cells["CusName"].Value.ToString() + ",删除联系人资料的客户组:" + this.dgvData.CurrentRow.Cells["GMID"].Value.ToString() + ",时间:" + SDateTime.Now, LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID, LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name);
  655. MessageBoxCustom.Show("删除成功!");
  656. bl = true;
  657. this.FrmOldCustomerEditBaby_Load(null, null);
  658. }
  659. }
  660. }
  661. else { MessageBoxCustom.Show("请选择删除内容"); }
  662. }
  663. /// <summary>
  664. /// 关闭
  665. /// </summary>
  666. /// <param name="sender"></param>
  667. /// <param name="e"></param>
  668. void btnClose_Click(object sender, EventArgs e)
  669. {
  670. this.Close();
  671. }
  672. /// <summary>
  673. /// 设置客户等级
  674. /// </summary>
  675. /// <param name="sender"></param>
  676. /// <param name="e"></param>
  677. void btnlevel_Click(object sender, EventArgs e)
  678. {
  679. LYFZ.Software.MainBusiness.InitialSet.FrmSystemSet set = new InitialSet.FrmSystemSet();
  680. set.TypeName = "BFADBIBEFCFCIDCDG";
  681. set.Version = "Version";
  682. if (set.ShowDialog() == DialogResult.OK)
  683. { LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory("BFADBIBEFCFCIDCDG", this.cmbtreevlevel, IsFirstNodeNull: true); }
  684. }
  685. /// <summary>
  686. /// 设置客户来源
  687. /// </summary>
  688. /// <param name="sender"></param>
  689. /// <param name="e"></param>
  690. void btnCustomerSource_Click(object sender, EventArgs e)
  691. {
  692. LYFZ.Software.MainBusiness.InitialSet.FrmSystemSet set = new InitialSet.FrmSystemSet();
  693. set.TypeName = "AAAAAAF";
  694. set.Version = "Version";
  695. if (set.ShowDialog() == DialogResult.OK)
  696. { LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_ClientSourec("AAAAAAF", this.cmbCus_CustomerSource, strHideFiled: "BFACBABGBGBJGDHIE,BFAFBCBADBDCABFDD"); }
  697. }
  698. /// <summary>
  699. /// 设置客户区域
  700. /// </summary>
  701. /// <param name="sender"></param>
  702. /// <param name="e"></param>
  703. void btnRegion_Click(object sender, EventArgs e)
  704. {
  705. LYFZ.Software.MainBusiness.InitialSet.FrmSystemSet set = new InitialSet.FrmSystemSet();
  706. set.TypeName = "AAAAAAC";
  707. set.Version = "Version";
  708. if (set.ShowDialog() == DialogResult.OK)
  709. { LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_ClientSourec("AAAAAAC", this.cmbCus_Region, strHideFiled: ""); }
  710. }
  711. /// <summary>
  712. /// 返回日历类别
  713. /// </summary>
  714. /// <param name="lun"></param>
  715. /// <returns></returns>
  716. string Lunar(string lun)
  717. {
  718. string luns = "";
  719. switch (lun)
  720. {
  721. case "0":
  722. luns = "公历";
  723. break;
  724. case "1":
  725. luns = "农历";
  726. break;
  727. case "2":
  728. luns = "农历润月";
  729. break;
  730. }
  731. return luns;
  732. }
  733. /// <summary>
  734. /// 文本框输入
  735. /// </summary>
  736. /// <param name="sender"></param>
  737. /// <param name="e"></param>
  738. void txtHistory_Money_KeyPress(object sender, KeyPressEventArgs e)
  739. {
  740. if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar))
  741. { e.Handled = true; }
  742. }
  743. /// <summary>
  744. /// 文本框输入
  745. /// </summary>
  746. /// <param name="sender"></param>
  747. /// <param name="e"></param>
  748. void txtCus_FixedPhone_KeyPress(object sender, KeyPressEventArgs e)
  749. {
  750. if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar))
  751. { e.Handled = true; }
  752. }
  753. /// <summary>
  754. /// 文本框输入
  755. /// </summary>
  756. /// <param name="sender"></param>
  757. /// <param name="e"></param>
  758. void txtCus_Telephone_KeyPress(object sender, KeyPressEventArgs e)
  759. {
  760. if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar))
  761. { e.Handled = true; }
  762. }
  763. /// <summary>
  764. /// 文本框输入
  765. /// </summary>
  766. /// <param name="sender"></param>
  767. /// <param name="e"></param>
  768. void txtCus_QQ_KeyPress(object sender, KeyPressEventArgs e)
  769. {
  770. if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar))
  771. { e.Handled = true; }
  772. }
  773. /// <summary>
  774. /// 单选框事件
  775. /// </summary>
  776. /// <param name="sender"></param>
  777. /// <param name="e"></param>
  778. void chkQT_Click(object sender, EventArgs e)
  779. {
  780. this.chkLKH.Checked = false;
  781. this.chkPYJS.Checked = false;
  782. this.cmbCus_CustomerSource.Enabled = true;
  783. }
  784. /// <summary>
  785. /// 单选框事件
  786. /// </summary>
  787. /// <param name="sender"></param>
  788. /// <param name="e"></param>
  789. void chkPYJS_Click(object sender, EventArgs e)
  790. {
  791. this.cmbCus_CustomerSource.Enabled = false;
  792. this.chkLKH.Checked = false;
  793. this.chkQT.Checked = false;
  794. }
  795. /// <summary>
  796. /// 单选框事件
  797. /// </summary>
  798. /// <param name="sender"></param>
  799. /// <param name="e"></param>
  800. void chkLKH_Click(object sender, EventArgs e)
  801. {
  802. this.chkPYJS.Checked = false;
  803. this.chkQT.Checked = false;
  804. this.cmbCus_CustomerSource.Enabled = false;
  805. }
  806. }
  807. }