FrmOldCustomer.cs 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.Globalization;
  10. using LYFZ.ComponentLibrary;
  11. using System.Web.UI.WebControls;
  12. using LYFZ.DAL;
  13. using LYFZ.Software.MainBusiness.Customers.OldCustomer;
  14. using LYFZ.BLL;
  15. namespace LYFZ.Software.MainBusiness.Customers
  16. {
  17. public partial class FrmOldCustomer : LYFZ.Software.UI.Customers.FrmOldCustomer
  18. {
  19. private delegate void UpdateControl();
  20. public FrmOldCustomer()
  21. {
  22. this.btnAdd.Click += btnAdd_Click;
  23. this.btnUpdate.Click += btnUpdate_Click;
  24. this.btnSlect.Click += btnSlect_Click;
  25. this.btnDelete.Click += btnDelete_Click;
  26. this.btnExport.Click += btnExport_Click;
  27. this.btnClose.Click += btnClose_Click;
  28. this.btnTexting.Click += btnTexting_Click;
  29. this.Shown += FrmOldCustomer_Shown;
  30. this.chkHs.Click += chkHs_Click;
  31. this.chkEt.Click += chkEt_Click;
  32. this.chkXz.Click += chkXz_Click;
  33. this.chkFw.Click += chkFw_Click;
  34. this.Type = 1;
  35. this.btnExcel.Click += btnExcel_Click;
  36. this.dgv.CellDoubleClick += dgv_CellDoubleClick;
  37. this.Resize += FrmOldCustomer_Resize;
  38. orbll.UpdateNullDataToLunar();
  39. // 虚拟模式;
  40. this.dgv.VirtualMode = true;
  41. this.dgv.CellValueNeeded += Dgv_CellValueNeeded;
  42. }
  43. DataTable newTable = new DataTable();
  44. private void Dgv_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e)
  45. {
  46. if (newTable != null && newTable.Rows.Count == 0 && e.RowIndex == newTable.Rows.Count)
  47. return;
  48. DataGridViewRow dgr = this.dgv.Rows[e.RowIndex];
  49. if (e.RowIndex % 2 == 0)
  50. {//偶行;
  51. dgr.DefaultCellStyle.BackColor = System.Drawing.Color.PowderBlue;
  52. }
  53. else
  54. {//奇行;
  55. dgr.DefaultCellStyle.BackColor = System.Drawing.Color.PapayaWhip;
  56. }
  57. //客户组编号
  58. if (e.ColumnIndex == 0)
  59. e.Value = newTable.Rows[e.RowIndex]["GP_CustomerGroupID"].ToString().Trim();
  60. //名字
  61. if (e.ColumnIndex == 1)
  62. e.Value = newTable.Rows[e.RowIndex]["Cus_Name"].ToString().Trim();
  63. //性别
  64. if (e.ColumnIndex == 2)
  65. e.Value = newTable.Rows[e.RowIndex]["Cus_Sex_cs"].ToString().Trim();
  66. //手机
  67. if (e.ColumnIndex == 3)
  68. e.Value = newTable.Rows[e.RowIndex]["Cus_Telephone"].ToString().Trim();
  69. //区域
  70. if (e.ColumnIndex == 4)
  71. e.Value = newTable.Rows[e.RowIndex]["Cus_Region"].ToString().Trim();
  72. //客户类型 0 为婚纱订单客户 1 为儿童订单客户 2 写真订单客户 3 为服务套系 4 为其它订单客户
  73. if (e.ColumnIndex == 5)
  74. e.Value = GetType(newTable.Rows[e.RowIndex]["GP_CustomerType"].ToString().Trim());
  75. //客户来源;
  76. if (e.ColumnIndex == 6)
  77. e.Value = newTable.Rows[e.RowIndex]["GP_CustomerSource"].ToString().Trim();
  78. //客户生日
  79. if (e.ColumnIndex == 7)
  80. e.Value = newTable.Rows[e.RowIndex]["Cus_BirthdayText"].ToString().Trim();
  81. //客户婚期
  82. if (e.ColumnIndex == 8)
  83. e.Value = newTable.Rows[e.RowIndex]["Cus_DayForMarriageText"].ToString().Trim();
  84. //添加时间
  85. if (e.ColumnIndex == 9)
  86. e.Value = newTable.Rows[e.RowIndex]["GP_CreateDatetime"].ToString().Trim();
  87. //套系名称
  88. if (e.ColumnIndex == 10)
  89. e.Value = newTable.Rows[e.RowIndex]["History_Type"].ToString().Trim();
  90. //套系价格
  91. if (e.ColumnIndex == 11)
  92. e.Value = newTable.Rows[e.RowIndex]["History_Money"].ToString().Trim();
  93. //订单时间
  94. if (e.ColumnIndex == 12)
  95. e.Value = newTable.Rows[e.RowIndex]["History_OrderTime"].ToString().Trim();
  96. }
  97. /// <summary>
  98. /// 客户类型
  99. /// </summary>
  100. public int Type;
  101. LYFZ.BLL.BLL_ErpOrder orbll = new BLL_ErpOrder();
  102. LYFZ.BLL.BLL_ErpCustomer ctbll = new BLL_ErpCustomer();
  103. LYFZ.BLL.BLL_ErpCustomerGroup cgbll = new BLL.BLL_ErpCustomerGroup();
  104. LYFZ.BLL.BLL_ErpCustomerGroupMembers cgmbll = new BLL.BLL_ErpCustomerGroupMembers();
  105. LYFZ.BLL.BLL_OldOrderHistory oohbll = new BLL.BLL_OldOrderHistory();
  106. LYFZ.BLL.BLL_ErpSystemLogs slogbll = new BLL_ErpSystemLogs();
  107. List<LYFZ.Software.MainBusiness.EnumPermissions.BusinessType> Versions = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetBusinessTypeList();
  108. /// <summary>
  109. /// 窗体加载事件
  110. /// </summary>
  111. /// <param name="sender"></param>
  112. /// <param name="e"></param>
  113. void FrmOldCustomer_Shown(object sender, EventArgs e)
  114. {
  115. this.chkEt.Visible = false;
  116. this.chkXz.Visible = false;
  117. this.chkHs.Visible = false;
  118. for (int i = 0; i < this.Versions.Count; i++)
  119. {
  120. LYFZ.Software.MainBusiness.EnumPermissions.BusinessType Version = this.Versions[i];
  121. if (Version.ToString() == EnumPermissions.BusinessType.写真版.ToString())
  122. { this.chkXz.Visible = true; }
  123. if (Version.ToString() == EnumPermissions.BusinessType.婚纱版.ToString())
  124. { this.chkHs.Visible = true; }
  125. if (Version.ToString() == EnumPermissions.BusinessType.儿童版.ToString())
  126. { this.chkEt.Visible = true; }
  127. }
  128. this.PublicFunctionRows();
  129. this.btnAdd.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.OldCustomerCompetence, CustomAttributes.OperatingAuthority.Add);
  130. this.btnUpdate.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.OldCustomerCompetence, CustomAttributes.OperatingAuthority.Update);
  131. this.btnDelete.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.OldCustomerCompetence, CustomAttributes.OperatingAuthority.Delete);
  132. this.btnExport.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.OldCustomerCompetence, CustomAttributes.OperatingAuthority.DataExport);
  133. this.btnTexting.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.OldCustomerCompetence, CustomAttributes.OperatingAuthority.SMSSend);
  134. this.btnExcel.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.OldCustomerCompetence, LYFZ.CustomAttributes.OperatingAuthority.DataImport);
  135. }
  136. /// <summary>
  137. /// 查询
  138. /// </summary>
  139. /// <param name="sender"></param>
  140. /// <param name="e"></param>
  141. void btnSlect_Click(object sender, EventArgs e)
  142. { this.PublicFunctionRows(); }
  143. /// <summary>
  144. /// 增加
  145. /// </summary>
  146. /// <param name="sender"></param>
  147. /// <param name="e"></param>
  148. void btnAdd_Click(object sender, EventArgs e)
  149. {
  150. string StrClientType = "";
  151. if (this.chkHs.Checked == false && this.chkEt.Checked == false && this.chkXz.Checked == false && this.chkFw.Checked == false)
  152. {
  153. FrmOrdersCustomerRecord frm = new FrmOrdersCustomerRecord();
  154. if (frm.ShowDialog() == DialogResult.OK)
  155. { StrClientType = frm.DindanType.Trim(); }
  156. else
  157. { return; }
  158. }
  159. if (chkHs.Checked || StrClientType == "0")//0 为婚纱订单客户
  160. {
  161. LYFZ.Software.MainBusiness.Customers.OldCustomer.FrmOldCustomerOtheEdit frmHS = new OldCustomer.FrmOldCustomerOtheEdit();
  162. frmHS.type = this.Type;
  163. if (frmHS.ShowDialog() == DialogResult.OK)
  164. { this.PublicFunctionRows(); }
  165. }
  166. else if (chkEt.Checked || StrClientType == "1")//1 为儿童订单客户
  167. {
  168. LYFZ.Software.MainBusiness.Customers.OldCustomer.FrmOldCustomerPortraitEdit frmET = new OldCustomer.FrmOldCustomerPortraitEdit();
  169. frmET.type = this.Type;
  170. if (frmET.ShowDialog() == DialogResult.OK)
  171. { this.PublicFunctionRows(); }
  172. }
  173. else if (chkXz.Checked || StrClientType == "2") // 2 写真订单客户
  174. {
  175. LYFZ.Software.MainBusiness.Customers.OldCustomer.FrmOldCustomerPortraitAdd frmXZ = new OldCustomer.FrmOldCustomerPortraitAdd();
  176. frmXZ.type = this.Type;
  177. if (frmXZ.ShowDialog() == DialogResult.OK)
  178. { this.PublicFunctionRows(); }
  179. }
  180. else if (chkFw.Checked || StrClientType == "3")// 3 为服务套系
  181. {
  182. LYFZ.Software.MainBusiness.Customers.OldCustomer.FrmOldCustomerOtherAdd frmFW = new OldCustomer.FrmOldCustomerOtherAdd();
  183. frmFW.type = this.Type;
  184. if (frmFW.ShowDialog() == DialogResult.OK)
  185. { this.PublicFunctionRows(); }
  186. }
  187. }
  188. /// <summary>
  189. /// 双击列表修改
  190. /// </summary>
  191. /// <param name="sender"></param>
  192. /// <param name="e"></param>
  193. void dgv_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  194. {
  195. try
  196. {
  197. if (e.RowIndex >= 0 && e.ColumnIndex >= 0)
  198. {
  199. if (this.dgv.SelectedRows.Count > 0)
  200. {
  201. if (!LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.OldCustomerCompetence, CustomAttributes.OperatingAuthority.Update))
  202. { return; }
  203. if (this.dgv.CurrentRow.Cells["GP_CustomerType"].Value.ToString() == "儿童客户")
  204. {
  205. FrmOldCustomerEditBaby from = new FrmOldCustomerEditBaby();
  206. from.GM = this.dgv.CurrentRow.Cells["GP_CustomerGroupID"].Value.ToString();
  207. from.type = this.Type;
  208. if (from.ShowDialog() == DialogResult.OK)
  209. { this.PublicFunctionRows(); }
  210. }
  211. else
  212. {
  213. FrmOldCustomerEdit from = new FrmOldCustomerEdit();
  214. from.GM = this.dgv.CurrentRow.Cells["GP_CustomerGroupID"].Value.ToString();
  215. from.Leixing = this.dgv.CurrentRow.Cells["GP_CustomerType"].Value.ToString();
  216. from.type = this.Type;
  217. if (from.ShowDialog() == DialogResult.OK)
  218. { this.PublicFunctionRows(); }
  219. }
  220. }
  221. }
  222. }
  223. catch (Exception ex)
  224. { MessageBoxCustom.Show(ex.Message); }
  225. }
  226. /// <summary>
  227. /// 修改
  228. /// </summary>
  229. /// <param name="sender"></param>
  230. /// <param name="e"></param>
  231. void btnUpdate_Click(object sender, EventArgs e)
  232. {
  233. try
  234. {
  235. if (this.dgv.SelectedRows.Count == 0)
  236. { MessageBoxCustom.Show("请选择你要编辑的数据!"); return; }
  237. if (this.dgv.CurrentRow.Cells["GP_CustomerType"].Value.ToString() == "儿童客户")
  238. {
  239. FrmOldCustomerEditBaby from = new FrmOldCustomerEditBaby();
  240. from.GM = this.dgv.CurrentRow.Cells["GP_CustomerGroupID"].Value.ToString();
  241. from.type = this.Type;
  242. if (from.ShowDialog() == DialogResult.OK)
  243. { this.PublicFunctionRows(); }
  244. }
  245. else
  246. {
  247. FrmOldCustomerEdit from = new FrmOldCustomerEdit();
  248. from.GM = this.dgv.CurrentRow.Cells["GP_CustomerGroupID"].Value.ToString();
  249. from.Leixing = this.dgv.CurrentRow.Cells["GP_CustomerType"].Value.ToString();
  250. from.type = this.Type;
  251. if (from.ShowDialog() == DialogResult.OK)
  252. { this.PublicFunctionRows(); }
  253. }
  254. }
  255. catch (Exception ex)
  256. { MessageBoxCustom.Show(ex.Message); }
  257. }
  258. /// <summary>
  259. /// 删除
  260. /// </summary>
  261. /// <param name="sender"></param>
  262. /// <param name="e"></param>
  263. void btnDelete_Click(object sender, EventArgs e)
  264. {
  265. try
  266. {
  267. if (this.dgv.SelectedRows.Count == 0)
  268. {
  269. MessageBoxCustom.Show("请选中你要删除的数据!");
  270. return;
  271. }
  272. if (MessageBoxCustom.Show("你确定要删除吗?", "删除提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
  273. {
  274. List<Helper.CommandInfo> clist = new List<Helper.CommandInfo>();
  275. List<string> StrGroupList = new List<string>();
  276. for (int i = 0; i < this.dgv.SelectedRows.Count; i++)
  277. { StrGroupList.Add(this.dgv.SelectedRows[i].Cells["GP_CustomerGroupID"].Value.ToString().Trim()); }
  278. int IsExecuteSqlTran = 0;
  279. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  280. {
  281. for (int i = 0; i < StrGroupList.Count; i++)
  282. {
  283. clist.Add(cgmbll.GetDeleteCommandInfo(whereStr: "GM_CustomerGroupID='" + StrGroupList[i].Trim() + "' "));
  284. clist.Add(cgbll.GetDeleteCommandInfo(whereStr: "GP_CustomerGroupID='" + StrGroupList[i].Trim() + "'"));
  285. clist.Add(oohbll.GetDeleteCommandInfo(whereStr: "History_ID='" + StrGroupList[i].Trim() + "'"));
  286. DataTable tblGroupMembers = orbll.GetView_Custom("tb_ErpCustomerGroupMembers", StrWhere: "GM_CustomerGroupID = '" + StrGroupList[i].Trim() + "'", ShowColumnName: "GM_CustomerID").Tables[0];
  287. for (int j = 0; j < tblGroupMembers.Rows.Count; j++)
  288. {
  289. DataTable tblClient = orbll.GetView_Custom("tb_ErpCustomer", StrWhere: "Cus_CustomerNumber = '" + tblGroupMembers.Rows[j]["GM_CustomerID"].ToString().Trim() + "'", ShowColumnName: "Cus_Name,Cus_Telephone").Tables[0];
  290. DataTable tblTwoSales = orbll.GetView_Custom("tb_ErpTwoSalesOrder", StrWhere: "Tsorder_CustomerNumber = '" + tblGroupMembers.Rows[j]["GM_CustomerID"].ToString().Trim() + "'", ShowColumnName: "ID").Tables[0];
  291. DataTable tblGroupMembers2 = orbll.GetView_Custom("tb_ErpCustomerGroupMembers", StrWhere: "GM_CustomerGroupID != '" + StrGroupList[i].Trim() + "' And GM_CustomerID = '" + tblGroupMembers.Rows[j]["GM_CustomerID"].ToString().Trim() + "'", ShowColumnName: "ID").Tables[0];
  292. if (tblTwoSales.Rows.Count <= 0 && tblGroupMembers2.Rows.Count <= 0)
  293. {
  294. DataTable dt = orbll.GetView_Custom("tb_ErpMemberCard", StrWhere: "Mc_CustomerNumber = '" + tblGroupMembers.Rows[j]["GM_CustomerID"].ToString().Trim() + "' And Mc_Status = '1' And Mc_CradNumber != ''", ShowColumnName: "ID").Tables[0];
  295. if (dt.Rows.Count <= 0)
  296. { clist.Add(ctbll.GetDeleteCommandInfo(whereStr: "Cus_CustomerNumber='" + tblGroupMembers.Rows[j]["GM_CustomerID"].ToString().Trim() + "'")); }
  297. if (tblClient.Rows.Count > 0)
  298. {
  299. clist.Add(slogbll.GetAddCommandInfo(LYFZ.BLL.BLL_ErpSystemLogs.GetWriteLogModel(LYFZ.EnumPublic.SystemLogsType.删除客户资料, "删除联系人:" + tblClient.Rows[0]["Cus_Name"].ToString().Trim() + ",电话:" + tblClient.Rows[0]["Cus_Telephone"].ToString().Trim() + "客户编号:" + tblGroupMembers.Rows[j]["GM_CustomerID"].ToString().Trim() + ",时间:" + SDateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID, LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name, StrInfoID: LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID())));
  300. }
  301. }
  302. else
  303. { clist.Add(slogbll.GetAddCommandInfo(LYFZ.BLL.BLL_ErpSystemLogs.GetWriteLogModel(LYFZ.EnumPublic.SystemLogsType.删除客户资料, "删除客户组编号:" + StrGroupList[i].Trim() + ",时间:" + SDateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID, LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name, StrInfoID: LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID()))); }
  304. }
  305. }
  306. if (clist.Count > 0)
  307. {
  308. IsExecuteSqlTran = LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist);
  309. if (IsExecuteSqlTran > 0)
  310. {
  311. for (int i = 0; i < StrGroupList.Count; i++)
  312. { DAL_ErpCustomer.UpdateAggregationCustomer(StrGroupList[i].Trim()); }
  313. }
  314. }
  315. });
  316. if (IsExecuteSqlTran > 0)
  317. {
  318. MessageBoxCustom.Show("删除成功!");
  319. this.PublicFunctionRows();
  320. }
  321. else
  322. { MessageBoxCustom.Show("删除失败!"); }
  323. ////批量删除 速度过慢
  324. //List<Helper.CommandInfo> ctlist = new List<Helper.CommandInfo>();
  325. //List<string> datelist = new List<string>();
  326. //List<string> namelist = new List<string>();
  327. //StringBuilder where = new StringBuilder();
  328. //int DeleteCount = 0;
  329. //LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  330. //{
  331. // //串客户组ID
  332. // for (int i = 0; i < dgv.SelectedRows.Count; i++)
  333. // {
  334. // if (i + 1 != dgv.SelectedRows.Count)
  335. // { where.Append("'" + dgv.SelectedRows[i].Cells["GP_CustomerGroupID"].Value.ToString().Trim() + "',"); }
  336. // else
  337. // { where.Append("'" + dgv.SelectedRows[i].Cells["GP_CustomerGroupID"].Value.ToString().Trim() + "'"); }
  338. // }
  339. // //根据客户组查客户ID
  340. // DataTable dtList = orbll.GetView_Custom("SELECT GM_CustomerID FROM tb_ErpCustomerGroupMembers where GM_CustomerGroupID in (" + where.ToString() + ") group by GM_CustomerID ").Tables[0];
  341. // foreach (DataGridViewRow item in dgv.SelectedRows)
  342. // {
  343. // ctlist.Add(cgmbll.GetDeleteCommandInfo(whereStr: "GM_CustomerGroupID='" + item.Cells["GP_CustomerGroupID"].Value.ToString() + "' "));
  344. // ctlist.Add(cgbll.GetDeleteCommandInfo(whereStr: "GP_CustomerGroupID='" + item.Cells["GP_CustomerGroupID"].Value.ToString() + "'"));
  345. // ctlist.Add(oohbll.GetDeleteCommandInfo(whereStr: "History_ID='" + item.Cells["GP_CustomerGroupID"].Value.ToString() + "'"));
  346. // datelist.Add(item.Cells["GP_CustomerGroupID"].Value.ToString());
  347. // namelist.Add(item.Cells["Cus_Name"].Value.ToString());
  348. // }
  349. // DeleteCount = LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(ctlist);
  350. //if (DeleteCount > 0)
  351. //{
  352. // string Cusid = "";
  353. // //串客户ID
  354. // foreach (DataRow row in dtList.Rows)
  355. // { Cusid += "'" + row[0].ToString() + "',"; }
  356. // Cusid = Cusid.Substring(0, Cusid.Length - 1);
  357. // //查二消表
  358. // DataTable dtTwo = orbll.GetView_Custom("select Tsorder_CustomerNumber from tb_ErpTwoSalesOrder where Tsorder_CustomerNumber in (" + Cusid + ")").Tables[0];
  359. // //查客户成员表
  360. // DataTable dtCus = orbll.GetView_Custom("select GM_CustomerID from tb_ErpCustomerGroupMembers where GM_CustomerID in (" + Cusid + ")").Tables[0];
  361. // //循环客户ID次数
  362. // for (int i = 0; i < Cusid.Split(',').Length; i++)
  363. // {
  364. // //如果二消表或者 成员表都没有数据可直接删除
  365. // if (dtTwo.Select(" Tsorder_CustomerNumber = " + Cusid.Split(',')[i].ToString() + "").Length < 1 && dtCus.Select("GM_CustomerID=" + Cusid.Split(',')[i].ToString()).Length < 1)
  366. // { ctbll.Delete("Cus_CustomerNumber=" + Cusid.Split(',')[i].ToString()); }
  367. // }
  368. // foreach (string item in namelist)
  369. // {
  370. // //日志
  371. // LYFZ.BLL.BLL_ErpSystemLogs.WriteSystemLog(LYFZ.EnumPublic.SystemLogsType.删除客户资料, "删除联系人资料:" + item + ",时间:" + SDateTime.Now, LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID, LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name);
  372. // }
  373. // foreach (string item in datelist)
  374. // { DAL_ErpCustomer.UpdateAggregationCustomer(item); }
  375. //}
  376. //});
  377. //if (DeleteCount > 0)
  378. //{
  379. // this.Bind();
  380. // MessageBoxCustom.Show("删除成功!");
  381. //}
  382. //else
  383. //{ MessageBoxCustom.Show("删除失败!"); }
  384. }
  385. }
  386. catch (Exception ex)
  387. { MessageBoxCustom.Show(ex.Message); }
  388. }
  389. /// <summary>
  390. /// 关闭
  391. /// </summary>
  392. /// <param name="sender"></param>
  393. /// <param name="e"></param>
  394. void btnClose_Click(object sender, EventArgs e)
  395. {
  396. this.Close();
  397. }
  398. /// <summary>
  399. /// 导出
  400. /// </summary>
  401. /// <param name="sender"></param>
  402. /// <param name="e"></param>
  403. void btnExport_Click(object sender, EventArgs e)
  404. {
  405. this.dgv.ExportDataTable();
  406. }
  407. /// <summary>
  408. /// 发短信
  409. /// </summary>
  410. /// <param name="sender"></param>
  411. /// <param name="e"></param>
  412. void btnTexting_Click(object sender, EventArgs e)
  413. {
  414. try
  415. {
  416. string Sj1 = "";
  417. LYFZ.Software.MainBusiness.SMSManagement.SmsSend.FrmSendSms set = new SMSManagement.SmsSend.FrmSendSms();
  418. if (dgv.SelectedRows.Count == 0)
  419. {
  420. MessageBoxCustom.Show("选择你要发送短信的客户!");
  421. return;
  422. }
  423. for (int i = 0; i < dgv.SelectedRows.Count; i++)
  424. {
  425. //检查手机合法性
  426. string tempPhones = this.dgv.SelectedRows[i].Cells["客户电话"].Value.ToString();
  427. string okPhones = "";
  428. LYFZ.WinAPI.CustomPublicMethod.ValidationPhones(tempPhones.Replace('/', ','), ref okPhones);
  429. okPhones = okPhones.Trim().Trim(',');
  430. foreach (string phone in okPhones.Split(','))
  431. {
  432. if (phone.Trim().Length >= 11 && !Sj1.Contains(phone))
  433. { Sj1 += phone + ","; }
  434. }
  435. }
  436. set.Phone = Sj1.Trim(',');
  437. set.ShowDialog();
  438. }
  439. catch (Exception ex)
  440. { MessageBoxCustom.Show(ex.Message); }
  441. }
  442. /// <summary>
  443. /// 创建行
  444. /// </summary>
  445. void PublicFunctionRows()
  446. {
  447. if (this.dgv.Rows.Count > 0)
  448. { this.dgv.Rows.Clear(); }
  449. StringBuilder str = new StringBuilder();
  450. string keyword = this.cmbQueryText.Text.Trim();
  451. str.Append(" and tempTB_AggregationCustomer.GP_GroupType='1' ");
  452. if (!string.IsNullOrEmpty(keyword))
  453. {
  454. str.Append(" and (Cus_Name like '%" + keyword + "%' or Cus_Name_py like '%" + keyword + "%' or Cus_Telephone like '%" + keyword + "%' or Cus_Region like '%" + keyword + "%') ");
  455. if (chkFw.Checked)//服务
  456. { str.Append(" and tempTB_AggregationCustomer.GP_CustomerType = '3' "); }
  457. else if (chkHs.Checked)//婚纱
  458. { str.Append(" and tempTB_AggregationCustomer.GP_CustomerType = '0' "); }
  459. else if (chkEt.Checked)//儿童
  460. { str.Append(" and tempTB_AggregationCustomer.GP_CustomerType = '1' "); }
  461. else if (chkXz.Checked)//写真
  462. { str.Append(" and tempTB_AggregationCustomer.GP_CustomerType = '2' "); }
  463. }
  464. else
  465. {
  466. if (chkFw.Checked)//服务
  467. { str.Append(" and tempTB_AggregationCustomer.GP_CustomerType = '3'"); }
  468. else if (chkHs.Checked)//婚纱
  469. { str.Append(" and tempTB_AggregationCustomer.GP_CustomerType = '0'"); }
  470. else if (chkEt.Checked)//儿童
  471. { str.Append(" and tempTB_AggregationCustomer.GP_CustomerType = '1'"); }
  472. else if (chkXz.Checked)//写真
  473. { str.Append(" and tempTB_AggregationCustomer.GP_CustomerType = '2'"); }
  474. }
  475. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  476. {
  477. newTable = LYFZ.BLL.BLL_ErpOrderView.GetData_ClientManagementClientOld(str.ToString().Trim());
  478. });
  479. #if IGNORE
  480. for (int t = 0; t < newTable.Rows.Count; t++)
  481. {
  482. DataGridViewRow dgvr = new DataGridViewRow();
  483. DataGridViewCell cell = null;
  484. //客户组编号
  485. cell = new DataGridViewTextBoxCell();
  486. cell.Value = newTable.Rows[t]["GP_CustomerGroupID"].ToString().Trim();
  487. dgvr.Cells.Add(cell);
  488. //名字
  489. cell = new DataGridViewTextBoxCell();
  490. cell.Value = newTable.Rows[t]["Cus_Name"].ToString().Trim();
  491. dgvr.Cells.Add(cell);
  492. //性别
  493. cell = new DataGridViewTextBoxCell();
  494. cell.Value = newTable.Rows[t]["Cus_Sex_cs"].ToString().Trim();
  495. dgvr.Cells.Add(cell);
  496. //手机
  497. cell = new DataGridViewTextBoxCell();
  498. cell.Value = newTable.Rows[t]["Cus_Telephone"].ToString().Trim();
  499. dgvr.Cells.Add(cell);
  500. //区域
  501. cell = new DataGridViewTextBoxCell();
  502. cell.Value = newTable.Rows[t]["Cus_Region"].ToString().Trim();
  503. dgvr.Cells.Add(cell);
  504. //客户类型 0 为婚纱订单客户 1 为儿童订单客户 2 写真订单客户 3 为服务套系 4 为其它订单客户
  505. cell = new DataGridViewTextBoxCell();
  506. cell.Value = GetType(newTable.Rows[t]["GP_CustomerType"].ToString().Trim());
  507. dgvr.Cells.Add(cell);
  508. //客户来源;
  509. cell = new DataGridViewTextBoxCell();
  510. cell.Value = newTable.Rows[t]["GP_CustomerSource"].ToString().Trim();
  511. dgvr.Cells.Add(cell);
  512. //客户生日
  513. cell = new DataGridViewTextBoxCell();
  514. cell.Value = newTable.Rows[t]["Cus_BirthdayText"].ToString().Trim();
  515. dgvr.Cells.Add(cell);
  516. //客户婚期
  517. cell = new DataGridViewTextBoxCell();
  518. cell.Value = newTable.Rows[t]["Cus_DayForMarriageText"].ToString().Trim();
  519. dgvr.Cells.Add(cell);
  520. //添加时间
  521. cell = new DataGridViewTextBoxCell();
  522. cell.Value = newTable.Rows[t]["GP_CreateDatetime"].ToString().Trim();
  523. dgvr.Cells.Add(cell);
  524. //套系名称
  525. cell = new DataGridViewTextBoxCell();
  526. cell.Value = newTable.Rows[t]["History_Type"].ToString().Trim();
  527. dgvr.Cells.Add(cell);
  528. //套系价格
  529. cell = new DataGridViewTextBoxCell();
  530. cell.Value = newTable.Rows[t]["History_Money"].ToString().Trim();
  531. dgvr.Cells.Add(cell);
  532. //订单时间
  533. cell = new DataGridViewTextBoxCell();
  534. cell.Value = newTable.Rows[t]["History_OrderTime"].ToString().Trim();
  535. dgvr.Cells.Add(cell);
  536. this.dgv.Rows.Add(dgvr);
  537. }
  538. #endif
  539. this.dgv.RowCount = newTable.Rows.Count;
  540. this.lblTotalCount.Text = "总条数:" + newTable.Rows.Count;
  541. //this.ucPagerEx1.PageCurrent = 1;
  542. //this.ucPagerEx1.PageSize = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetPageSize();//3;分页条数
  543. //this.ucPagerEx1.Bind();
  544. }
  545. /// <summary>
  546. /// 导出Excel
  547. /// </summary>
  548. /// <param name="sender"></param>
  549. /// <param name="e"></param>
  550. void btnExcel_Click(object sender, EventArgs e)
  551. {
  552. if (this.Type == 1)
  553. {
  554. ImportExcel excel = new ImportExcel();
  555. FrmOrdersCustomerRecord frm = new FrmOrdersCustomerRecord();
  556. if (frm.ShowDialog() == DialogResult.OK)
  557. {
  558. excel.Type = this.Type;
  559. excel.Leixing = Convert.ToInt32(frm.DindanType);
  560. if (excel.ShowDialog() == DialogResult.OK)
  561. { this.PublicFunctionRows(); }
  562. }
  563. }
  564. if (this.Type == 2)
  565. {
  566. ImportExcel excel = new ImportExcel();
  567. excel.Type = this.Type;
  568. if (excel.ShowDialog() == DialogResult.OK)
  569. { this.PublicFunctionRows(); }
  570. }
  571. }
  572. /// <summary>
  573. /// 窗体大小发生变化
  574. /// </summary>
  575. /// <param name="sender"></param>
  576. /// <param name="e"></param>
  577. void FrmOldCustomer_Resize(object sender, EventArgs e)
  578. {
  579. switch (this.panelTotalCount.Location.Y)
  580. {
  581. case 3: this.flowLayoutPanel1.Height = 36; break;
  582. case 37: this.flowLayoutPanel1.Height = 70; break;
  583. }
  584. }
  585. /// <summary>
  586. /// 写真
  587. /// </summary>
  588. /// <param name="sender"></param>
  589. /// <param name="e"></param>
  590. void chkXz_Click(object sender, EventArgs e)
  591. {
  592. this.chkHs.Checked = false;
  593. this.chkEt.Checked = false;
  594. this.chkFw.Checked = false;
  595. this.PublicFunctionRows();
  596. }
  597. /// <summary>
  598. /// 儿童
  599. /// </summary>
  600. /// <param name="sender"></param>
  601. /// <param name="e"></param>
  602. void chkEt_Click(object sender, EventArgs e)
  603. {
  604. this.chkHs.Checked = false;
  605. this.chkFw.Checked = false;
  606. this.chkXz.Checked = false;
  607. this.PublicFunctionRows();
  608. }
  609. /// <summary>
  610. /// 婚纱
  611. /// </summary>
  612. /// <param name="sender"></param>
  613. /// <param name="e"></param>
  614. void chkHs_Click(object sender, EventArgs e)
  615. {
  616. this.chkEt.Checked = false;
  617. this.chkFw.Checked = false;
  618. this.chkXz.Checked = false;
  619. this.PublicFunctionRows();
  620. }
  621. /// <summary>
  622. /// 服务
  623. /// </summary>
  624. /// <param name="sender"></param>
  625. /// <param name="e"></param>
  626. void chkFw_Click(object sender, EventArgs e)
  627. {
  628. this.chkHs.Checked = false;
  629. this.chkEt.Checked = false;
  630. this.chkXz.Checked = false;
  631. this.PublicFunctionRows();
  632. }
  633. /// <summary>
  634. /// 订单类型
  635. /// </summary>
  636. /// <param name="Gotype"> 0 为婚纱订单客户 1 为儿童订单客户 2 写真订单客户 3 为服务套系 4 为其它订单客户</param>
  637. /// <returns></returns>
  638. string GetType(string Gotype)
  639. {
  640. string Tpy = "";
  641. switch (Gotype)
  642. {
  643. case "1":
  644. Tpy = "儿童客户";
  645. break;
  646. case "2":
  647. Tpy = "写真客户";
  648. break;
  649. case "3":
  650. Tpy = "服务客户";
  651. break;
  652. case "0":
  653. Tpy = "婚纱客户";
  654. break;
  655. case "4":
  656. Tpy = "其他客户";
  657. break;
  658. }
  659. return Tpy;
  660. }
  661. }
  662. }