PhotographerConferenceStatisticSmallForm.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  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. namespace LYFZ.Software.MainBusiness.MembershipManage
  10. {
  11. public partial class PhotographerConferenceStatisticSmallForm : LYFZ.Software.UI.MembershipManage.PhotographerConferenceStatisticSmallForm
  12. {
  13. public PhotographerConferenceStatisticSmallForm()
  14. {
  15. this.Resize += PhotographerConferenceStatisticSmallForm_Resize;
  16. }
  17. LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
  18. LYFZ.BLL.BLL_ErpMemberCard mcbll = new BLL.BLL_ErpMemberCard();
  19. string StrPointsType;
  20. /// <summary>
  21. /// 窗体加载事件
  22. /// </summary>
  23. /// <param name="sender"></param>
  24. /// <param name="e"></param>
  25. protected override void PhotographerConferenceStatisticSmallForm_Shown(object sender, EventArgs e)
  26. {
  27. if (!LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.MemberManage, LYFZ.CustomAttributes.OperatingAuthority.SMSSend))
  28. { this.btnSendSMS.Enabled = false; }
  29. }
  30. /// <summary>
  31. /// 窗体加载事件
  32. /// </summary>
  33. /// <param name="sender"></param>
  34. /// <param name="e"></param>
  35. protected override void PhotographerConferenceStatisticSmallForm_Load(object sender, EventArgs e)
  36. {
  37. string sql = "select Sconfig_Value from tb_ErpSystemConfigure where Sconfig_Code = 'MemberPhotographerNeededType'";
  38. DataSet dtSet = orbll.GetView_Custom(sql);
  39. DataTable tbl1 = dtSet.Tables["ds"];
  40. if (tbl1.Rows.Count > 0)
  41. { StrPointsType = tbl1.Rows[0]["Sconfig_Value"].ToString().Trim(); }
  42. else { MessageBoxCustom.Show("未设置新摄会所需要积分方案!"); this.Close(); }
  43. PublicQuery();
  44. }
  45. /// <summary>
  46. /// 查询
  47. /// </summary>
  48. /// <param name="sender"></param>
  49. /// <param name="e"></param>
  50. protected override void btnQuery_Click(object sender, EventArgs e)
  51. {
  52. //int A = LYFZ.Software.MainBusiness.MembershipManage.MemberPublicClass.GetPoints_AgoPeriod(LYFZ.EnumPublic.MemberPointsType.AgoPeriod_RMB, 5000, "201505081446052982");
  53. //int B = LYFZ.Software.MainBusiness.MembershipManage.MemberPublicClass.GetPoints_AgoPeriod(LYFZ.EnumPublic.MemberPointsType.LatePeriod_RMB, 5000, "201505081446052982");
  54. //int C = LYFZ.Software.MainBusiness.MembershipManage.MemberPublicClass.GetPoints_AgoPeriod(LYFZ.EnumPublic.MemberPointsType.txtReferral_RMB, 5000, "201505081446052982");
  55. //MessageBox.Show(A + " " + B + " " + C);
  56. this.tabPanel.SelectedIndex = 0;
  57. PublicQuery();
  58. PublicQueryCount++;
  59. }
  60. LYFZ.Software.MainBusiness.MembershipManage.SetSmallForm.PhotographerConditionModel model = null;
  61. /// <summary>
  62. /// 条件查询
  63. /// </summary>
  64. /// <param name="sender"></param>
  65. /// <param name="e"></param>
  66. protected override void btnConditionQuery_Click(object sender, EventArgs e)
  67. {
  68. LYFZ.Software.MainBusiness.MembershipManage.SetSmallForm.PhotographerConditionQuerySmallForm frm = new SetSmallForm.PhotographerConditionQuerySmallForm();
  69. frm.ShowDialog();
  70. if (frm.IsSaveed)
  71. {
  72. model = frm.model;
  73. this.tabPanel.SelectedIndex = 0;
  74. PublicQuery();
  75. PublicQueryCount++;
  76. }
  77. }
  78. /// <summary>
  79. /// 发送短信
  80. /// </summary>
  81. /// <param name="sender"></param>
  82. /// <param name="e"></param>
  83. protected override void btnSendSMS_Click(object sender, EventArgs e)
  84. {
  85. string StrMc_Telephone = "";
  86. string strtmp = "";
  87. switch (this.tabPanel.TabPages[this.tabPanel.SelectedIndex].Name.Trim())
  88. {
  89. case "tb_1":
  90. if (this.dgvData1.Rows.Count > 0)
  91. {
  92. if (this.dgvData1.SelectedRows.Count > 0)
  93. {
  94. for (int i = 0; i < this.dgvData1.SelectedRows.Count; i++)
  95. {
  96. if (LYFZ.Command.Command_Validate.IsPhone(this.dgvData1.SelectedRows[i].Cells["客户电话"].Value.ToString().Trim()))
  97. { StrMc_Telephone += this.dgvData1.SelectedRows[i].Cells["客户电话"].Value.ToString().Trim() + ","; }
  98. else
  99. { strtmp = this.dgvData1.SelectedRows[i].Cells["客户电话"].Value.ToString().Trim() + ","; }
  100. }
  101. }
  102. }
  103. break;
  104. case "tb_2":
  105. if (this.dgvData2.Rows.Count > 0)
  106. {
  107. if (this.dgvData2.SelectedRows.Count > 0)
  108. {
  109. for (int i = 0; i < this.dgvData1.SelectedRows.Count; i++)
  110. {
  111. if (LYFZ.Command.Command_Validate.IsPhone(this.dgvData2.SelectedRows[i].Cells["客户电话"].Value.ToString().Trim()))
  112. { StrMc_Telephone += this.dgvData2.SelectedRows[i].Cells["客户电话"].Value.ToString().Trim() + ","; }
  113. else
  114. { strtmp = this.dgvData2.SelectedRows[i].Cells["客户电话"].Value.ToString().Trim() + ","; }
  115. }
  116. }
  117. }
  118. break;
  119. case "tb_3":
  120. if (this.dgvData3.Rows.Count > 0)
  121. {
  122. if (this.dgvData3.SelectedRows.Count > 0)
  123. {
  124. for (int i = 0; i < this.dgvData1.SelectedRows.Count; i++)
  125. {
  126. if (LYFZ.Command.Command_Validate.IsPhone(this.dgvData3.SelectedRows[i].Cells["客户电话"].Value.ToString().Trim()))
  127. { StrMc_Telephone += this.dgvData3.SelectedRows[i].Cells["客户电话"].Value.ToString().Trim() + ","; }
  128. else
  129. { strtmp = this.dgvData3.SelectedRows[i].Cells["客户电话"].Value.ToString().Trim() + ","; }
  130. }
  131. }
  132. }
  133. break;
  134. case "tb_4":
  135. if (this.dgvData4.Rows.Count > 0)
  136. {
  137. if (this.dgvData4.SelectedRows.Count > 0)
  138. {
  139. for (int i = 0; i < this.dgvData1.SelectedRows.Count; i++)
  140. {
  141. if (LYFZ.Command.Command_Validate.IsPhone(this.dgvData4.SelectedRows[i].Cells["客户电话"].Value.ToString().Trim()))
  142. { StrMc_Telephone += this.dgvData4.SelectedRows[i].Cells["客户电话"].Value.ToString().Trim() + ","; }
  143. else
  144. { strtmp = this.dgvData4.SelectedRows[i].Cells["客户电话"].Value.ToString().Trim() + ","; }
  145. }
  146. }
  147. }
  148. break;
  149. }
  150. if (strtmp != "")
  151. { MessageBoxCustom.Show("号码" + strtmp.TrimEnd(',') + "不是正确的电话号码"); }
  152. if (StrMc_Telephone != "")
  153. {
  154. LYFZ.Software.MainBusiness.SMSManagement.SmsSend.FrmSendSms SendSMS = new SMSManagement.SmsSend.FrmSendSms();
  155. SendSMS.Phone = StrMc_Telephone.TrimEnd(',');
  156. SendSMS.Show(); return;
  157. }
  158. else
  159. { MessageBoxCustom.Show("请选中您要发送短信的新摄会会员"); return; }
  160. }
  161. /// <summary>
  162. /// 关闭
  163. /// </summary>
  164. /// <param name="sender"></param>
  165. /// <param name="e"></param>
  166. protected override void btnColse_Click(object sender, EventArgs e)
  167. {
  168. this.Close();
  169. }
  170. private int tb1Count = 0;
  171. private int tb2Count = 0;
  172. private int tb3Count = 0;
  173. private int tb4Count = 0;
  174. /// <summary>
  175. /// 选项卡选择
  176. /// </summary>
  177. /// <param name="sender"></param>
  178. /// <param name="e"></param>
  179. protected override void tabPanel_SelectedIndexChanged(object sender, EventArgs e)
  180. {
  181. switch (this.tabPanel.TabPages[this.tabPanel.SelectedIndex].Name.Trim())
  182. {
  183. case "tb_1":
  184. if (this.tb1Count < this.PublicQueryCount)
  185. {
  186. this.GetStatusData(this.dgvData1, "全部");
  187. this.tb1Count = this.PublicQueryCount;
  188. this.dgvData1.FillLastColumn(true);
  189. }
  190. break;
  191. case "tb_2":
  192. if (this.tb2Count < this.PublicQueryCount)
  193. {
  194. this.GetStatusData(this.dgvData2, "已返");
  195. this.tb2Count = this.PublicQueryCount;
  196. this.dgvData2.FillLastColumn(true);
  197. }
  198. break;
  199. case "tb_3":
  200. if (this.tb3Count < this.PublicQueryCount)
  201. {
  202. this.GetStatusData(this.dgvData3, "未返");
  203. this.tb3Count = this.PublicQueryCount;
  204. this.dgvData3.FillLastColumn(true);
  205. }
  206. break;
  207. case "tb_4":
  208. if (this.tb4Count < this.PublicQueryCount)
  209. {
  210. this.GetStatusData(this.dgvData4, "未达条件");
  211. this.tb4Count = this.PublicQueryCount;
  212. this.dgvData4.FillLastColumn(true);
  213. }
  214. break;
  215. }
  216. }
  217. /// <summary>
  218. /// 行添加时发生改变
  219. /// </summary>
  220. /// <param name="sender"></param>
  221. /// <param name="e"></param>
  222. protected override void dgvData1_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
  223. {
  224. if (this.dgvData1.Rows.Count > 0)
  225. {
  226. decimal OpenCradAoumnt = 0;
  227. decimal NotBackAoumnt = 0;
  228. decimal OKBackAoumnt = 0;
  229. decimal NotReachedAoumnt = 0;
  230. for (int i = 0; i < this.dgvData1.Rows.Count; i++)
  231. {
  232. if (this.dgvData1.Rows[i].Cells["所需开卡金"].Value.ToString().Trim() != "")
  233. { OpenCradAoumnt += Convert.ToDecimal(this.dgvData1.Rows[i].Cells["所需开卡金"].Value); }
  234. if (this.dgvData1.Rows[i].Cells["返还状态"].Value.ToString().Trim() == "未返")
  235. { NotBackAoumnt += Convert.ToDecimal(this.dgvData1.Rows[i].Cells["返还开卡金"].Value); }
  236. else if (this.dgvData1.Rows[i].Cells["返还状态"].Value.ToString().Trim() == "已返")
  237. { OKBackAoumnt += Convert.ToDecimal(this.dgvData1.Rows[i].Cells["返还开卡金"].Value); }
  238. else if (this.dgvData1.Rows[i].Cells["返还状态"].Value.ToString().Trim() == "未达条件")
  239. { NotReachedAoumnt += Convert.ToDecimal(this.dgvData1.Rows[i].Cells["返还开卡金"].Value); }
  240. }
  241. this.labelEx1.Text = "总开卡金:" + OpenCradAoumnt + " ;已返:" + OKBackAoumnt + ";未返:" + NotBackAoumnt + ";未达条件:" + NotReachedAoumnt;
  242. }
  243. }
  244. LYFZ.Software.MainBusiness.MembershipManage.SetSmallForm.MyPhotographerConferenceSmallForm frm = null;
  245. /// <summary>
  246. /// 全部双击事件
  247. /// </summary>
  248. /// <param name="sender"></param>
  249. /// <param name="e"></param>
  250. protected override void dgvData1_MouseDoubleClick(object sender, MouseEventArgs e)
  251. {
  252. if (e.Location.Y > this.dgvData1.ColumnHeadersHeight)
  253. {
  254. if (this.dgvData1.Rows.Count > 0)
  255. {
  256. if (this.dgvData1.CurrentRow.Index >= 0 && this.dgvData1.CurrentCell.ColumnIndex >= 0)
  257. {
  258. if (frm != null)
  259. { frm.Close(); }
  260. frm = new SetSmallForm.MyPhotographerConferenceSmallForm();
  261. frm.StrNumber = this.dgvData1.CurrentRow.Cells["会员编号"].Value.ToString().Trim();
  262. frm.Show();
  263. }
  264. }
  265. }
  266. }
  267. /// <summary>
  268. /// 已达未返双击事件
  269. /// </summary>
  270. /// <param name="sender"></param>
  271. /// <param name="e"></param>
  272. protected override void dgvData3_MouseDoubleClick(object sender, MouseEventArgs e)
  273. {
  274. if (e.Location.Y > this.dgvData3.ColumnHeadersHeight)
  275. {
  276. if (this.dgvData3.Rows.Count > 0)
  277. {
  278. if (this.dgvData3.CurrentRow.Index >= 0 && this.dgvData3.CurrentCell.ColumnIndex >= 0)
  279. {
  280. if (frm != null)
  281. { frm.Close(); }
  282. frm = new SetSmallForm.MyPhotographerConferenceSmallForm();
  283. frm.StrNumber = this.dgvData3.CurrentRow.Cells["会员编号"].Value.ToString().Trim();
  284. frm.Show();
  285. }
  286. }
  287. }
  288. }
  289. /// <summary>
  290. /// 查询框回车键
  291. /// </summary>
  292. /// <param name="sender"></param>
  293. /// <param name="e"></param>
  294. protected override void txtQuery_KeyDown(object sender, KeyEventArgs e)
  295. {
  296. if (e.KeyCode == Keys.Enter)
  297. { this.btnQuery_Click(this, null); }
  298. }
  299. /// <summary>
  300. /// 窗体大小发生变化
  301. /// </summary>
  302. /// <param name="sender"></param>
  303. /// <param name="e"></param>
  304. void PhotographerConferenceStatisticSmallForm_Resize(object sender, EventArgs e)
  305. {
  306. }
  307. /// <summary>
  308. /// 总查询次数
  309. /// </summary>
  310. private int PublicQueryCount = 0;
  311. DataTable dt = new DataTable();
  312. /// <summary>
  313. /// 公共查询
  314. /// </summary>
  315. private void PublicQuery()
  316. {
  317. string StrWhere = " 会员卡号 is not null and 1 = 1 ";
  318. if (this.model != null)
  319. {
  320. if (this.model.MemberType != "")
  321. { StrWhere += " and 类型 = '" + this.model.MemberType + "'"; }
  322. if (this.model.IsPoints)
  323. {
  324. if (StrPointsType == "AvailablePoints")
  325. { StrWhere += " and (Mcps_AvailablePoints between " + this.model.StrPointStart + " and " + this.model.StrPointEnd + ")"; }
  326. else if (StrPointsType == "HistoricalPoints")
  327. { StrWhere += " and (Mcps_TotalPoints between " + this.model.MemberType + " and " + this.model.StrPointEnd + ")"; }
  328. }
  329. if (this.model.IsDate)
  330. { StrWhere += " and (Mcpm_CreateDatetime between '" + this.model.StrDateStart + "' and '" + this.model.StrDateEnd + "')"; }
  331. if (this.model.IsBack)
  332. { StrWhere += " and (Mcpm_BackDatetime between '" + this.model.StrBackDateStart + "' and '" + this.model.StrBackDateEnd + "')"; }
  333. if (this.model.StrStatusTag != null)
  334. { StrWhere += " and Mcpm_BackStatus = '" + this.model.StrStatusTag + "'"; }
  335. }
  336. string StrText = this.txtQuery.Text.Trim();
  337. if (StrText != "")
  338. {
  339. if (LYFZ.Command.Command_Validate.IsNumber(StrText))
  340. { StrWhere += " and (电话 like '%" + StrText + "%' or 会员卡号 like '%" + StrText + "%')"; }
  341. else if (LYFZ.Command.Command_Validate.IsEnglish(StrText))
  342. { StrWhere += " and (姓名 like '%" + StrText + "%' or 会员卡号 like '%" + StrText + "%' or 姓名拼音 like '" + StrText + "%')"; }
  343. else if (LYFZ.Command.Command_Validate.IsChinese(StrText))
  344. { StrWhere += " and 姓名 like '%" + StrText + "%' "; }
  345. else
  346. { StrWhere += " and (姓名 like '%" + StrText + "%' or 会员卡号 like '%" + StrText + "%' or 电话 like '%" + StrText + "%')"; }
  347. }
  348. string sql = "select * from (select Mcpm_Number,Mcpm_UpgradeAoumnt,Mcpm_BackAoumnt,Mcpm_UpgradePoints,Mcpm_BackStatus,Mcpm_BackDatetime,dbo.fn_CheckUserIDGetUserName(Mcpm_CreateName) AS Mcpm_CreateName,Mcpm_CreateDatetime," +
  349. "会员卡号,姓名,dbo.fn_ChineseToSpell(姓名) AS 姓名拼音,类型,积分,电话,Mcps_TotalPoints,Mcps_AvailablePoints from tb_ErpMemberCardPhotographerMain Left join (select Mc_Number,会员卡号,姓名,类型,积分,电话,Mcps_TotalPoints," +
  350. "Mcps_AvailablePoints from BView_MemberMain_GoldMember left join tb_ErpMemberCardPoints on Mc_Number = Mcps_Number) as tb on Mcpm_Number = Mc_Number) AS tb2 where " + StrWhere + ";";
  351. DataSet dtSet = orbll.GetView_Custom(sql);
  352. DataTable tbl1 = dtSet.Tables["ds"];
  353. if (this.dt.Columns.Count <= 0)
  354. {
  355. string[] StrColumns = ("会员编号,会员卡号,客户姓名,客户电话,会员类型,所需开卡金,返还开卡金,返还所需积分,返还状态,返还时间,录入人").Split(',');
  356. for (int i = 0; i < StrColumns.Length; i++)
  357. {
  358. DataColumn dc = new DataColumn(StrColumns[i].Trim());
  359. dt.Columns.Add(dc);
  360. }
  361. }
  362. this.dt.Rows.Clear();
  363. for (int i = 0; i < tbl1.Rows.Count; i++)
  364. {
  365. DataRow dr = dt.NewRow();
  366. int CurrentPoints = 0;
  367. if (StrPointsType == "AvailablePoints")
  368. {
  369. if (!string.IsNullOrEmpty(tbl1.Rows[i]["Mcps_AvailablePoints"].ToString()))
  370. { CurrentPoints = Convert.ToInt32(tbl1.Rows[i]["Mcps_AvailablePoints"]); }
  371. }
  372. else if (StrPointsType == "HistoricalPoints")
  373. {
  374. if (!string.IsNullOrEmpty(tbl1.Rows[i]["Mcps_TotalPoints"].ToString()))
  375. { CurrentPoints = Convert.ToInt32(tbl1.Rows[i]["Mcps_TotalPoints"]); }
  376. }
  377. dr["会员编号"] = Convert.ToString(tbl1.Rows[i]["Mcpm_Number"].ToString());
  378. dr["会员卡号"] = Convert.ToString(tbl1.Rows[i]["会员卡号"].ToString());
  379. dr["客户姓名"] = Convert.ToString(tbl1.Rows[i]["姓名"].ToString());
  380. dr["客户电话"] = Convert.ToString(tbl1.Rows[i]["电话"].ToString());
  381. dr["会员类型"] = Convert.ToString(tbl1.Rows[i]["类型"].ToString());
  382. dr["所需开卡金"] = Convert.ToString(tbl1.Rows[i]["Mcpm_UpgradeAoumnt"].ToString());
  383. dr["返还开卡金"] = Convert.ToString(tbl1.Rows[i]["Mcpm_BackAoumnt"].ToString());
  384. dr["返还所需积分"] = Convert.ToString(CurrentPoints + "/" + tbl1.Rows[i]["Mcpm_UpgradePoints"].ToString());
  385. string strBackStatus = "未达条件";
  386. if (CurrentPoints >= Convert.ToInt32(tbl1.Rows[i]["Mcpm_UpgradePoints"]))
  387. {
  388. if (tbl1.Rows[i]["Mcpm_BackStatus"].ToString() == "0")
  389. { strBackStatus = "未返"; }
  390. else
  391. { strBackStatus = "已返"; }
  392. }
  393. dr["返还状态"] = Convert.ToString(strBackStatus);
  394. dr["返还时间"] = Convert.ToString(LYFZ.Command.Command_Validate.DateTimeToString(tbl1.Rows[i]["Mcpm_BackDatetime"].ToString()));
  395. dr["录入人"] = Convert.ToString(tbl1.Rows[i]["Mcpm_CreateName"].ToString());
  396. dt.Rows.Add(dr);
  397. }
  398. this.dgvData1.DataSource(dt, strHideField: "会员编号");
  399. PublicQueryCount++;
  400. this.model = null;
  401. }
  402. /// <summary>
  403. /// 获取状态数据
  404. /// </summary>
  405. /// <param name="dgvData"></param>
  406. /// <param name="StrStatus"></param>
  407. private void GetStatusData(LYFZ.ComponentLibrary.DataGridViewEc dgvData, string StrStatus)
  408. {
  409. DataTable tbl = new DataTable();
  410. for (int i = 0; i < dt.Columns.Count; i++)
  411. {
  412. DataColumn dc = new DataColumn(dt.Columns[i].ToString().Trim());
  413. tbl.Columns.Add(dc);
  414. }
  415. if (dt.Rows.Count > 0)
  416. {
  417. for (int i = 0; i < dt.Rows.Count; i++)
  418. {
  419. if (dt.Rows[i]["返还状态"].ToString().Trim() == StrStatus || StrStatus == "全部")
  420. {
  421. DataRow dr = tbl.NewRow();
  422. for (int j = 0; j < dt.Columns.Count; j++)
  423. {
  424. dr[j] = Convert.ToString(dt.Rows[i][j].ToString().Trim());
  425. }
  426. tbl.Rows.Add(dr);
  427. }
  428. }
  429. }
  430. dgvData.DataSource(tbl, strHideField: "");
  431. }
  432. }
  433. }