123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303 |
- using LYFZ.Software.MainBusiness.DoorCityProcess;
- using System;
- 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.Payroll
- {
- public partial class FrmSearchRecord : LYFZ.Software.UI.FinancialManagement.Payroll.FrmSearchRecord
- {
- public string N_NameText;
- public string N_NameTag;
- public string N_Name;
- private delegate void UpdateControl();
- LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
- LYFZ.BLL.BLL_AllViewSet AllViewSetbll = new BLL.BLL_AllViewSet();
- public FrmSearchRecord()
- {
- }
-
-
-
-
-
- protected override void FrmSearchRecord_Shown(object sender, EventArgs e)
- {
- try
- {
- this.txtTimeStart.Text = SDateTime.Now.ToString("yyyy-MM") + "-01";
- this.txtTimeEnd.Text = Convert.ToDateTime(SDateTime.Now.ToString("yyyy-MM") + "-01").AddMonths(1).AddSeconds(-1).ToString("yyyy-MM-dd");
- if (this.N_NameText == "全部" || this.N_Name == "Department")
- {
- this.dgv.Visible = false;
- this.btnDelete.Visible = false;
- this.TotalAllPerformance();
- }
- else
- {
- this.dgvAll.Visible = false;
- this.GetWage(this.N_NameTag, this.txtTimeStart.DateValue, this.txtTimeEnd.DateValue);
- }
-
- this.btnDelete.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.StatisticalInquiryAllWagesCompetence, CustomAttributes.OperatingAuthority.Delete);
- this.btnExPort.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.StatisticalInquiryAllWagesCompetence, CustomAttributes.OperatingAuthority.DataExport);
- }
- catch (Exception ex)
- { MessageBoxCustom.Show(ex.Message); }
- }
-
-
-
-
-
-
- public void GetWage(string EmployeeName, string StartTime, string EndTime)
- {
- this.dgv.Rows.Clear();
- StringBuilder str = new StringBuilder();
- DataTable dt = new DataTable();
- str.Append(" Wcr_PerformanceTimeStart>='" + this.txtTimeStart.DateValue + "' and Wcr_PerformanceTimeEnd<='" + this.txtTimeEnd.DateValue + "'");
- str.Append(" and Wcr_EmployeeID = '" + EmployeeName + "'");
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- {
- dt = orbll.GetView_Custom("tb_ErpWageCommissionRecords left Join tb_ErpSystemCategory on Wcr_CommissionScheme = Sc_ClassCode Left Join dbo.tb_ErpUser on User_EmployeeID = Wcr_EmployeeID", StrWhere: str.ToString(), ShowColumnName: "tb_ErpWageCommissionRecords.ID,User_Name,Wcr_CommissionScheme,Sc_ClassName,Wcr_CurrentPerformance,Wcr_PieceCommission,Wcr_CommissionWages,Wcr_CreateDateTime,Wcr_CreateName").Tables[0];
- if (dt.Rows.Count > 0)
- {
- this.Invoke(new UpdateControl(delegate()
- {
- decimal PerformanceSum = 0;
- decimal PieceSum = 0;
- decimal CommissionSum = 0;
- for (int t = 0; t < dt.Rows.Count; t++)
- {
- #region
- DataGridViewRow dgvr = new DataGridViewRow();
- DataGridViewCell cell = null;
-
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["ID"].ToString().Trim();
- dgvr.Cells.Add(cell);
-
- cell = new DataGridViewTextBoxCell();
- cell.Value = Convert.ToDateTime(dt.Rows[t]["Wcr_CreateDateTime"]).ToString("yyyy-MM-dd HH:mm").Trim();
- dgvr.Cells.Add(cell);
-
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["User_Name"].ToString().Trim();
- dgvr.Cells.Add(cell);
-
- cell = new DataGridViewTextBoxCell();
- if (dt.Rows[t]["Wcr_CommissionScheme"].ToString().Trim() == "计件提成")
- { cell.Value = dt.Rows[t]["Wcr_CommissionScheme"].ToString().Trim(); }
- else
- { cell.Value = dt.Rows[t]["Sc_ClassName"].ToString(); }
- dgvr.Cells.Add(cell);
-
- cell = new DataGridViewTextBoxCell();
- cell.Value = Convert.ToDecimal(dt.Rows[t]["Wcr_CurrentPerformance"]).ToString("N2").Trim();
- PerformanceSum += Convert.ToDecimal(dt.Rows[t]["Wcr_CurrentPerformance"]);
- dgvr.Cells.Add(cell);
-
- cell = new DataGridViewTextBoxCell();
- cell.Value = Convert.ToDecimal(dt.Rows[t]["Wcr_PieceCommission"]).ToString("N2").Trim();
- PieceSum += Convert.ToDecimal(dt.Rows[t]["Wcr_PieceCommission"]);
- dgvr.Cells.Add(cell);
-
- cell = new DataGridViewTextBoxCell();
- cell.Value = Convert.ToDecimal(dt.Rows[t]["Wcr_CommissionWages"]).ToString("N2").Trim();
- CommissionSum += Convert.ToDecimal(dt.Rows[t]["Wcr_CommissionWages"]);
- dgvr.Cells.Add(cell);
-
- cell = new DataGridViewTextBoxCell();
- cell.Value = LYFZ.DAL.DAL_ErpUser.SimpleUserDataTable.Rows.Find(dt.Rows[t]["Wcr_CreateName"])["User_Name"].ToString();
- dgvr.Cells.Add(cell);
- this.dgv.Rows.Add(dgvr);
- #endregion
- }
- this.dgv.ClearSelection();
- int rows = this.dgv.Rows.Add();
- this.dgv.Rows[rows].Cells[1].Value = "统计:";
- this.dgv.Rows[rows].Cells[4].Value = PerformanceSum.ToString("N2");
- this.dgv.Rows[rows].Cells[5].Value = PieceSum.ToString("N2");
- this.dgv.Rows[rows].Cells[6].Value = CommissionSum.ToString("N2");
- }));
- }
- });
- }
-
-
-
- public void TotalAllPerformance()
- {
- this.dgvAll.Rows.Clear();
- string StrDtpStart = this.txtTimeStart.Text;
- string StrDtpEnd = this.txtTimeEnd.Text;
- string StrWhere = "";
- if (this.N_Name == "Department")
- { StrWhere = " And User_Department='" + N_NameTag + "'"; }
- #region 部门
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- {
- string ExecuteSql = orbll.GetView_CustomReturnExecuteSql("tb_ErpUser", StrWhere: "User_Status='在职'" + StrWhere, ShowColumnName: "User_Name,User_EmployeeID");
- ExecuteSql += ";" + orbll.GetView_CustomReturnExecuteSql("tb_ErpWageCommissionRecords", StrWhere: "Wcr_PerformanceTimeStart>='" + StrDtpStart + "' and Wcr_PerformanceTimeEnd<='" + StrDtpEnd + "'", ShowColumnName: "Wcr_EmployeeID,sum(Wcr_CurrentPerformance) AS 当前业绩,sum(Wcr_PieceCommission) AS 计件提成,sum(Wcr_CommissionWages) AS 提成工资", StrGroupBy: "Wcr_EmployeeID");
- DataSet dtSet = orbll.GetView_Custom(ExecuteSql);
- DataTable dt = dtSet.Tables["ds"];
- DataTable tbl = dtSet.Tables["ds1"];
- tbl.PrimaryKey = new DataColumn[] { tbl.Columns["Wcr_EmployeeID"] };
- this.Invoke(new UpdateControl(delegate()
- {
- for (int t = 0; t < dt.Rows.Count; t++)
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- DataGridViewCell cell = null;
-
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["User_EmployeeID"].ToString().Trim();
- dgvr.Cells.Add(cell);
-
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["User_Name"].ToString().Trim();
- dgvr.Cells.Add(cell);
-
- cell = new DataGridViewTextBoxCell();
- DataRow dtRow = tbl.Rows.Find(dt.Rows[t]["User_EmployeeID"].ToString().Trim());
- if (dtRow != null)
- { cell.Value = dtRow["当前业绩"]; }
- else
- { cell.Value = "0.00"; }
-
-
-
-
-
- dgvr.Cells.Add(cell);
-
- cell = new DataGridViewTextBoxCell();
- DataRow dtRow2 = tbl.Rows.Find(dt.Rows[t]["User_EmployeeID"].ToString().Trim());
- if (dtRow2 != null)
- { cell.Value = dtRow2["计件提成"]; }
- else
- { cell.Value = "0.00"; }
-
-
-
-
-
- dgvr.Cells.Add(cell);
-
- cell = new DataGridViewTextBoxCell();
- DataRow dtRow3 = tbl.Rows.Find(dt.Rows[t]["User_EmployeeID"].ToString().Trim());
- if (dtRow3 != null)
- { cell.Value = dtRow3["提成工资"]; }
- else
- { cell.Value = "0.00"; }
-
-
-
-
-
- dgvr.Cells.Add(cell);
- this.dgvAll.Rows.Add(dgvr);
- }
- this.dgvAll.ClearSelection();
- }));
- });
- #endregion
- }
-
-
-
-
-
- protected override void btnDelete_Click(object sender, EventArgs e)
- {
- try
- {
- if (this.dgv.SelectedRows.Count == 0)
- { MessageBoxCustom.Show("请选中你要删除的数据!"); return; }
- if (this.dgv.CurrentRow.Cells["Column2"].Value.ToString() == "统计:")
- { MessageBoxCustom.Show("此行不可删除!"); return; }
- if (MessageBoxCustom.Show("你确定要删除吗?", "删除提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
- {
- LYFZ.BLL.BLL_ErpWageCommissionRecords bll = new BLL.BLL_ErpWageCommissionRecords();
- int id = Convert.ToInt32(this.dgv.CurrentRow.Cells["ID"].Value);
- if (bll.Delete(id))
- {
- string logsContent = "删除工资提成记录:" + this.dgv.CurrentRow.Cells["Column3"].Value.ToString() + " " + this.dgv.CurrentRow.Cells["Column4"].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);
-
- this.GetWage(this.N_NameTag, this.txtTimeStart.Text, this.txtTimeEnd.Text);
- MessageBoxCustom.Show("删除成功!");
- }
- }
- }
- catch (Exception ex)
- { MessageBoxCustom.Show(ex.Message); }
- }
-
-
-
-
-
- protected override void btnSelect_Click(object sender, EventArgs e)
- {
- if (this.N_NameText == "全部" || this.N_Name == "Department")
- {
- this.dgv.Visible = false;
- this.btnDelete.Visible = false;
- this.TotalAllPerformance();
- }
- else
- {
- this.dgvAll.Visible = false;
- this.GetWage(this.N_NameTag, this.txtTimeStart.DateValue, this.txtTimeEnd.DateValue);
- }
- }
-
-
-
-
-
- protected override void dgvAll_SortCompare(object sender, DataGridViewSortCompareEventArgs e)
- {
- if (e.Column.Name == "员工姓名" || e.Column.Name == "业绩金额")
- { e.SortResult = (Convert.ToDouble(e.CellValue1) - Convert.ToDouble(e.CellValue2) > 0) ? 1 : (Convert.ToDouble(e.CellValue1) - Convert.ToDouble(e.CellValue2) < 0) ? -1 : 0; }
-
- else
- { e.SortResult = System.String.Compare(Convert.ToString(e.CellValue1), Convert.ToString(e.CellValue2)); }
- e.Handled = true;
- }
-
-
-
-
-
- protected override void btnExPort_Click(object sender, EventArgs e)
- {
- if (this.dgv.Visible)
- { this.dgv.ExportDataTable(); }
- else if (this.dgvAll.Visible)
- { this.dgvAll.ExportDataTable(); }
- }
- }
- }
|