FrmPieceCommissionRecords.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. using LYFZ.ComponentLibrary;
  2. using LYFZ.Software.MainBusiness.DoorCityProcess;
  3. using System;
  4. using System.Collections;
  5. using System.Collections.Generic;
  6. using System.ComponentModel;
  7. using System.Data;
  8. using System.Drawing;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Windows.Forms;
  12. namespace LYFZ.Software.MainBusiness.FinancialManagement
  13. {
  14. public partial class FrmPieceCommissionRecords : LYFZ.Software.UI.FinancialManagement.FrmPieceCommissionRecords
  15. {
  16. List<LYFZ.Software.MainBusiness.EnumPermissions.BusinessType> Versions = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetBusinessTypeList();
  17. public FrmPieceCommissionRecords()
  18. {
  19. this.Shown += FrmPieceCommissionRecords_Shown;
  20. this.txtkeyword.KeyDown += txtkeyword_KeyDown;
  21. this.btnQuery.Click += btnQuery_Click;
  22. this.btnConditionQuery.Click += btnConditionQuery_Click;
  23. this.btnEntry.Click += btnEntry_Click;
  24. this.btnDelete.Click += btnDelete_Click;
  25. this.btnClose.Click += btnClose_Click;
  26. this.chkDress.Click += chkDress_Click;
  27. this.chkChild.Click += chkChild_Click;
  28. this.chkPortrait.Click += chkPortrait_Click;
  29. this.chkService.Click += chkService_Click;
  30. this.chkWeddingCelebration.Click += chkWeddingCelebration_Click;
  31. this.Resize += FrmPieceCommissionRecords_Resize;
  32. // 导出按钮;
  33. this.btnExport.Click += BtnExport_Click;
  34. }
  35. /// <summary>
  36. /// 导出按钮 ;
  37. /// </summary>
  38. /// <param name="sender"></param>
  39. /// <param name="e"></param>
  40. private void BtnExport_Click(object sender, EventArgs e)
  41. {
  42. if (this.dgvData.Rows.Count == 0)
  43. {
  44. MessageBox.Show("没有数据可以导出");
  45. return;
  46. }
  47. this.dgvData.ExportDataTable();
  48. }
  49. Hashtable htData = new Hashtable();
  50. /// <summary>
  51. /// 加载
  52. /// </summary>
  53. /// <param name="sender"></param>
  54. /// <param name="e"></param>
  55. void FrmPieceCommissionRecords_Shown(object sender, EventArgs e)
  56. {
  57. this.dtpDateTimeStart.DateValue = SDateTime.Now.ToString("yyyy-MM-dd");
  58. this.dtpDateTimeEnd.DateValue = this.dtpDateTimeStart.DateValue;
  59. this.chkChild.Visible = false;
  60. this.chkPortrait.Visible = false;
  61. this.chkDress.Visible = false;
  62. for (int i = 0; i < this.Versions.Count; i++)
  63. {
  64. LYFZ.Software.MainBusiness.EnumPermissions.BusinessType Version = Versions[i];
  65. if (Version.ToString() == EnumPermissions.BusinessType.写真版.ToString())
  66. { this.chkPortrait.Visible = true; }
  67. if (Version.ToString() == EnumPermissions.BusinessType.婚纱版.ToString())
  68. { this.chkDress.Visible = true; }
  69. if (Version.ToString() == EnumPermissions.BusinessType.儿童版.ToString())
  70. { this.chkChild.Visible = true; }
  71. }
  72. this.PublicFunctionRows();
  73. // 权限设置
  74. this.btnEntry.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.PieceCommissionRecordsCompetence, CustomAttributes.OperatingAuthority.Add);
  75. this.btnDelete.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.PieceCommissionRecordsCompetence, CustomAttributes.OperatingAuthority.Delete);
  76. }
  77. /// <summary>
  78. /// 回车查询
  79. /// </summary>
  80. /// <param name="sender"></param>
  81. /// <param name="e"></param>
  82. void txtkeyword_KeyDown(object sender, KeyEventArgs e)
  83. {
  84. if (e.KeyCode == Keys.Enter)
  85. { this.PublicFunctionRows(); }
  86. }
  87. /// <summary>
  88. /// 查询
  89. /// </summary>
  90. /// <param name="sender"></param>
  91. /// <param name="e"></param>
  92. void btnQuery_Click(object sender, EventArgs e)
  93. {
  94. this.PublicFunctionRows();
  95. }
  96. /// <summary>
  97. /// 条件查询
  98. /// </summary>
  99. /// <param name="sender"></param>
  100. /// <param name="e"></param>
  101. void btnConditionQuery_Click(object sender, EventArgs e)
  102. {
  103. LYFZ.Software.MainBusiness.FinancialManagement.SetSmallForm.ConditionQueryPieceCommissionSetSmallForm frm = new SetSmallForm.ConditionQueryPieceCommissionSetSmallForm();
  104. frm.ShowDialog();
  105. if (frm.IsSaveed)
  106. {
  107. this.htData = frm.htData;
  108. this.PublicFunctionRows();
  109. }
  110. }
  111. /// <summary>
  112. /// 录入
  113. /// </summary>
  114. /// <param name="sender"></param>
  115. /// <param name="e"></param>
  116. void btnEntry_Click(object sender, EventArgs e)
  117. {
  118. LYFZ.Software.MainBusiness.FinancialManagement.PieceCommissionRecords.FrmWeddingEntry frm = new MainBusiness.FinancialManagement.PieceCommissionRecords.FrmWeddingEntry();
  119. if (frm.ShowDialog() == DialogResult.OK)
  120. { this.PublicFunctionRows(); }
  121. }
  122. /// <summary>
  123. /// 删除
  124. /// </summary>
  125. /// <param name="sender"></param>
  126. /// <param name="e"></param>
  127. void btnDelete_Click(object sender, EventArgs e)
  128. {
  129. if (this.dgvData.SelectedRows.Count == 0)
  130. { MessageBoxCustom.Show("请选中你要删除的数据!"); return; }
  131. if (MessageBoxCustom.Show("你确定要删除吗?", "删除提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
  132. {
  133. LYFZ.BLL.BLL_ErpPieceCommissionRecords bll = new BLL.BLL_ErpPieceCommissionRecords();
  134. int id = Convert.ToInt32(this.dgvData.CurrentRow.Cells["ID"].Value);
  135. if (bll.Delete(id) == true)
  136. {
  137. string logsContent = "删除计件提成订单号为:" + this.dgvData.CurrentRow.Cells["订单号"].Value.ToString() + " 完成内容:" + this.dgvData.CurrentRow.Cells["工作内容"].Value.ToString();
  138. LYFZ.BLL.BLL_ErpSystemLogs.WriteSystemLog(LYFZ.EnumPublic.SystemLogsType.删除计件提成, logsContent, LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID, LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name);
  139. MessageBoxCustom.Show("删除成功!");
  140. PublicFunctionRows();
  141. }
  142. else
  143. { MessageBoxCustom.Show("删除失败!"); }
  144. }
  145. }
  146. /// <summary>
  147. /// 关闭
  148. /// </summary>
  149. /// <param name="sender"></param>
  150. /// <param name="e"></param>
  151. void btnClose_Click(object sender, EventArgs e)
  152. { this.Close(); }
  153. /// <summary>
  154. /// 婚纱
  155. /// </summary>
  156. /// <param name="sender"></param>
  157. /// <param name="e"></param>
  158. void chkDress_Click(object sender, EventArgs e)
  159. {
  160. this.chkChild.Checked = false;
  161. this.chkService.Checked = false;
  162. this.chkPortrait.Checked = false;
  163. this.chkWeddingCelebration.Checked = false;
  164. this.PublicFunctionRows();
  165. }
  166. /// <summary>
  167. /// 儿童
  168. /// </summary>
  169. /// <param name="sender"></param>
  170. /// <param name="e"></param>
  171. void chkChild_Click(object sender, EventArgs e)
  172. {
  173. this.chkDress.Checked = false;
  174. this.chkService.Checked = false;
  175. this.chkPortrait.Checked = false;
  176. this.chkWeddingCelebration.Checked = false;
  177. this.PublicFunctionRows();
  178. }
  179. /// <summary>
  180. /// 写真
  181. /// </summary>
  182. /// <param name="sender"></param>
  183. /// <param name="e"></param>
  184. void chkPortrait_Click(object sender, EventArgs e)
  185. {
  186. this.chkDress.Checked = false;
  187. this.chkChild.Checked = false;
  188. this.chkService.Checked = false;
  189. this.chkWeddingCelebration.Checked = false;
  190. this.PublicFunctionRows();
  191. }
  192. /// <summary>
  193. /// 服务
  194. /// </summary>
  195. /// <param name="sender"></param>
  196. /// <param name="e"></param>
  197. void chkService_Click(object sender, EventArgs e)
  198. {
  199. this.chkDress.Checked = false;
  200. this.chkChild.Checked = false;
  201. this.chkPortrait.Checked = false;
  202. this.chkWeddingCelebration.Checked = false;
  203. this.PublicFunctionRows();
  204. }
  205. /// <summary>
  206. /// 婚庆
  207. /// </summary>
  208. /// <param name="sender"></param>
  209. /// <param name="e"></param>
  210. void chkWeddingCelebration_Click(object sender, EventArgs e)
  211. {
  212. this.chkService.Checked = false;
  213. this.chkDress.Checked = false;
  214. this.chkChild.Checked = false;
  215. this.chkPortrait.Checked = false;
  216. this.PublicFunctionRows();
  217. }
  218. /// <summary>
  219. /// 窗体大小发生变化
  220. /// </summary>
  221. /// <param name="sender"></param>
  222. /// <param name="e"></param>
  223. void FrmPieceCommissionRecords_Resize(object sender, EventArgs e)
  224. {
  225. switch (this.panelWeddingCelebration.Location.Y)
  226. {
  227. case 5: this.flowLayoutPanel1.Height = 40; break;
  228. case 39: this.flowLayoutPanel1.Height = 70; break;
  229. }
  230. }
  231. /// <summary>
  232. /// 绑定数据
  233. /// </summary>
  234. public void PublicFunctionRows()
  235. {
  236. DataTable newTable = new DataTable();
  237. string StrWhere = " Where 1 = 1 ";
  238. //if (!string.IsNullOrEmpty(this.dtpDateTimeStart.DateValue) && !string.IsNullOrEmpty(this.dtpDateTimeEnd.DateValue))
  239. //{ StrWhere += PublicCodeClasses.GetDateTime("Pcr_Date", this.dtpDateTimeStart.DateValue, this.dtpDateTimeEnd.DateValue); }
  240. if (this.chkDress.Checked)
  241. {
  242. StrWhere += " and 订单类型 = '0'";
  243. }
  244. else if (this.chkChild.Checked)
  245. {
  246. StrWhere += " and 订单类型 = '1'";
  247. }
  248. else if (this.chkPortrait.Checked)
  249. {
  250. StrWhere += " and 订单类型 = '2'";
  251. }
  252. else if (this.chkService.Checked)
  253. {
  254. StrWhere += " and 订单类型 = '3'";
  255. }
  256. else if (this.chkWeddingCelebration.Checked)
  257. {
  258. StrWhere += " and 订单类型 = '4'";
  259. }
  260. if (!string.IsNullOrEmpty(this.txtkeyword.Text.Trim()))
  261. { StrWhere += " and (客户姓名 like '%" + this.txtkeyword.Text.Trim() + "%' or Cus_Name_py like '%" + this.txtkeyword.Text.Trim() + "%' or 客户电话 like '%" + this.txtkeyword.Text.Trim() + "%')"; }
  262. if (this.htData.Count > 0)
  263. {
  264. if (htData.ContainsKey("CommissionName"))
  265. { StrWhere += " and 提成人 = '" + htData["CommissionName"].ToString().Trim() + "'"; }
  266. if (htData.ContainsKey("SeriesName"))
  267. { StrWhere += " and 套系名称 = '" + htData["SeriesName"].ToString().Trim() + "'"; }
  268. if (htData.ContainsKey("WorkContent"))
  269. { StrWhere += " and Pcr_CompletionContents = '" + htData["WorkContent"].ToString().Trim() + "'"; }
  270. }
  271. this.htData.Clear();
  272. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  273. {
  274. newTable = LYFZ.BLL.BLL_ErpOrderView.GetData_FinancialManagementPieceStatistics(StrWhere
  275. , this.dtpDateTimeStart.Value.ToString("yyyy-MM-dd")
  276. , this.dtpDateTimeEnd.Value.ToString("yyyy-MM-dd"));
  277. });
  278. #region
  279. this.dgvData.DataColumns(newTable.Columns, strHideField: "ID");
  280. this.dgvData.Columns["工作内容"].Width = 250;
  281. this.dgvData.Columns["提成日期"].Width = 120;
  282. this.dgvData.Columns["录入日期"].Width = 120;
  283. this.dgvData.Columns["套系名称"].Width = 150;
  284. this.dgvData.FillLastColumn();
  285. for (int t = 0; t < newTable.Rows.Count; t++)
  286. {
  287. DataGridViewRow dgvr = new DataGridViewRow();
  288. DataGridViewCell cell = null;
  289. cell = new DataGridViewTextBoxCell();
  290. cell.Value = newTable.Rows[t]["ID"].ToString().Trim(); ;
  291. dgvr.Cells.Add(cell);
  292. cell = new DataGridViewTextBoxCell();
  293. cell.Value = newTable.Rows[t]["工作内容"].ToString();
  294. dgvr.Cells.Add(cell);
  295. cell = new DataGridViewTextBoxCell();
  296. cell.Value = newTable.Rows[t]["工作数量"];
  297. dgvr.Cells.Add(cell);
  298. cell = new DataGridViewTextBoxCell();
  299. cell.Value = newTable.Rows[t]["导片数量"];
  300. dgvr.Cells.Add(cell);
  301. cell = new DataGridViewTextBoxCell();
  302. cell.Value = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetUserName(newTable.Rows[t]["提成人"]);
  303. dgvr.Cells.Add(cell);
  304. cell = new DataGridViewTextBoxCell();
  305. cell.Value = LYFZ.BLL.OtherCommonModel.DateTimeToString(newTable.Rows[t]["提成日期"]);
  306. dgvr.Cells.Add(cell);
  307. cell = new DataGridViewTextBoxCell();
  308. cell.Value = newTable.Rows[t]["订单号"].ToString().Trim();
  309. dgvr.Cells.Add(cell);
  310. cell = new DataGridViewTextBoxCell();
  311. if (newTable.Rows[t]["订单类型"].ToString().Trim().Length > 0&& newTable.Rows[t]["订单类型"].ToString()!= "散客消费")
  312. {
  313. cell.Value = Enum.ToObject(typeof(LYFZ.EnumPublic.OrderType), Convert.ToInt32(newTable.Rows[t]["订单类型"])).ToString();
  314. }
  315. else
  316. {
  317. cell.Value = "散客消费";
  318. }
  319. dgvr.Cells.Add(cell);
  320. cell = new DataGridViewTextBoxCell();
  321. cell.Value = newTable.Rows[t]["客户姓名"];
  322. dgvr.Cells.Add(cell);
  323. cell = new DataGridViewTextBoxCell();
  324. cell.Value = newTable.Rows[t]["客户电话"];
  325. dgvr.Cells.Add(cell);
  326. cell = new DataGridViewTextBoxCell();
  327. cell.Value = newTable.Rows[t]["套系名称"];
  328. dgvr.Cells.Add(cell);
  329. cell = new DataGridViewTextBoxCell();
  330. cell.Value = newTable.Rows[t]["套系价格"];
  331. dgvr.Cells.Add(cell);
  332. cell = new DataGridViewTextBoxCell();
  333. cell.Value = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetUserName(newTable.Rows[t]["录单人"]);
  334. dgvr.Cells.Add(cell);
  335. cell = new DataGridViewTextBoxCell();
  336. cell.Value = LYFZ.BLL.OtherCommonModel.DateTimeToString(newTable.Rows[t]["录入日期"]);
  337. dgvr.Cells.Add(cell);
  338. this.dgvData.Rows.Add(dgvr);
  339. }
  340. #endregion
  341. this.dgvData.ClearSelection();
  342. }
  343. }
  344. }