123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298 |
- using LYFZ.ComponentLibrary;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace LYFZ.Software.MainBusiness.FinancialManagement
- {
- public partial class FrmCashExpenditures : LYFZ.Software.UI.FinancialManagement.FrmCashExpenditures
- {
- LYFZ.BLL.BLL_ErpOtherIncomeAndExpenses oiebll = new BLL.BLL_ErpOtherIncomeAndExpenses();
- public FrmCashExpenditures()
- {
- this.Shown += FrmCashExpenditures_Shown;
- this.btnQuery.Click += btnQuery_Click;
- this.btnConditionQuery.Click += btnConditionQuery_Click;
- this.btnEntry.Click += btnEntry_Click;
- this.btnUpdate.Click += btnUpdate_Click;
- this.dgvData.CellDoubleClick += dgvData_CellDoubleClick;
- this.btnDelete.Click += btnDelete_Click;
- this.btnClose.Click += btnClose_Click;
- this.btnReport.Click += btnReport_Click;
- this.btnPrint.Click += btnPrint_Click;
- this.btnExport.Click += btnExport_Click;
- this.Resize += FrmCashExpenditures_Resize;
- }
- DataTable _dataTable = new DataTable();
- Hashtable htData = new Hashtable();
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void FrmCashExpenditures_Shown(object sender, EventArgs e)
- {
- this.dgvData.MultiSelect = true;
- this.dtpDateTimeStart.DateValue = SDateTime.Now.ToString("yyyy-MM-dd HH:mm");
- this.dtpDateTimeEnd.DateValue = this.dtpDateTimeStart.DateValue;
- this.btnEntry.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.CashExpendituresCompetence, CustomAttributes.OperatingAuthority.Add);
- this.btnUpdate.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.CashExpendituresCompetence, CustomAttributes.OperatingAuthority.Update);
- this.btnDelete.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.CashExpendituresCompetence, CustomAttributes.OperatingAuthority.Delete);
- this.btnPrint.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.CashExpendituresCompetence, CustomAttributes.OperatingAuthority.Print);
- this.btnReport.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.CashExpendituresCompetence, CustomAttributes.OperatingAuthority.ReportForm);
- this.PublicFunctionRows();
- }
- /// <summary>
- /// 查询
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnQuery_Click(object sender, EventArgs e)
- {
- this.PublicFunctionRows();
- }
- /// <summary>
- /// 条件查询
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnConditionQuery_Click(object sender, EventArgs e)
- {
- LYFZ.Software.MainBusiness.FinancialManagement.SetSmallForm.ConditionQueryOutlaySetSmallForm frm = new SetSmallForm.ConditionQueryOutlaySetSmallForm();
- frm.StrSystemCode = "BEBACIAFBEDIGJJFE";
- frm.ShowDialog();
- if (frm.IsSaveed)
- {
- this.htData = frm.htData;
- this.PublicFunctionRows();
- }
- }
- /// <summary>
- /// 录入
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnEntry_Click(object sender, EventArgs e)
- {
- LYFZ.Software.MainBusiness.FinancialManagement.SetSmallForm.StorefrontOutlaySetSmallForm frm = new SetSmallForm.StorefrontOutlaySetSmallForm();
- frm.EnumOutlayInputType = SetSmallForm.StorefrontOutlaySetSmallForm.OutlayInputType.添加;
- frm.EnumOutlayLoadType = SetSmallForm.StorefrontOutlaySetSmallForm.OutlayLoadType.店面支出;
- frm.ShowDialog();
- if (frm.IsSaveed)
- { this.PublicFunctionRows(); }
- }
- /// <summary>
- /// 修改
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnUpdate_Click(object sender, EventArgs e)
- {
- if (this.dgvData.Rows.Count > 0 && this.dgvData.CurrentRow != null)
- {
- LYFZ.Software.MainBusiness.FinancialManagement.SetSmallForm.StorefrontOutlaySetSmallForm frm = new SetSmallForm.StorefrontOutlaySetSmallForm();
- frm.EnumOutlayInputType = SetSmallForm.StorefrontOutlaySetSmallForm.OutlayInputType.修改;
- frm.EnumOutlayLoadType = SetSmallForm.StorefrontOutlaySetSmallForm.OutlayLoadType.店面支出;
- frm.OutlayID = Convert.ToInt32(this.dgvData.CurrentRow.Cells["ID"].Value);
- frm.ShowDialog();
- if (frm.IsSaveed)
- { this.PublicFunctionRows(); }
- }
- }
- /// <summary>
- /// 列表双击事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void dgvData_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
- {
- if (this.dgvData.Rows.Count > 0)
- {
- if (e.RowIndex >= 0 && e.ColumnIndex >= 0)
- {
- if (this.dgvData.SelectedRows.Count == 0)
- { MessageBoxCustom.Show("请选择你要修改的数据!"); return; }
- if (this.btnUpdate.Enabled)
- { this.btnUpdate_Click(this, null); }
- }
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnDelete_Click(object sender, EventArgs e)
- {
- if (this.dgvData.SelectedRows.Count == 0)
- { MessageBoxCustom.Show("请选中你要删除的数据!"); return; }
- int ID = Convert.ToInt32(this.dgvData.CurrentRow.Cells["ID"].Value);
- LYFZ.Model.Model_ErpOtherIncomeAndExpenses model = oiebll.GetModel(ID);
- if (model.ID > 0)
- {
- if (model.Oiae_FinancialAuditState == "已审核")
- { MessageBoxCustom.Show("财务已审核,不能删除!"); return; }
- if (MessageBoxCustom.Show("你确定要删除吗?", "删除提示", MessageBoxButtons.YesNo) == DialogResult.No)
- { return; }
- if (oiebll.Delete(ID))
- {
- // 写入操作日志
- string logsContent = "删除现金支出项目名称:" + this.dgvData.CurrentRow.Cells["费用项目"].Value.ToString() + " 金额为:" + this.dgvData.CurrentRow.Cells["费用金额"].Value.ToString();
- LYFZ.BLL.BLL_ErpSystemLogs.WriteSystemLog(LYFZ.EnumPublic.SystemLogsType.删除支出, logsContent, LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID, LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name);
- MessageBoxCustom.Show("删除成功!");
- this.PublicFunctionRows();
- }
- }
- }
- /// <summary>
- /// 关闭
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnClose_Click(object sender, EventArgs e)
- { this.Close(); }
- /// <summary>
- /// 报表
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnReport_Click(object sender, EventArgs e)
- {
- LYFZ.Software.MainBusiness.FinancialManagement.SetSmallForm.OutlayReportSetSmallForm frm = new SetSmallForm.OutlayReportSetSmallForm();
- frm.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
- frm.Location = new Point(LYFZ.EnumPublic.FormLocation_X, LYFZ.EnumPublic.FormLocation_Y);
- frm.Size = new Size(LYFZ.EnumPublic.FormSize_Width, LYFZ.EnumPublic.FormSize_Height);
- frm.EnumOutlayReportLoadType = SetSmallForm.OutlayReportSetSmallForm.OutlayReportLoadType.店面支出;
- frm.ShowDialog();
- }
- /// <summary>
- /// 打印收据
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnPrint_Click(object sender, EventArgs e)
- {
- if (dgvData.SelectedRows.Count == 0)
- { MessageBoxCustom.Show("请选择你要打印的数据!"); return; }
- Hashtable ht = new Hashtable();
- Hashtable ht2 = new Hashtable();
- for (int i = 0; i < this.dgvData.SelectedRows.Count; i++)
- {
- ht[Convert.ToDateTime(this.dgvData.SelectedRows[i].Cells["支出日期"].Value).ToString("yyyy-MM-dd")] = this.dgvData.SelectedRows[i].Cells["支出日期"].Value.ToString().Trim();
- ht2[this.dgvData.SelectedRows[i].Cells["取款人"].Value.ToString().Trim()] = this.dgvData.SelectedRows[i].Cells["取款人"].Value.ToString().Trim();
- }
- if (ht.Count > 1)
- { MessageBoxCustom.Show("多数据打印,必须为同一日期!"); return; }
- if (ht2.Count > 1)
- { MessageBoxCustom.Show("多数据打印,必须为同一取款人!"); return; }
- Hashtable htData = new Hashtable();
- htData["dgvData"] = this.dgvData;
- LYFZ.Software.MainBusiness.ReportPrint.ReportFixedFormat.PrintFixedFormat(LYFZ.EnumPublic.PrintTypeEnum.现金支出, htData);
- }
- /// <summary>
- /// 导出
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnExport_Click(object sender, EventArgs e)
- {
- this.dgvData.ExportDataTable();
- }
- /// <summary>
- /// 窗体大小发生变化
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void FrmCashExpenditures_Resize(object sender, EventArgs e)
- {
- switch (this.panelClose.Location.Y)
- {
- case 5: this.flowLayoutPanel1.Height = 40; break;
- case 39: this.flowLayoutPanel1.Height = 73; break;
- }
- }
- /// <summary>
- /// 绑定数据
- /// </summary>
- void PublicFunctionRows()
- {
- string StrWhere = " Where Oiae_Type = '支出'";
- if (!string.IsNullOrEmpty(this.dtpDateTimeStart.DateValue.Trim()) && !string.IsNullOrEmpty(this.dtpDateTimeEnd.DateValue.Trim()))
- { StrWhere += LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetDateTime("Oiae_IEDatetime", this.dtpDateTimeStart.DateValue.Trim(), this.dtpDateTimeEnd.DateValue.Trim()); }
- if (this.htData.ContainsKey("WithdrawalsName"))
- { StrWhere += " And Oiae_ThePayer = '" + this.htData["WithdrawalsName"].ToString().Trim() + "'"; }
- if (this.htData.ContainsKey("ItemName"))
- { StrWhere += " And Oiae_ProjectName = '" + this.htData["ItemName"].ToString().Trim() + "'"; }
- this.htData.Clear();
-
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- {
- _dataTable = LYFZ.BLL.BLL_ErpOrderView.GetData_FinancialManagementIncomeExpenditureStatistics(StrWhere, "");
- });
- #region
- if ( _dataTable != null)
- this.dgvData.RowCount = _dataTable.Rows.Count;
-
- this.dgvData.DataColumns("ID,费用项目,费用金额,支出日期,取款人,支出方式,录单人,支出说明", strHideField: "ID");
- this.dgvData.Columns["费用项目"].Width = 250;
- this.dgvData.Columns["支出日期"].Width = 120;
- this.dgvData.Columns["支出方式"].Width = 150;
- this.dgvData.FillLastColumn();
-
- for (int t = 0; t < _dataTable.Rows.Count; t++)
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- DataGridViewCell cell = null;
- cell = new DataGridViewTextBoxCell();
- cell.Value = _dataTable.Rows[t]["ID"].ToString().Trim(); ;
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = _dataTable.Rows[t]["费用项目"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = _dataTable.Rows[t]["费用金额"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = LYFZ.BLL.OtherCommonModel.DateTimeToString(_dataTable.Rows[t]["支出日期"]);
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetUserName(_dataTable.Rows[t]["取款人"].ToString().Trim());
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = _dataTable.Rows[t]["支出方式"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetUserName(_dataTable.Rows[t]["录单人"].ToString().Trim());
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = _dataTable.Rows[t]["支出说明"].ToString().Trim();
- dgvr.Cells.Add(cell);
- this.dgvData.Rows.Add(dgvr);
- }
- #endregion
- this.dgvData.ClearSelection();
- }
- }
- }
|