FrmOtherIncome.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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 FrmOtherIncome : LYFZ.Software.UI.FinancialManagement.FrmOtherIncome
  15. {
  16. LYFZ.BLL.BLL_ErpOtherIncomeAndExpenses oiebll = new BLL.BLL_ErpOtherIncomeAndExpenses();
  17. public FrmOtherIncome()
  18. {
  19. this.Shown += FrmOtherIncome_Shown;
  20. this.txtkeyword.KeyDown += txtkeyword_KeyDown;
  21. this.btnQuery.Click += btnQuery_Click;
  22. this.btnEntry.Click += btnEntry_Click;
  23. this.btnDelete.Click += btnDelete_Click;
  24. this.btnPrint.Click += btnPrint_Click;
  25. this.btnClose.Click += btnClose_Click;
  26. this.Resize += FrmOtherIncome_Resize;
  27. }
  28. /// <summary>
  29. /// 窗体加载事件
  30. /// </summary>
  31. /// <param name="sender"></param>
  32. /// <param name="e"></param>
  33. void FrmOtherIncome_Shown(object sender, EventArgs e)
  34. {
  35. this.dgvData.MultiSelect = true;
  36. this.dtpDateTimeStart.DateValue = SDateTime.Now.ToString("yyyy-MM-dd");
  37. this.dtpDateTimeEnd.DateValue = this.dtpDateTimeStart.DateValue;
  38. this.btnEntry.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.OtherIncomeCompetence, CustomAttributes.OperatingAuthority.Add);
  39. this.btnDelete.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.OtherIncomeCompetence, CustomAttributes.OperatingAuthority.Delete);
  40. this.btnPrint.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.OtherIncomeCompetence, CustomAttributes.OperatingAuthority.Print);
  41. this.PublicFunctionRows();
  42. }
  43. /// <summary>
  44. /// 回车查询
  45. /// </summary>
  46. /// <param name="sender"></param>
  47. /// <param name="e"></param>
  48. void txtkeyword_KeyDown(object sender, KeyEventArgs e)
  49. {
  50. if (e.KeyCode == Keys.Enter)
  51. { this.PublicFunctionRows(); }
  52. }
  53. /// <summary>
  54. /// 查询
  55. /// </summary>
  56. /// <param name="sender"></param>
  57. /// <param name="e"></param>
  58. void btnQuery_Click(object sender, EventArgs e)
  59. {
  60. this.PublicFunctionRows();
  61. }
  62. /// <summary>
  63. /// 录入
  64. /// </summary>
  65. /// <param name="sender"></param>
  66. /// <param name="e"></param>
  67. void btnEntry_Click(object sender, EventArgs e)
  68. {
  69. LYFZ.Software.MainBusiness.FinancialManagement.OtherIncome.FrmOtherIncomeEntry frm = new OtherIncome.FrmOtherIncomeEntry();
  70. frm.ShowDialog();
  71. if (frm.IsSaveed)
  72. { this.PublicFunctionRows(); }
  73. }
  74. /// <summary>
  75. /// 删除
  76. /// </summary>
  77. /// <param name="sender"></param>
  78. /// <param name="e"></param>
  79. void btnDelete_Click(object sender, EventArgs e)
  80. {
  81. if (this.dgvData.SelectedRows.Count == 0)
  82. { MessageBoxCustom.Show("请选中你要删除的数据!"); return; }
  83. int ID = Convert.ToInt32(this.dgvData.CurrentRow.Cells["ID"].Value);
  84. LYFZ.Model.Model_ErpOtherIncomeAndExpenses model = oiebll.GetModel(ID);
  85. if (model.ID > 0)
  86. {
  87. if (model.Oiae_FinancialAuditState == "已审核")
  88. { MessageBoxCustom.Show("财务已审核,不能删除!"); return; }
  89. if (model.Oiae_SourceType == 1)
  90. { MessageBoxCustom.Show("'" + this.dgvData.CurrentRow.Cells["项目名称"].Value.ToString().Trim() + "'为礼服报损转入数据,不能直接删除!\r\n应到礼服退押金处进行删除!"); return; }
  91. if (MessageBoxCustom.Show("你确定要删除吗?", "删除提示", MessageBoxButtons.YesNo) == DialogResult.No)
  92. { return; }
  93. if (oiebll.Delete(ID) == true)
  94. {
  95. // 写入操作日志
  96. string logsContent = "删除其它收入项目名称:" + this.dgvData.CurrentRow.Cells["项目名称"].Value.ToString() + " 金额为:" + this.dgvData.CurrentRow.Cells["项目金额"].Value.ToString();
  97. LYFZ.BLL.BLL_ErpSystemLogs.WriteSystemLog(LYFZ.EnumPublic.SystemLogsType.删除其它收入, logsContent, LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID, LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name);
  98. MessageBoxCustom.Show("删除成功!");
  99. this.PublicFunctionRows();
  100. }
  101. }
  102. }
  103. /// <summary>
  104. /// 关闭
  105. /// </summary>
  106. /// <param name="sender"></param>
  107. /// <param name="e"></param>
  108. void btnClose_Click(object sender, EventArgs e)
  109. {
  110. this.Close();
  111. }
  112. /// <summary>
  113. /// 打印收据
  114. /// </summary>
  115. /// <param name="sender"></param>
  116. /// <param name="e"></param>
  117. void btnPrint_Click(object sender, EventArgs e)
  118. {
  119. if (this.dgvData.SelectedRows.Count == 0)
  120. {
  121. MessageBoxCustom.Show("请选择你要打印的数据!");
  122. return;
  123. }
  124. Hashtable ht = new Hashtable();
  125. Hashtable ht2 = new Hashtable();
  126. for (int i = 0; i < this.dgvData.SelectedRows.Count; i++)
  127. {
  128. ht[Convert.ToDateTime(this.dgvData.SelectedRows[i].Cells["收入时间"].Value).ToString("yyyy-MM-dd")] = this.dgvData.SelectedRows[i].Cells["收入时间"].Value.ToString().Trim();
  129. ht2[this.dgvData.SelectedRows[i].Cells["付款人"].Value.ToString().Trim()] = this.dgvData.SelectedRows[i].Cells["付款人"].Value.ToString().Trim();
  130. }
  131. if (ht.Count > 1)
  132. { MessageBoxCustom.Show("多数据打印,必须为同一日期!"); return; }
  133. if (ht2.Count > 1)
  134. { MessageBoxCustom.Show("多数据打印,必须为同一取款人!"); return; }
  135. Hashtable htData = new Hashtable();
  136. htData["dgvData"] = this.dgvData;
  137. LYFZ.Software.MainBusiness.ReportPrint.ReportFixedFormat.PrintFixedFormat(LYFZ.EnumPublic.PrintTypeEnum.其它收入, htData);
  138. }
  139. /// <summary>
  140. /// 窗体大小发生变化
  141. /// </summary>
  142. /// <param name="sender"></param>
  143. /// <param name="e"></param>
  144. void FrmOtherIncome_Resize(object sender, EventArgs e)
  145. {
  146. switch (this.panelClose.Location.Y)
  147. {
  148. case 5: this.flowLayoutPanel1.Height = 40; break;
  149. case 41: this.flowLayoutPanel1.Height = 75; break;
  150. }
  151. }
  152. /// <summary>
  153. /// 绑定数据
  154. /// </summary>
  155. void PublicFunctionRows()
  156. {
  157. string StrWhere = " Where Oiae_Type = '收入'";
  158. if (!string.IsNullOrEmpty(this.txtkeyword.Text.Trim()))
  159. { StrWhere += " And (Oiae_ProjectName like '%" + this.txtkeyword.Text.Trim() + "%' or dbo.fn_CheckUserIDGetUserName(Oiae_ThePayer) like '%" + this.txtkeyword.Text.Trim() + "%')"; }
  160. if (!string.IsNullOrEmpty(this.dtpDateTimeStart.DateValue) && !string.IsNullOrEmpty(this.dtpDateTimeEnd.DateValue))
  161. { StrWhere += PublicCodeClasses.GetDateTime("Oiae_IEDatetime", this.dtpDateTimeStart.DateValue, this.dtpDateTimeEnd.DateValue); }
  162. DataTable newTable = new DataTable();
  163. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  164. {
  165. newTable = LYFZ.BLL.BLL_ErpOrderView.GetData_FinancialManagementIncomeExpenditureStatistics(StrWhere, "");
  166. });
  167. #region
  168. this.dgvData.DataColumns("ID,项目名称,项目金额,收入时间,付款人,录单人,进帐方式,项目说明", strHideField: "ID");
  169. this.dgvData.Columns["项目名称"].Width = 250;
  170. this.dgvData.Columns["收入时间"].Width = 120;
  171. this.dgvData.Columns["进帐方式"].Width = 150;
  172. this.dgvData.FillLastColumn();
  173. for (int t = 0; t < newTable.Rows.Count; t++)
  174. {
  175. DataGridViewRow dgvr = new DataGridViewRow();
  176. DataGridViewCell cell = null;
  177. cell = new DataGridViewTextBoxCell();
  178. cell.Value = newTable.Rows[t]["ID"].ToString().Trim(); ;
  179. dgvr.Cells.Add(cell);
  180. cell = new DataGridViewTextBoxCell();
  181. cell.Value = newTable.Rows[t]["费用项目"].ToString().Trim();
  182. dgvr.Cells.Add(cell);
  183. cell = new DataGridViewTextBoxCell();
  184. cell.Value = newTable.Rows[t]["费用金额"].ToString().Trim();
  185. dgvr.Cells.Add(cell);
  186. cell = new DataGridViewTextBoxCell();
  187. cell.Value = LYFZ.BLL.OtherCommonModel.DateTimeToString(newTable.Rows[t]["支出日期"]);
  188. dgvr.Cells.Add(cell);
  189. cell = new DataGridViewTextBoxCell();
  190. cell.Value = newTable.Rows[t]["取款人"].ToString().Trim();
  191. dgvr.Cells.Add(cell);
  192. cell = new DataGridViewTextBoxCell();
  193. cell.Value = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetUserName(newTable.Rows[t]["录单人"].ToString().Trim());
  194. dgvr.Cells.Add(cell);
  195. cell = new DataGridViewTextBoxCell();
  196. cell.Value = newTable.Rows[t]["支出方式"].ToString().Trim();
  197. dgvr.Cells.Add(cell);
  198. cell = new DataGridViewTextBoxCell();
  199. cell.Value = newTable.Rows[t]["支出说明"].ToString().Trim();
  200. dgvr.Cells.Add(cell);
  201. this.dgvData.Rows.Add(dgvr);
  202. }
  203. #endregion
  204. this.dgvData.ClearSelection();
  205. }
  206. }
  207. }