123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220 |
- using LYFZ.ComponentLibrary;
- using LYFZ.Software.MainBusiness.DoorCityProcess;
- 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 FrmOtherIncome : LYFZ.Software.UI.FinancialManagement.FrmOtherIncome
- {
- LYFZ.BLL.BLL_ErpOtherIncomeAndExpenses oiebll = new BLL.BLL_ErpOtherIncomeAndExpenses();
- public FrmOtherIncome()
- {
- this.Shown += FrmOtherIncome_Shown;
- this.txtkeyword.KeyDown += txtkeyword_KeyDown;
- this.btnQuery.Click += btnQuery_Click;
- this.btnEntry.Click += btnEntry_Click;
- this.btnDelete.Click += btnDelete_Click;
- this.btnPrint.Click += btnPrint_Click;
- this.btnClose.Click += btnClose_Click;
- this.Resize += FrmOtherIncome_Resize;
- }
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void FrmOtherIncome_Shown(object sender, EventArgs e)
- {
- this.dgvData.MultiSelect = true;
- this.dtpDateTimeStart.DateValue = SDateTime.Now.ToString("yyyy-MM-dd");
- this.dtpDateTimeEnd.DateValue = this.dtpDateTimeStart.DateValue;
- this.btnEntry.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.OtherIncomeCompetence, CustomAttributes.OperatingAuthority.Add);
- this.btnDelete.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.OtherIncomeCompetence, CustomAttributes.OperatingAuthority.Delete);
- this.btnPrint.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.OtherIncomeCompetence, CustomAttributes.OperatingAuthority.Print);
- this.PublicFunctionRows();
- }
- /// <summary>
- /// 回车查询
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void txtkeyword_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- { 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 btnEntry_Click(object sender, EventArgs e)
- {
- LYFZ.Software.MainBusiness.FinancialManagement.OtherIncome.FrmOtherIncomeEntry frm = new OtherIncome.FrmOtherIncomeEntry();
- frm.ShowDialog();
- if (frm.IsSaveed)
- { this.PublicFunctionRows(); }
- }
- /// <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 (model.Oiae_SourceType == 1)
- { MessageBoxCustom.Show("'" + this.dgvData.CurrentRow.Cells["项目名称"].Value.ToString().Trim() + "'为礼服报损转入数据,不能直接删除!\r\n应到礼服退押金处进行删除!"); return; }
- if (MessageBoxCustom.Show("你确定要删除吗?", "删除提示", MessageBoxButtons.YesNo) == DialogResult.No)
- { return; }
- if (oiebll.Delete(ID) == true)
- {
- // 写入操作日志
- 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 btnPrint_Click(object sender, EventArgs e)
- {
- if (this.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 FrmOtherIncome_Resize(object sender, EventArgs e)
- {
- switch (this.panelClose.Location.Y)
- {
- case 5: this.flowLayoutPanel1.Height = 40; break;
- case 41: this.flowLayoutPanel1.Height = 75; break;
- }
- }
- /// <summary>
- /// 绑定数据
- /// </summary>
- void PublicFunctionRows()
- {
- string StrWhere = " Where Oiae_Type = '收入'";
- if (!string.IsNullOrEmpty(this.txtkeyword.Text.Trim()))
- { StrWhere += " And (Oiae_ProjectName like '%" + this.txtkeyword.Text.Trim() + "%' or dbo.fn_CheckUserIDGetUserName(Oiae_ThePayer) like '%" + this.txtkeyword.Text.Trim() + "%')"; }
- if (!string.IsNullOrEmpty(this.dtpDateTimeStart.DateValue) && !string.IsNullOrEmpty(this.dtpDateTimeEnd.DateValue))
- { StrWhere += PublicCodeClasses.GetDateTime("Oiae_IEDatetime", this.dtpDateTimeStart.DateValue, this.dtpDateTimeEnd.DateValue); }
- DataTable newTable = new DataTable();
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- {
- newTable = LYFZ.BLL.BLL_ErpOrderView.GetData_FinancialManagementIncomeExpenditureStatistics(StrWhere, "");
- });
- #region
- 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 < newTable.Rows.Count; t++)
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- DataGridViewCell cell = null;
- cell = new DataGridViewTextBoxCell();
- cell.Value = newTable.Rows[t]["ID"].ToString().Trim(); ;
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = newTable.Rows[t]["费用项目"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = newTable.Rows[t]["费用金额"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = LYFZ.BLL.OtherCommonModel.DateTimeToString(newTable.Rows[t]["支出日期"]);
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = newTable.Rows[t]["取款人"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetUserName(newTable.Rows[t]["录单人"].ToString().Trim());
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = newTable.Rows[t]["支出方式"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = newTable.Rows[t]["支出说明"].ToString().Trim();
- dgvr.Cells.Add(cell);
- this.dgvData.Rows.Add(dgvr);
- }
- #endregion
- this.dgvData.ClearSelection();
- }
- }
- }
|