FrmOldCustomerEdit.cs 36 KB

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