FrmCashExpenditures.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. using LYFZ.ComponentLibrary;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using System.ComponentModel;
  6. using System.Data;
  7. using System.Drawing;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Windows.Forms;
  11. namespace LYFZ.Software.MainBusiness.FinancialManagement
  12. {
  13. public partial class FrmCashExpenditures : LYFZ.Software.UI.FinancialManagement.FrmCashExpenditures
  14. {
  15. LYFZ.BLL.BLL_ErpOtherIncomeAndExpenses oiebll = new BLL.BLL_ErpOtherIncomeAndExpenses();
  16. public FrmCashExpenditures()
  17. {
  18. this.Shown += FrmCashExpenditures_Shown;
  19. this.btnQuery.Click += btnQuery_Click;
  20. this.btnConditionQuery.Click += btnConditionQuery_Click;
  21. this.btnEntry.Click += btnEntry_Click;
  22. this.btnUpdate.Click += btnUpdate_Click;
  23. this.dgvData.CellDoubleClick += dgvData_CellDoubleClick;
  24. this.btnDelete.Click += btnDelete_Click;
  25. this.btnClose.Click += btnClose_Click;
  26. this.btnReport.Click += btnReport_Click;
  27. this.btnPrint.Click += btnPrint_Click;
  28. this.btnExport.Click += btnExport_Click;
  29. this.Resize += FrmCashExpenditures_Resize;
  30. }
  31. DataTable _dataTable = new DataTable();
  32. Hashtable htData = new Hashtable();
  33. /// <summary>
  34. /// 窗体加载事件
  35. /// </summary>
  36. /// <param name="sender"></param>
  37. /// <param name="e"></param>
  38. void FrmCashExpenditures_Shown(object sender, EventArgs e)
  39. {
  40. this.dgvData.MultiSelect = true;
  41. this.dtpDateTimeStart.DateValue = SDateTime.Now.ToString("yyyy-MM-dd HH:mm");
  42. this.dtpDateTimeEnd.DateValue = this.dtpDateTimeStart.DateValue;
  43. this.btnEntry.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.CashExpendituresCompetence, CustomAttributes.OperatingAuthority.Add);
  44. this.btnUpdate.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.CashExpendituresCompetence, CustomAttributes.OperatingAuthority.Update);
  45. this.btnDelete.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.CashExpendituresCompetence, CustomAttributes.OperatingAuthority.Delete);
  46. this.btnPrint.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.CashExpendituresCompetence, CustomAttributes.OperatingAuthority.Print);
  47. this.btnReport.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.CashExpendituresCompetence, CustomAttributes.OperatingAuthority.ReportForm);
  48. this.PublicFunctionRows();
  49. }
  50. /// <summary>
  51. /// 查询
  52. /// </summary>
  53. /// <param name="sender"></param>
  54. /// <param name="e"></param>
  55. void btnQuery_Click(object sender, EventArgs e)
  56. {
  57. this.PublicFunctionRows();
  58. }
  59. /// <summary>
  60. /// 条件查询
  61. /// </summary>
  62. /// <param name="sender"></param>
  63. /// <param name="e"></param>
  64. void btnConditionQuery_Click(object sender, EventArgs e)
  65. {
  66. LYFZ.Software.MainBusiness.FinancialManagement.SetSmallForm.ConditionQueryOutlaySetSmallForm frm = new SetSmallForm.ConditionQueryOutlaySetSmallForm();
  67. frm.StrSystemCode = "BEBACIAFBEDIGJJFE";
  68. frm.ShowDialog();
  69. if (frm.IsSaveed)
  70. {
  71. this.htData = frm.htData;
  72. this.PublicFunctionRows();
  73. }
  74. }
  75. /// <summary>
  76. /// 录入
  77. /// </summary>
  78. /// <param name="sender"></param>
  79. /// <param name="e"></param>
  80. void btnEntry_Click(object sender, EventArgs e)
  81. {
  82. LYFZ.Software.MainBusiness.FinancialManagement.SetSmallForm.StorefrontOutlaySetSmallForm frm = new SetSmallForm.StorefrontOutlaySetSmallForm();
  83. frm.EnumOutlayInputType = SetSmallForm.StorefrontOutlaySetSmallForm.OutlayInputType.添加;
  84. frm.EnumOutlayLoadType = SetSmallForm.StorefrontOutlaySetSmallForm.OutlayLoadType.店面支出;
  85. frm.ShowDialog();
  86. if (frm.IsSaveed)
  87. { this.PublicFunctionRows(); }
  88. }
  89. /// <summary>
  90. /// 修改
  91. /// </summary>
  92. /// <param name="sender"></param>
  93. /// <param name="e"></param>
  94. void btnUpdate_Click(object sender, EventArgs e)
  95. {
  96. if (this.dgvData.Rows.Count > 0 && this.dgvData.CurrentRow != null)
  97. {
  98. LYFZ.Software.MainBusiness.FinancialManagement.SetSmallForm.StorefrontOutlaySetSmallForm frm = new SetSmallForm.StorefrontOutlaySetSmallForm();
  99. frm.EnumOutlayInputType = SetSmallForm.StorefrontOutlaySetSmallForm.OutlayInputType.修改;
  100. frm.EnumOutlayLoadType = SetSmallForm.StorefrontOutlaySetSmallForm.OutlayLoadType.店面支出;
  101. frm.OutlayID = Convert.ToInt32(this.dgvData.CurrentRow.Cells["ID"].Value);
  102. frm.ShowDialog();
  103. if (frm.IsSaveed)
  104. { this.PublicFunctionRows(); }
  105. }
  106. }
  107. /// <summary>
  108. /// 列表双击事件
  109. /// </summary>
  110. /// <param name="sender"></param>
  111. /// <param name="e"></param>
  112. void dgvData_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  113. {
  114. if (this.dgvData.Rows.Count > 0)
  115. {
  116. if (e.RowIndex >= 0 && e.ColumnIndex >= 0)
  117. {
  118. if (this.dgvData.SelectedRows.Count == 0)
  119. { MessageBoxCustom.Show("请选择你要修改的数据!"); return; }
  120. if (this.btnUpdate.Enabled)
  121. { this.btnUpdate_Click(this, null); }
  122. }
  123. }
  124. }
  125. /// <summary>
  126. /// 删除
  127. /// </summary>
  128. /// <param name="sender"></param>
  129. /// <param name="e"></param>
  130. void btnDelete_Click(object sender, EventArgs e)
  131. {
  132. if (this.dgvData.SelectedRows.Count == 0)
  133. { MessageBoxCustom.Show("请选中你要删除的数据!"); return; }
  134. int ID = Convert.ToInt32(this.dgvData.CurrentRow.Cells["ID"].Value);
  135. LYFZ.Model.Model_ErpOtherIncomeAndExpenses model = oiebll.GetModel(ID);
  136. if (model.ID > 0)
  137. {
  138. if (model.Oiae_FinancialAuditState == "已审核")
  139. { MessageBoxCustom.Show("财务已审核,不能删除!"); return; }
  140. if (MessageBoxCustom.Show("你确定要删除吗?", "删除提示", MessageBoxButtons.YesNo) == DialogResult.No)
  141. { return; }
  142. if (oiebll.Delete(ID))
  143. {
  144. // 写入操作日志
  145. string logsContent = "删除现金支出项目名称:" + this.dgvData.CurrentRow.Cells["费用项目"].Value.ToString() + " 金额为:" + this.dgvData.CurrentRow.Cells["费用金额"].Value.ToString();
  146. LYFZ.BLL.BLL_ErpSystemLogs.WriteSystemLog(LYFZ.EnumPublic.SystemLogsType.删除支出, logsContent, LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID, LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name);
  147. MessageBoxCustom.Show("删除成功!");
  148. this.PublicFunctionRows();
  149. }
  150. }
  151. }
  152. /// <summary>
  153. /// 关闭
  154. /// </summary>
  155. /// <param name="sender"></param>
  156. /// <param name="e"></param>
  157. void btnClose_Click(object sender, EventArgs e)
  158. { this.Close(); }
  159. /// <summary>
  160. /// 报表
  161. /// </summary>
  162. /// <param name="sender"></param>
  163. /// <param name="e"></param>
  164. void btnReport_Click(object sender, EventArgs e)
  165. {
  166. LYFZ.Software.MainBusiness.FinancialManagement.SetSmallForm.OutlayReportSetSmallForm frm = new SetSmallForm.OutlayReportSetSmallForm();
  167. frm.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
  168. frm.Location = new Point(LYFZ.EnumPublic.FormLocation_X, LYFZ.EnumPublic.FormLocation_Y);
  169. frm.Size = new Size(LYFZ.EnumPublic.FormSize_Width, LYFZ.EnumPublic.FormSize_Height);
  170. frm.EnumOutlayReportLoadType = SetSmallForm.OutlayReportSetSmallForm.OutlayReportLoadType.店面支出;
  171. frm.ShowDialog();
  172. }
  173. /// <summary>
  174. /// 打印收据
  175. /// </summary>
  176. /// <param name="sender"></param>
  177. /// <param name="e"></param>
  178. void btnPrint_Click(object sender, EventArgs e)
  179. {
  180. if (dgvData.SelectedRows.Count == 0)
  181. { MessageBoxCustom.Show("请选择你要打印的数据!"); return; }
  182. Hashtable ht = new Hashtable();
  183. Hashtable ht2 = new Hashtable();
  184. for (int i = 0; i < this.dgvData.SelectedRows.Count; i++)
  185. {
  186. ht[Convert.ToDateTime(this.dgvData.SelectedRows[i].Cells["支出日期"].Value).ToString("yyyy-MM-dd")] = this.dgvData.SelectedRows[i].Cells["支出日期"].Value.ToString().Trim();
  187. ht2[this.dgvData.SelectedRows[i].Cells["取款人"].Value.ToString().Trim()] = this.dgvData.SelectedRows[i].Cells["取款人"].Value.ToString().Trim();
  188. }
  189. if (ht.Count > 1)
  190. { MessageBoxCustom.Show("多数据打印,必须为同一日期!"); return; }
  191. if (ht2.Count > 1)
  192. { MessageBoxCustom.Show("多数据打印,必须为同一取款人!"); return; }
  193. Hashtable htData = new Hashtable();
  194. htData["dgvData"] = this.dgvData;
  195. LYFZ.Software.MainBusiness.ReportPrint.ReportFixedFormat.PrintFixedFormat(LYFZ.EnumPublic.PrintTypeEnum.现金支出, htData);
  196. }
  197. /// <summary>
  198. /// 导出
  199. /// </summary>
  200. /// <param name="sender"></param>
  201. /// <param name="e"></param>
  202. void btnExport_Click(object sender, EventArgs e)
  203. {
  204. this.dgvData.ExportDataTable();
  205. }
  206. /// <summary>
  207. /// 窗体大小发生变化
  208. /// </summary>
  209. /// <param name="sender"></param>
  210. /// <param name="e"></param>
  211. void FrmCashExpenditures_Resize(object sender, EventArgs e)
  212. {
  213. switch (this.panelClose.Location.Y)
  214. {
  215. case 5: this.flowLayoutPanel1.Height = 40; break;
  216. case 39: this.flowLayoutPanel1.Height = 73; break;
  217. }
  218. }
  219. /// <summary>
  220. /// 绑定数据
  221. /// </summary>
  222. void PublicFunctionRows()
  223. {
  224. string StrWhere = " Where Oiae_Type = '支出'";
  225. if (!string.IsNullOrEmpty(this.dtpDateTimeStart.DateValue.Trim()) && !string.IsNullOrEmpty(this.dtpDateTimeEnd.DateValue.Trim()))
  226. { StrWhere += LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetDateTime("Oiae_IEDatetime", this.dtpDateTimeStart.DateValue.Trim(), this.dtpDateTimeEnd.DateValue.Trim()); }
  227. if (this.htData.ContainsKey("WithdrawalsName"))
  228. { StrWhere += " And Oiae_ThePayer = '" + this.htData["WithdrawalsName"].ToString().Trim() + "'"; }
  229. if (this.htData.ContainsKey("ItemName"))
  230. { StrWhere += " And Oiae_ProjectName = '" + this.htData["ItemName"].ToString().Trim() + "'"; }
  231. this.htData.Clear();
  232. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  233. {
  234. _dataTable = LYFZ.BLL.BLL_ErpOrderView.GetData_FinancialManagementIncomeExpenditureStatistics(StrWhere, "");
  235. });
  236. #region
  237. if ( _dataTable != null)
  238. this.dgvData.RowCount = _dataTable.Rows.Count;
  239. this.dgvData.DataColumns("ID,费用项目,费用金额,支出日期,取款人,支出方式,录单人,支出说明", strHideField: "ID");
  240. this.dgvData.Columns["费用项目"].Width = 250;
  241. this.dgvData.Columns["支出日期"].Width = 120;
  242. this.dgvData.Columns["支出方式"].Width = 150;
  243. this.dgvData.FillLastColumn();
  244. for (int t = 0; t < _dataTable.Rows.Count; t++)
  245. {
  246. DataGridViewRow dgvr = new DataGridViewRow();
  247. DataGridViewCell cell = null;
  248. cell = new DataGridViewTextBoxCell();
  249. cell.Value = _dataTable.Rows[t]["ID"].ToString().Trim(); ;
  250. dgvr.Cells.Add(cell);
  251. cell = new DataGridViewTextBoxCell();
  252. cell.Value = _dataTable.Rows[t]["费用项目"].ToString().Trim();
  253. dgvr.Cells.Add(cell);
  254. cell = new DataGridViewTextBoxCell();
  255. cell.Value = _dataTable.Rows[t]["费用金额"].ToString().Trim();
  256. dgvr.Cells.Add(cell);
  257. cell = new DataGridViewTextBoxCell();
  258. cell.Value = LYFZ.BLL.OtherCommonModel.DateTimeToString(_dataTable.Rows[t]["支出日期"]);
  259. dgvr.Cells.Add(cell);
  260. cell = new DataGridViewTextBoxCell();
  261. cell.Value = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetUserName(_dataTable.Rows[t]["取款人"].ToString().Trim());
  262. dgvr.Cells.Add(cell);
  263. cell = new DataGridViewTextBoxCell();
  264. cell.Value = _dataTable.Rows[t]["支出方式"].ToString().Trim();
  265. dgvr.Cells.Add(cell);
  266. cell = new DataGridViewTextBoxCell();
  267. cell.Value = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetUserName(_dataTable.Rows[t]["录单人"].ToString().Trim());
  268. dgvr.Cells.Add(cell);
  269. cell = new DataGridViewTextBoxCell();
  270. cell.Value = _dataTable.Rows[t]["支出说明"].ToString().Trim();
  271. dgvr.Cells.Add(cell);
  272. this.dgvData.Rows.Add(dgvr);
  273. }
  274. #endregion
  275. this.dgvData.ClearSelection();
  276. }
  277. }
  278. }