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; using LYFZ.BLL; using System.Collections; namespace LYFZ.Software.MainBusiness.FinancialManagement { public partial class frmWageStatisticsQuery : LYFZ.Software.UI.FinancialManagement.frmWageStatisticsQuery { public frmWageStatisticsQuery() { this.btntest.Click += btntest_Click; this.Shown += frmWageStatisticsQuery_Shown; // this.cmbEmployeeName.ComboBoxTree_NodeMouseClick+=cmbEmployeeName_ComboBoxTree_NodeMouseClick; this.Load += frmWageStatisticsQuery_Load; this.btnClosed.Click += bntClosed_Click; this.btnQuery.Click += btnQuery_Click; this.btnExport.Click += btnExport_Click; this.txtTimeStart.ValueChanged += txtTimeStart_ValueChanged; this.txtTimeEnd.ValueChanged += txtTimeEnd_ValueChanged; this.dgvStatisticsList.EraseCell = true; this.btnProgramSetting.Click += btnProgramSetting_Click; this.dgvStatisticsList.CellDoubleClick += dgvStatisticsList_CellDoubleClick; this.btnDataStatisticsQuery.Click += btnDataStatisticsQuery_Click; this.cbxStoreList.SelectedIndexChanged += cbxStoreList_SelectedIndexChanged; this.btnViews.Click += btnViews_Click; } /// /// 查看详细 /// /// /// void btnViews_Click(object sender, EventArgs e) { frmWageStatisticsViewList frmWSViewList = new frmWageStatisticsViewList(); frmWSViewList.StartDateTime = this.StartDateTime; frmWSViewList.EndDateTime = this.EndDateTime; frmWSViewList.UserWageStatisticsPerformanceCommissionList.AddRange(this.UserWageStatisticsPerformanceCommissionList.ToArray()); frmWSViewList.Show(); } /// /// 导出 /// /// /// void btnExport_Click(object sender, EventArgs e) { this.dgvStatisticsList.ExportDataTable(); } void cbxStoreList_SelectedIndexChanged(object sender, EventArgs e) { RefreshDataStatisticsQuery(); } /// /// 工资统计处理类 /// WageStatisticsProcess WSP_WageStatisticsProcess = new WageStatisticsProcess(); /// /// 订单信息总订单数统计处理类 /// WageStatisticsOrderInfo WSO_WageStatisticsOrderInfo = new WageStatisticsOrderInfo(); /// /// 订单信息当前阶段订单数统计处理类 /// WageStatisticsOrderInfo WSO_WageStatisticsCurrentOrderInfo = new WageStatisticsOrderInfo(); string WageStatisticsInfo = ""; /// /// 加载工资统计基础数据 /// void LoadBasisWageStatisticsDataTable(BackgroundWorker backgroundWorker) { WageStatisticsProcess.DisposeTable(WSP_WageStatisticsProcess.WageStatisticsOrderTable); WageStatisticsProcess.DisposeTable(WSP_WageStatisticsProcess.RelatedOrderCount); WageStatisticsProcess.DisposeTable(WSP_WageStatisticsProcess.CurrentRelatedOrderCount); WageStatisticsProcess.DisposeTable(WSP_WageStatisticsProcess.WageStatisticsOrderReceiptRecordTable); WageStatisticsProcess.DisposeTable(WSP_WageStatisticsProcess.WageStatisticsSatisfactionScoreTable); WageStatisticsProcess.DisposeTable(WSP_WageStatisticsProcess.DressRentalRecordsTable); WageStatisticsProcess.DisposeTable(WSP_WageStatisticsProcess.OtherConsumptionRecordTable); WageStatisticsProcess.DisposeTable(WSP_WageStatisticsProcess.PieceCommissionRecordTable); WageStatisticsProcess.DisposeTable(WSP_WageStatisticsProcess.MemberCardRechargeRecordTable); WageStatisticsProcess.DisposeTable(WSP_WageStatisticsProcess.MemberCardPaymentRecordTable); WageStatisticsProcess.DisposeTable(WSP_WageStatisticsProcess.AttractionsLevelStatisticsTable); WageStatisticsProcess.DisposeTable(WSP_WageStatisticsProcess.AttractionsPersonnelStatisticsTable); System.GC.Collect(); LYFZ.BLL.BLL_ErpWageCommissionSet.UpdateCommissionSet(); LYFZ.BLL.BLL_ErpCommissionPercentage.LoadCommissionPercentageTable(); backgroundWorker.ReportProgress(0, "正获取订单信息..."); this.WSP_WageStatisticsProcess.WageStatisticsOrderTable = WageStatisticsProcess.GetPROCE_WageStatisticsOrder(this.StartDateTime, this.EndDateTime, this.CurrentQueryStoreList); backgroundWorker.ReportProgress(0, "正统计本次相关订单数..."); this.WSP_WageStatisticsProcess.RelatedOrderCount = WageStatisticsProcess.GetRelatedOrderCount(this.StartDateTime, this.EndDateTime, this.CurrentQueryStoreList); backgroundWorker.ReportProgress(0, "正统计本次新订单数..."); this.WSP_WageStatisticsProcess.CurrentRelatedOrderCount = WageStatisticsProcess.GetCurrentRelatedOrderCount(this.StartDateTime, this.EndDateTime, this.CurrentQueryStoreList); backgroundWorker.ReportProgress(0, "正获取订单收款记录..."); this.WSP_WageStatisticsProcess.WageStatisticsOrderReceiptRecordTable = WageStatisticsProcess.GetPROCE_WageStatisticsOrderReceiptRecord(this.StartDateTime, this.EndDateTime, this.CurrentQueryStoreList); if (this.chkSatisfaction.Checked) { backgroundWorker.ReportProgress(0, "正获取订单满意度分值..."); this.WSP_WageStatisticsProcess.WageStatisticsSatisfactionScoreTable = WageStatisticsProcess.GetPROCE_WageStatisticsSatisfactionScore(this.StartDateTime, this.EndDateTime); } backgroundWorker.ReportProgress(0, "正获取礼服租售记录..."); this.WSP_WageStatisticsProcess.DressRentalRecordsTable = WageStatisticsProcess.GetDressRentalRecords(this.StartDateTime, this.EndDateTime, this.CurrentQueryStoreList); backgroundWorker.ReportProgress(0, "正获取其它销费记录..."); this.WSP_WageStatisticsProcess.OtherConsumptionRecordTable = WageStatisticsProcess.GetOtherConsumptionRecords(this.StartDateTime, this.EndDateTime, this.CurrentQueryStoreList); backgroundWorker.ReportProgress(0, "正获取计件提成记录..."); this.WSP_WageStatisticsProcess.PieceCommissionRecordTable = WageStatisticsProcess.GetPieceCommissionRecords(this.StartDateTime, this.EndDateTime, this.CurrentQueryStoreList); backgroundWorker.ReportProgress(0, "正获取计件提成订单记录..."); this.WSP_WageStatisticsProcess.PieceCommissionRecordOrderList = WageStatisticsProcess.GetPieceCommissionRecordOrderList(this.StartDateTime, this.EndDateTime, this.CurrentQueryStoreList); backgroundWorker.ReportProgress(0, "正获取会员卡充值记录..."); this.WSP_WageStatisticsProcess.MemberCardRechargeRecordTable = WageStatisticsProcess.GetMemberCardRechargeRecord(this.StartDateTime, this.EndDateTime, this.CurrentQueryStoreList); backgroundWorker.ReportProgress(0, "正获取会员服务卡收款..."); this.WSP_WageStatisticsProcess.MemberCardPaymentRecordTable = WageStatisticsProcess.GetMemberCardPaymentRecord(this.StartDateTime, this.EndDateTime, this.CurrentQueryStoreList); backgroundWorker.ReportProgress(0, "正获取景点和阶段人员信息..."); this.WSP_WageStatisticsProcess.AttractionsLevelStatisticsTable = WageStatisticsProcess.GetAttractionsLevelStatistics(this.StartDateTime, this.EndDateTime); backgroundWorker.ReportProgress(0, "正获取景点和阶段等级信息..."); this.WSP_WageStatisticsProcess.AttractionsPersonnelStatisticsTable = WageStatisticsProcess.GetAttractionsPersonnelStatistics(this.StartDateTime, this.EndDateTime); } /// /// 要统计的基础数据是否已统计加载 /// bool isDataStatisticsQuery = false; string DataStatisticsQueryTimestamp = ""; string GetDataStatisticsQueryTimestamp() { return this.StartDateTime.ToString("yyyy-MM-dd") + this.EndDateTime.AddDays(1).ToString("yyyy-MM-dd") + this.CurrentQueryStoreList.QueryType.ToString() + WageStatisticsProcess.GetQueryStoreList(this.CurrentQueryStoreList); } /// /// 刷新基础数据加载状态 标记是否需要重新加载基础数据 /// void RefreshDataStatisticsQuery() { GetCurrentQueryStoreList(); GetTimePeriod(); string newDataStatisticsQueryTimestamp = GetDataStatisticsQueryTimestamp(); if (string.IsNullOrEmpty(DataStatisticsQueryTimestamp)) { isDataStatisticsQuery = false; } else { if (DataStatisticsQueryTimestamp.Trim().ToLower() != newDataStatisticsQueryTimestamp.Trim().ToLower()) { isDataStatisticsQuery = false; } else { isDataStatisticsQuery = true; } } this.lbDataStatisticsQueryInfo.ForeColor = Color.Teal; if (!isDataStatisticsQuery) { this.lbDataStatisticsQueryInfo.ForeColor = Color.Red; if (this.WSP_WageStatisticsProcess.DressRentalRecordsTable == null) { this.lbDataStatisticsQueryInfo.Text = "未统计数据"; } else { if (IsStoreNode(this.cmbEmployeeName.TreeView.Nodes)) { this.lbDataStatisticsQueryInfo.Text = "统计时间和门店已改变,需要重新进行“数据统计查询”才能准确计算业绩和提成"; } else { this.lbDataStatisticsQueryInfo.Text = "统计时间已改变,需要重新进行“数据统计查询”才能准确计算业绩和提成"; } } } else { this.lbDataStatisticsQueryInfo.Text = WageStatisticsInfo; } } /// /// 统计查询工资基出数据 /// /// /// void btnDataStatisticsQuery_Click(object sender, EventArgs e) { GetEmployeeBasicQueryUserList(); GetCurrentQueryStoreList(); GetTimePeriod(); LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate (object obj, BackgroundWorker backgroundWorker) { try { backgroundWorker.ReportProgress(0, "正获取项目类别..."); frmEditStatisticsProgram.LoadAllSystemCategory(); backgroundWorker.ReportProgress(0, "正获取基本工资..."); LoadWagesSetDataTable(); backgroundWorker.ReportProgress(0, "正获取奖罚金额..."); LoadRewardPunishment(StartDateTime, EndDateTime); LoadBasisWageStatisticsDataTable(backgroundWorker); if (WSO_WageStatisticsOrderInfo != null) { WSO_WageStatisticsOrderInfo = null; } if (WSO_WageStatisticsCurrentOrderInfo != null) { WSO_WageStatisticsCurrentOrderInfo = null; } backgroundWorker.ReportProgress(0, "正在统计订单..."); WSO_WageStatisticsOrderInfo = new WageStatisticsOrderInfo(WSP_WageStatisticsProcess.RelatedOrderCount);//统计相关总订单数信息 WSO_WageStatisticsCurrentOrderInfo = new WageStatisticsOrderInfo(WSP_WageStatisticsProcess.CurrentRelatedOrderCount);//统计相关总订单数信息 DataStatisticsQueryTimestamp = GetDataStatisticsQueryTimestamp(); } catch(Exception ex) { MessageBoxCustom.Show(ex.Message); } }); WageStatisticsInfo = WSO_WageStatisticsOrderInfo.ToString() + "\r\n" + WSO_WageStatisticsCurrentOrderInfo.ToString("在统计时间内的订单数"); RefreshDataStatisticsQuery(); } void dgvStatisticsList_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0 && e.ColumnIndex == 2) { if (this.dgvStatisticsList.Rows[e.RowIndex].Tag != null) { frmWageQueryConfig frmWQC = new frmWageQueryConfig(); frmWQC.CurrentUser_EmployeeID = this.dgvStatisticsList.Rows[e.RowIndex].Tag.ToString(); frmWQC.ShowDialog(); } } } void btnProgramSetting_Click(object sender, EventArgs e) { frmWageQueryConfig frmWQC = new frmWageQueryConfig(); frmWQC.ShowDialog(); } #region 窗体首次加载和显示事件 void frmWageStatisticsQuery_Load(object sender, EventArgs e) { this.dgvStatisticsList.Columns[0].Visible = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.IsGroupEdition; HideORShowStoresList(LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.IsGroupEdition); } void frmWageStatisticsQuery_Shown(object sender, EventArgs e) { // 部门人员绑定 LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_DepartmentAndEmployee(this.cmbEmployeeName, IsFirstNodeNull: true, IsFirstNodeName: "全部", IsShowResign: false, IsShowAdmin: true, tb_User: LYFZ.DAL.DAL_ErpUser.SimpleUserDataTable); // 查看 this.cmbEmployeeName.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.StatisticalInquiryAllWagesCompetence, CustomAttributes.OperatingAuthority.ViewAll); this.cmbEmployeeName.TagFindText(LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID); this.btnExport.Enabled=LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.StatisticalInquiryAllWagesCompetence, CustomAttributes.OperatingAuthority.DataExport); this.btnProgramSetting.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.StatisticalInquiryAllWagesCompetence, CustomAttributes.OperatingAuthority.WageProgramSetting); //绑定门店 BindStoreList(LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.IsGroupEdition); BindTimePeriod(); GetEmployeeBasicQueryUserList(); GetCurrentQueryStoreList(); GetTimePeriod(); BindWageStatisticsQuery(true); } static DataTable _WagesSetDataTable = null; /// /// 员工基本工资集合 /// public static DataTable WagesSetDataTable { get { if (_WagesSetDataTable == null) { LoadWagesSetDataTable(); } return frmWageStatisticsQuery._WagesSetDataTable; } } public static LYFZ.BLL.BLL_ErpWagesSet wagesSetBll = new BLL_ErpWagesSet(); /// /// 加载员工基本工资集合 /// public static void LoadWagesSetDataTable() { if (_WagesSetDataTable != null) { _WagesSetDataTable.Rows.Clear(); _WagesSetDataTable.Dispose(); _WagesSetDataTable = null; } _WagesSetDataTable = wagesSetBll.GetAllList().Tables[0]; } /// /// 获取指定用户的基本工资 /// /// /// public static decimal GetBasicWage(string uid) { foreach (DataRow row in WagesSetDataTable.Rows) { if (row["Ws_StaffCode"].ToString().Trim().ToLower() == uid.ToLower().Trim() && row["Ws_BasicWage"]!=null) { return Convert.ToDecimal(row["Ws_BasicWage"]); } } return 0; } /// /// 获取指定用户的工资统计方案列表 /// /// /// public static string GetCommissionScheme(string uid) { try { foreach (DataRow row in WagesSetDataTable.Rows) { if (row["Ws_StaffCode"].ToString().Trim().ToLower() == uid.ToLower().Trim()) { return row["Ws_EarlyCommissionScheme"].ToString(); } } } catch { } return ""; } //创建一个委托,是为访问DataGridVie控件服务的。 // public delegate void UpdateControl(); /// /// 用户工资计算结果集合 /// List UserWageStatisticsPerformanceCommissionList = new List(); /// /// 绑定工资查询结果 /// void BindWageStatisticsQuery(bool isLoadData) { if (CurrentQueryUserList == null) { MessageBoxCustom.Show("请选择员工"); return; } // LYFZ.DAL.DAL_ErpUser.SimpleUserDataTable; if (isLoadData) { LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker) { backgroundWorker.ReportProgress(0, "正在初始化查询,请稍等..."); frmEditStatisticsProgram.LoadAllSystemCategory(); LoadWagesSetDataTable(); if (frmWageQueryConfig.WQCTable.Rows.Count <= 0) { MessageBoxCustom.Show("系统检查到你还没有设置任何工资统计方案,建义您先设置后再查询工资。"); } }); } LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker) { backgroundWorker.ReportProgress(0, "正在查询数据,请稍等..."); LoadRewardPunishment(StartDateTime, EndDateTime); }); this.dgvStatisticsList.Rows.Clear(); this.UserWageStatisticsPerformanceCommissionList.Clear(); #region 计算统计工资,业绩提成 LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker) { backgroundWorker.ReportProgress(0, "正在计算工资,请稍等..."); try { WageStatisticsProcess.LoadCommissionPercentageSetInfo(); } catch (Exception ex){ MessageBoxCustom.Show("业绩划分提成比例设置不正确,请重新设置后重试。\r\n"+ex.Message); return; } try { foreach (DataRow row in LYFZ.DAL.DAL_ErpUser.SimpleUserDataTable.Rows) { string User_EmployeeID = row["User_EmployeeID"].ToString(); if (CurrentQueryUserList.CheckRange(row["User_DividedShop"].ToString(), row["User_Department"].ToString(), User_EmployeeID) && row["User_Status"].ToString() != "离职") { UserWageStatisticsPerformanceCommission uwspc = new UserWageStatisticsPerformanceCommission(); uwspc.User_DividedShop = row["User_DividedShop"].ToString(); uwspc.User_DividedShopName = GetStoreSPIDToSPName(uwspc.User_DividedShop); uwspc.User_Department = Convert.ToInt32(row["User_Department"].ToString()); uwspc.Dt_Name = row["Dt_Name"].ToString(); uwspc.User_EmployeeID = User_EmployeeID; uwspc.User_Name = row["User_Name"].ToString(); backgroundWorker.ReportProgress(0, "计算[" + uwspc.User_Name.Trim() + "]的业绩请稍等..."); string[] CommissionSchemeList = GetCommissionScheme(User_EmployeeID).Split(','); for (int i = 0; i < CommissionSchemeList.Length; i++) { if (!string.IsNullOrEmpty(CommissionSchemeList[i])) { LYFZ.Model.Model_WageQueryConfig wqcModel = frmWageQueryConfig.FindWageQueryConfig(CommissionSchemeList[i]); if (wqcModel != null) { PerformanceCommissionInfo pcInfo = WSP_WageStatisticsProcess.GetPerformanceCommissionInfo(wqcModel, User_EmployeeID); uwspc.PerformanceCommissionList.Add(pcInfo); } } } UserWageStatisticsPerformanceCommissionList.Add(uwspc); } } } catch (Exception ex){ MessageBoxCustom.Show("计算统计工资时出错:"+ex.Message); } }); #endregion DataGridViewRow dgRow = null; foreach (UserWageStatisticsPerformanceCommission userWSPC in UserWageStatisticsPerformanceCommissionList) { dgRow = new DataGridViewRow(); dgRow.CreateCells(this.dgvStatisticsList); dgRow.Cells[0].Style = GetDataGridViewCellStyle(System.Drawing.Color.LightCyan, DataGridViewContentAlignment.MiddleLeft); dgRow.Cells[1].Style = dgRow.Cells[0].Style; dgRow.Cells[1].Style = dgRow.Cells[0].Style; dgRow.Cells[2].Style = dgRow.Cells[0].Style; dgRow.Cells[3].Style = dgRow.Cells[0].Style; dgRow.Cells[4].Style = dgRow.Cells[0].Style; dgRow.Cells[5].Style = dgRow.Cells[0].Style; dgRow.Cells[6].Style = dgRow.Cells[0].Style; dgRow.Cells[7].Style = dgRow.Cells[0].Style; dgRow.Cells[8].Style = dgRow.Cells[0].Style; dgRow.Cells[9].Style = dgRow.Cells[0].Style; dgRow.Cells[10].Style = dgRow.Cells[0].Style; dgRow.Cells[11].Style = dgRow.Cells[0].Style; dgRow.Cells[0].Value = userWSPC.User_DividedShopName; dgRow.Cells[1].Value = userWSPC.Dt_Name; dgRow.Cells[2].Value = userWSPC.User_Name; userWSPC.BasicWage = GetBasicWage(userWSPC.User_EmployeeID);//基本工资 dgRow.Cells[3].Value = userWSPC.BasicWage; dgRow.Tag = userWSPC.User_EmployeeID; userWSPC.Bonus = GetRewardPunish(userWSPC.User_EmployeeID, true);//奖金 dgRow.Cells[4].Value = userWSPC.Bonus; userWSPC.FineMoney = -GetRewardPunish(userWSPC.User_EmployeeID, false);//罚金 dgRow.Cells[5].Value = userWSPC.FineMoney;//罚金 dgRow.Cells[7].Value = "合计"; dgRow.Cells[8].Value = ""; userWSPC.SumComputePerformanceCommission(); dgRow.Cells[9].Value = userWSPC.SumPerformance;//总业绩 dgRow.Cells[10].Value = userWSPC.SumCommission;//总提成金额 dgRow.Cells[11].Value = ""; //总工资=基本工资+奖金+(-罚金)+总提成金额 dgRow.Cells[6].Value = Convert.ToDecimal(dgRow.Cells[3].Value) + Convert.ToDecimal(dgRow.Cells[4].Value) + Convert.ToDecimal(dgRow.Cells[5].Value) + Convert.ToDecimal(dgRow.Cells[10].Value); this.dgvStatisticsList.Rows.Add(dgRow); for (int i = 0; i < userWSPC.PerformanceCommissionList.Count; i++) { if (i == userWSPC.PerformanceCommissionList.Count - 1) { this.dgvStatisticsList.Rows.Add(GetSubDataGridViewRow(userWSPC.PerformanceCommissionList[i], true)); } else { this.dgvStatisticsList.Rows.Add(GetSubDataGridViewRow(userWSPC.PerformanceCommissionList[i])); } } } this.dgvStatisticsList.ClearSelection(); } /// /// /// /// 统计查询方案 /// /// /// DataGridViewRow GetSubDataGridViewRow(PerformanceCommissionInfo pcInfo, bool isEndRow = false) { LYFZ.Model.WageStatisticsQueryItem wItem = (LYFZ.Model.WageStatisticsQueryItem)Convert.ToInt32(pcInfo.WageQueryProgram.WQC_StatisticalItems); DataGridViewRow dgRow = new DataGridViewRow(); dgRow.CreateCells(this.dgvStatisticsList); dgRow.Cells[0].Style = GetDataGridViewCellStyle(System.Drawing.Color.White, DataGridViewContentAlignment.MiddleLeft); dgRow.Cells[1].Style = dgRow.Cells[0].Style; dgRow.Cells[1].Style = dgRow.Cells[0].Style; dgRow.Cells[2].Style = dgRow.Cells[0].Style; dgRow.Cells[3].Style = dgRow.Cells[0].Style; dgRow.Cells[4].Style = dgRow.Cells[0].Style; dgRow.Cells[5].Style = dgRow.Cells[0].Style; dgRow.Cells[6].Style = dgRow.Cells[0].Style; dgRow.Cells[7].Style = dgRow.Cells[0].Style; dgRow.Cells[8].Style = dgRow.Cells[0].Style; dgRow.Cells[9].Style = dgRow.Cells[0].Style; dgRow.Cells[10].Style = dgRow.Cells[0].Style; dgRow.Cells[11].Style = dgRow.Cells[0].Style; dgRow.Tag = pcInfo; dgRow.Cells[7].Value = wItem.ToString(); if (isEndRow) { dgRow.Cells[0].Tag = this.dgvStatisticsList.EraseCellDrawLineHEnd; dgRow.Cells[1].Tag = this.dgvStatisticsList.EraseCellDrawLineHEnd; dgRow.Cells[2].Tag = this.dgvStatisticsList.EraseCellDrawLineHEnd; dgRow.Cells[3].Tag = this.dgvStatisticsList.EraseCellDrawLineHEnd; dgRow.Cells[4].Tag = this.dgvStatisticsList.EraseCellDrawLineHEnd; dgRow.Cells[5].Tag = this.dgvStatisticsList.EraseCellDrawLineHEnd; dgRow.Cells[6].Tag = this.dgvStatisticsList.EraseCellDrawLineVHEnd; } else { dgRow.Cells[0].Tag = this.dgvStatisticsList.EraseCellDrawLine; dgRow.Cells[1].Tag = this.dgvStatisticsList.EraseCellDrawLine; dgRow.Cells[2].Tag = this.dgvStatisticsList.EraseCellDrawLine; dgRow.Cells[3].Tag = this.dgvStatisticsList.EraseCellDrawLine; dgRow.Cells[4].Tag = this.dgvStatisticsList.EraseCellDrawLine; dgRow.Cells[5].Tag = this.dgvStatisticsList.EraseCellDrawLine; dgRow.Cells[6].Tag = this.dgvStatisticsList.EraseCellDrawLineVEnd; } dgRow.Cells[8].Value = pcInfo.WageQueryProgram.WQC_QueryName; dgRow.Cells[9].Value = pcInfo.Performance; dgRow.Cells[10].Value = pcInfo.Commission; dgRow.Cells[11].Value = pcInfo.CommissionMsg; return dgRow; } string GetStoreSPIDToSPName(string sid) { foreach (ItemValue item in this.cbxStoreList.Items) { if (item.Value.ToString().ToLower() == sid.ToLower()) { return item.Text.Trim(); } } return "未知"; } System.Windows.Forms.DataGridViewCellStyle GetDataGridViewCellStyle(System.Drawing.Color bgcolor, System.Windows.Forms.DataGridViewContentAlignment alignment = DataGridViewContentAlignment.MiddleCenter) { System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); dataGridViewCellStyle2.Alignment = alignment; dataGridViewCellStyle2.BackColor = bgcolor;//System.Drawing.Color.FromArgb(((int)(((byte)(43)))), ((int)(((byte)(108)))), ((int)(((byte)(150))))); dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 10.5f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); dataGridViewCellStyle2.ForeColor = System.Drawing.Color.Black; dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight; dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText; return dataGridViewCellStyle2; } #endregion /// /// 开始时间 /// DateTime StartDateTime; /// /// 结束时间 /// DateTime EndDateTime; /// /// 当前要查询的门店信息集合 /// QueryStoreList CurrentQueryStoreList=null; /// /// 当前查询用户集合 /// BasicQueryUserList CurrentQueryUserList = null; void btnQuery_Click(object sender, EventArgs e) { GetEmployeeBasicQueryUserList(); GetCurrentQueryStoreList(); GetTimePeriod(); #if !DEBUG if (!isDataStatisticsQuery) { MessageBoxCustom.Show("检查到您还没有进行“数据统计查询”,将只能统计到基本工资奖罚金额。"); } #endif BindWageStatisticsQuery(false); } void btntest_Click(object sender, EventArgs e) { if (MessageBoxCustom.Show("旧版工资管理已过时,将不在升级和维护。\r\n您确定要续续打开吗?", msgBoxButton: MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK) { FrmPayroll fpll = new FrmPayroll(); fpll.Show(); } } #region 开始统计工资 #region 奖罚记录表 /// /// 员工奖罚 /// DataTable _RewardPunishment = null; LYFZ.BLL.BLL_ErpRewardPunishment rphBll = new BLL_ErpRewardPunishment(); string tempQueryTimestamp = ""; /// /// 奖 /// Hashtable SumRewardTable = new Hashtable(); /// /// 罚 /// Hashtable SumPunishTable = new Hashtable(); /// /// 加载员工奖罚 /// /// /// void LoadRewardPunishment(DateTime starDate, DateTime endDate) { string newTempQueryTimestamp = starDate.ToString("yyyy-MM-dd") + starDate.AddDays(1).ToString("yyyy-MM-dd"); if (_RewardPunishment != null) { if (!string.IsNullOrEmpty(tempQueryTimestamp) && newTempQueryTimestamp == tempQueryTimestamp) { return; } _RewardPunishment.Rows.Clear(); _RewardPunishment.Dispose(); _RewardPunishment = null; } _RewardPunishment = rphBll.GetList(" Rp_Status='薪资执行' and (Rp_RPDatetime>='" + starDate.ToString("yyyy-MM-dd") + "' and Rp_RPDatetime<'" + endDate.AddDays(1).ToString("yyyy-MM-dd") + "')", " Rp_Type,rp_money desc").Tables[0]; SumRewardPunish(); tempQueryTimestamp = newTempQueryTimestamp; } /// /// 计算奖罚 /// void SumRewardPunish() { SumRewardTable.Clear(); SumPunishTable.Clear(); foreach (DataRow row in _RewardPunishment.Rows) { string Rp_RelevantPeople = row["Rp_RelevantPeople"].ToString(); decimal Rp_Money = Convert.ToDecimal(row["Rp_Money"].ToString()); switch (row["Rp_Type"].ToString()) { case "奖励": if (SumRewardTable.ContainsKey(Rp_RelevantPeople)) { SumRewardTable[Rp_RelevantPeople] = Convert.ToDecimal(SumRewardTable[Rp_RelevantPeople]) + Rp_Money; } else { SumRewardTable.Add(Rp_RelevantPeople, Rp_Money); } break; case "惩罚": if (SumPunishTable.ContainsKey(Rp_RelevantPeople)) { SumPunishTable[Rp_RelevantPeople] = Convert.ToDecimal(SumPunishTable[Rp_RelevantPeople]) + Rp_Money; } else { SumPunishTable.Add(Rp_RelevantPeople, Rp_Money); } break; } } } /// /// 获取指定人员的奖罚金额 /// /// 指定人员的ID /// true 为奖 false 罚 /// decimal GetRewardPunish(string uid, bool isRewardPunish) { if (isRewardPunish) { if (SumRewardTable.ContainsKey(uid)) { return Convert.ToDecimal(SumRewardTable[uid]); } } else { if (SumPunishTable.ContainsKey(uid)) { return Convert.ToDecimal(SumPunishTable[uid]); } } return 0; } #endregion #region 订单前期 统计门市前期业绩 #endregion #endregion #region 初始查询条件绑定 /// /// 获取时间段 /// void GetTimePeriod() { this.StartDateTime = this.txtTimeStart.Value; this.EndDateTime = this.txtTimeEnd.Value; WSP_WageStatisticsProcess.StartDateTime = this.StartDateTime; WSP_WageStatisticsProcess.EndDateTime = this.EndDateTime; } void txtTimeStart_ValueChanged(object sender, EventArgs e) { this.txtTimeEnd.Value = this.txtTimeStart.Value.AddMonths(1).AddDays(-1); RefreshDataStatisticsQuery(); } void txtTimeEnd_ValueChanged(object sender, EventArgs e) { RefreshDataStatisticsQuery(); } /// /// 获取当前要查询的门店信息集合 /// void GetCurrentQueryStoreList() { if (CurrentQueryStoreList == null) { CurrentQueryStoreList = new QueryStoreList(); } else { CurrentQueryStoreList.QueryStoreInfoList.Clear(); } ItemValue cItem = (ItemValue)this.cbxStoreList.SelectedItem; if (cItem.Value.ToString() == "0") { CurrentQueryStoreList.QueryType = 0; } else if (cItem.Value.ToString() == "1") { CurrentQueryStoreList.QueryType = 1; foreach (ItemValue item in this.cbxStoreList.Items) { if (item.Tag != null) { QueryStoreInfo qStoreInfo = GetQueryStoreInfo(item); if (qStoreInfo != null) { CurrentQueryStoreList.QueryStoreInfoList.Add(qStoreInfo); } } } } else { CurrentQueryStoreList.QueryType = 1; QueryStoreInfo qStoreInfo = GetQueryStoreInfo(cItem); if (qStoreInfo != null) { CurrentQueryStoreList.QueryStoreInfoList.Add(qStoreInfo); } } } QueryStoreInfo GetQueryStoreInfo(ItemValue item) { if (item.Tag != null) { QueryStoreInfo qStoreInfo = new QueryStoreInfo(); qStoreInfo.DividedShop = item.Value.ToString(); qStoreInfo.DividedShop_Name = item.Text.Trim(); qStoreInfo.JMGDomain = ((DataRow)item.Tag)["Company_JMGDomain"].ToString(); return qStoreInfo; } return null; } /// /// 获取当前选择的用户集合 /// /// void GetEmployeeBasicQueryUserList() { if (CurrentQueryUserList == null) { CurrentQueryUserList = new BasicQueryUserList(); } else { CurrentQueryUserList.BasicUsers.Clear(); } if (this.cmbEmployeeName.Tag != null&& this.cmbEmployeeName.TreeView.SelectedNode!=null) { string dataValue = this.cmbEmployeeName.Tag.ToString(); string dataType = this.cmbEmployeeName.StrGetName.Trim(); if (dataType.Length > 0) { switch (dataType.ToLower()) { case "storename": CurrentQueryUserList.SelectTypeValue = dataValue; CurrentQueryUserList.SelectUserType = 1; break; case "department": if (IsStoreNode(this.cmbEmployeeName.TreeView.Nodes)) { CurrentQueryUserList.SelectTypeValue = this.cmbEmployeeName.TreeView.SelectedNode.Parent.Tag.ToString() + "," + dataValue; } else { CurrentQueryUserList.SelectTypeValue = dataValue; } CurrentQueryUserList.SelectUserType = 2; break; case "user": CurrentQueryUserList.SelectTypeValue = dataValue; CurrentQueryUserList.SelectUserType = 3; break; default: CurrentQueryUserList.SelectTypeValue = ""; CurrentQueryUserList.SelectUserType = 0; break; } } else { CurrentQueryUserList.SelectUserType = 0; } switch (CurrentQueryUserList.SelectUserType) { /* case 0: CurrentQueryUserList.BasicUsers = GetBasicQueryUserList(this.cmbEmployeeName.TreeView.Nodes, IsStoreNode(this.cmbEmployeeName.TreeView.Nodes)); break;*/ case 1: case 2: CurrentQueryUserList.BasicUsers = GetBasicQueryUserList(this.cmbEmployeeName.TreeView.SelectedNode.Nodes, IsStoreNode(this.cmbEmployeeName.TreeView.Nodes)); break; case 3: CurrentQueryUserList.BasicUsers = GetBasicQueryUserList(this.cmbEmployeeName.TreeView.SelectedNode, IsStoreNode(this.cmbEmployeeName.TreeView.Nodes)); break; } } else { MessageBoxCustom.Show("请选择要查询的员工!"); } } /// /// 判断是否存在门店节点 /// /// /// bool IsStoreNode(TreeNodeCollection nodes) { bool ret = false; foreach (TreeNode node in nodes) { string dataType = node.Name.Trim().ToLower(); if (dataType == "storename") { ret = true; break; } } return ret; } /// /// /// /// /// 是否有门店节点 /// List GetBasicQueryUserList(object nodes, bool isStore = false) { List retList = new List(); string DividedShop = ""; string DividedShopName = ""; int DepartmentID = 0; string DepartmentName = ""; TreeNodeCollection tNodes = null; if (nodes.GetType() == typeof(TreeNode)) { TreeNode userNode = (TreeNode)nodes; if (userNode.Parent != null) { if (isStore) { DividedShop = userNode.Parent.Parent.Tag.ToString(); DividedShopName = userNode.Parent.Parent.Text.Trim(); } if (userNode.Parent.Tag != null) { DepartmentID = Convert.ToInt32(userNode.Parent.Tag.ToString()); DepartmentName = userNode.Parent.Text.Trim(); BasicQueryUser cuser = new BasicQueryUser(); cuser.DividedShop = DividedShop; cuser.DividedShopName = DividedShopName; cuser.DepartmentID = DepartmentID; cuser.DepartmentName = DepartmentName; cuser.UserID = userNode.Tag.ToString().Trim(); cuser.UserName = userNode.Text.Trim(); retList.Add(cuser); } } } else { tNodes = (TreeNodeCollection)nodes; } if (tNodes != null) { foreach (TreeNode node in tNodes) { if (node.Tag != null && node.Tag.ToString().Length > 0) { string dataType = node.Name.Trim().ToLower(); switch (dataType.ToLower()) { case "department": if (isStore) { DividedShop = node.Parent.Tag.ToString(); DividedShopName = node.Parent.Text.Trim(); } DepartmentID = Convert.ToInt32(node.Tag.ToString()); DepartmentName = node.Text.Trim(); foreach (TreeNode cnode in node.Nodes) { if (cnode.Tag != null && cnode.Tag.ToString().Trim().Length > 0) { BasicQueryUser user = new BasicQueryUser(); user.DividedShop = DividedShop; user.DividedShopName = DividedShopName; user.DepartmentID = DepartmentID; user.DepartmentName = DepartmentName; user.UserID = cnode.Tag.ToString().Trim(); user.UserName = cnode.Text.Trim(); retList.Add(user); } } break; case "user": if (isStore) { DividedShop = node.Parent.Parent.Tag.ToString(); DividedShopName = node.Parent.Parent.Text.Trim(); } DepartmentID = Convert.ToInt32(node.Parent.Tag.ToString()); DepartmentName = node.Parent.Text.Trim(); BasicQueryUser cuser = new BasicQueryUser(); cuser.DividedShop = DividedShop; cuser.DividedShopName = DividedShopName; cuser.DepartmentID = DepartmentID; cuser.DepartmentName = DepartmentName; cuser.UserID = node.Tag.ToString().Trim(); cuser.UserName = node.Text.Trim(); retList.Add(cuser); break; } } } } return retList; } void bntClosed_Click(object sender, EventArgs e) { this.Close(); } /// /// 根是是否集团版显示隐藏门店列表 /// /// void HideORShowStoresList(bool isGroupEdition) { if (isGroupEdition) { this.cbxStoreList.Show(); this.labelEx3.Show(); } else { this.cbxStoreList.Hide(); this.labelEx3.Hide(); } } /// /// 绑定时间段 /// void BindTimePeriod() { this.txtTimeStart.Value = new DateTime(SDateTime.Now.Year, SDateTime.Now.Month, 1); this.txtTimeEnd.Value = this.txtTimeStart.Value.AddMonths(1).AddDays(-1); } /// /// 邦定门店 /// void BindStoreList(bool isGroupEdition) { DataRowCollection rows = null; int allValue = 0; int allStoreCount = 1; if (isGroupEdition) { LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker) { rows = LYFZ.DAL.DAL_ErpCompanyInfo.GetCompanyBasicInfoList(LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.SoftwareInfo.SDomainName.Trim()); allStoreCount = LYFZ.DAL.DAL_ErpCompanyInfo.GetCompanyBasicInfoListCount(); }); if (rows == null) { MessageBoxCustom.Show("获取门店信息失败!"); return; } else { if (allStoreCount > 1 && allStoreCount == rows.Count) { allValue = 0; } else { allValue = 1; } if (rows.Count > 1) { ItemValue itemAll = new ItemValue(allValue, "全部"); this.cbxStoreList.Items.Add(itemAll); this.cbxStoreList.SelectedIndex = 0; } //是否找到当前店 bool isCurrentStore = false; foreach (DataRow row in rows) { ItemValue itemStore = new ItemValue(row["Company_DividedShop"].ToString(), row["Company_Name"].ToString()); itemStore.Tag = row; this.cbxStoreList.Items.Add(itemStore); if (row["Company_JMGDomain"].ToString().Trim().ToLower() == LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.SoftwareInfo.SDomainName.Trim().ToLower()) { isCurrentStore = true; if (allValue == 1) { this.cbxStoreList.SelectedItem = itemStore; } } } if (!isCurrentStore) { MessageBoxCustom.Show("没有找到当前门店信息"); this.cbxStoreList.Items.Clear(); return; } } } else { ItemValue itemAll = new ItemValue(allValue, "全部"); this.cbxStoreList.Items.Add(itemAll); this.cbxStoreList.SelectedIndex = 0; } } #endregion } }