private void ProcedurePrint_Click(object sender, RoutedEventArgs e)
        {
            if (lcv.CurrentItem == null)
            {
                return;
            }

            SalaryProcedureInfoWrap salaryProcedureInfoWrap = new SalaryProcedureInfoWrap();
            SalaryInfo info = Do_GetSalaryProcedureInfo(lcv.CurrentItem as SalaryInfo, ref salaryProcedureInfoWrap);

            if (info != null)
            {
                string msg = "";
                if (PrintDeal.CreateInstance().PrintSalarySheet(info, salaryProcedureInfoWrap, ref msg))
                {
                    MessageBox.Show("打印完成。");
                }
                else
                {
                    if (!string.IsNullOrEmpty(msg))
                    {
                        MessageBox.Show(msg);
                    }
                }
            }
        }
 private void FlushCurrentViewAllCommission()
 {
     foreach (SalaryInfo info in lcv)
     {
         SalaryProcedureInfoWrap salaryProcedureInfoWrap = new SalaryProcedureInfoWrap();
         Do_GetSalaryProcedureInfo(info, ref salaryProcedureInfoWrap);
     }
 }
        private SalaryProcedureInfoWrap GetSalaryProcedureInfo(SalaryInfo salaryInfo, ref bool isUpdateTotalPrice)
        {
            SalaryProcedureInfoWrap salaryProcedureInfoWrap = new SalaryProcedureInfoWrap()
            {
                EmployeeName   = salaryInfo.EmployeeName,
                DepartmentName = salaryInfo.DepartmentName,
                CurrentDate    = new DateTime(salaryInfo.Year, salaryInfo.Month, 1)
            };

            ObservableCollection <ProcedureInfo> CurProcedureInfoList = null;

            foreach (SheetInfo sheetInfo in dataManager.AllSheetList)
            {
                //结单了
                if (sheetInfo.SettleDate == null)
                {
                    continue;
                }

                //本月内
                DateTime dateValue = sheetInfo.SettleDate.Value;
                if (dateValue.Year == salaryInfo.Year && dateValue.Month == salaryInfo.Month)
                {
                    CurProcedureInfoList = SheetDeal.GetAllProcedureInfo(sheetInfo.ID);
                    if (CurProcedureInfoList == null)
                    {
                        continue;
                    }

                    CurProcedureInfoList.ToList().ForEach(procedureInfo =>
                    {
                        //该人参与该流程
                        if (procedureInfo.EmployeeID == salaryInfo.EmployeeID)
                        {
                            salaryProcedureInfoWrap.TotalPrice += procedureInfo.Price;
                            salaryProcedureInfoWrap.SalaryProcedureInfoList.Add(new SalaryProcedureInfo
                            {
                                SheetID       = sheetInfo.ID,
                                SettleDate    = dateValue,
                                BSType        = sheetInfo.BSType,
                                Customer      = sheetInfo.Customer,
                                ProcedureName = procedureInfo.ProcedureName,
                                Price         = procedureInfo.Price
                            });
                        }
                    });
                }
            }
            if (salaryInfo.Commission != salaryProcedureInfoWrap.TotalPrice)
            {
                isUpdateTotalPrice    = true;
                salaryInfo.Commission = salaryProcedureInfoWrap.TotalPrice;
            }

            return(salaryProcedureInfoWrap);
        }
        private void FlushCommission_Click(object sender, RoutedEventArgs e)
        {
            if (lcv.CurrentItem == null)
            {
                return;
            }

            SalaryProcedureInfoWrap salaryProcedureInfoWrap = new SalaryProcedureInfoWrap();
            SalaryInfo info = Do_GetSalaryProcedureInfo(lcv.CurrentItem as SalaryInfo, ref salaryProcedureInfoWrap);

            if (info != null)
            {
                MessageBox.Show("统计完成!");
            }
        }
        private void ViewBSBtn_Click(object sender, RoutedEventArgs e)
        {
            if (lcv.CurrentItem == null)
            {
                return;
            }

            SalaryProcedureInfoWrap salaryProcedureInfoWrap = new SalaryProcedureInfoWrap();
            SalaryInfo info = Do_GetSalaryProcedureInfo(lcv.CurrentItem as SalaryInfo, ref salaryProcedureInfoWrap);

            if (info != null)
            {
                ProcedureInfoPanel.DataContext = salaryProcedureInfoWrap;
                ProcedureInfoPanel.Visibility  = Visibility.Visible;
            }
        }
        private SalaryInfo Do_GetSalaryProcedureInfo(SalaryInfo salaryInfo, ref SalaryProcedureInfoWrap salaryProcedureInfoWrap)
        {
            if (salaryInfo == null)
            {
                return(null);
            }

            bool isUpdateTotalPrice = false;

            salaryProcedureInfoWrap = GetSalaryProcedureInfo(salaryInfo, ref isUpdateTotalPrice);
            if (isUpdateTotalPrice)
            {
                SalaryDeal.UpdateSalaryInfo(salaryInfo);
                dataManager.AllSalaryList = AlgorithmClass.DeepClone <ObservableCollection <SalaryInfo> >(AllSalaryList);
            }

            return(salaryInfo);
        }
Ejemplo n.º 7
0
        public bool PrintSalarySheet(SalaryInfo salaryInfo, SalaryProcedureInfoWrap salaryProcedureInfoWrap, ref string msg)
        {
            if (salaryInfo == null || salaryProcedureInfoWrap == null)
            {
                return(false);
            }
            try
            {
                if (!xlsAccess.LoadXlsTemplate(ResourceMap.AppFolderPathHashtable[AppFolderPath.Templates] as string + ResourceMap.TemplatesNameHashtable[TemplatesName.Salary] as string))
                {
                    return(false);
                }

                if (xlsAccess.GetSheet((ResourceMap.TemplatesNameHashtable[TemplatesName.Salary] as string).Split('.')[0]))
                {
                    if (salaryProcedureInfoWrap.SalaryProcedureInfoList.Count > 1)
                    {
                        xlsAccess.CopyRow(11, 10, salaryProcedureInfoWrap.SalaryProcedureInfoList.Count - 1);
                    }

                    xlsAccess.SetCellValue(1, 1, salaryInfo.EmployeeName);
                    xlsAccess.SetCellValue(1, 4, salaryInfo.Year + " 年 " + salaryInfo.Month + " 月");
                    xlsAccess.SetCellValue(2, 1, salaryInfo.EmployeeSex);
                    xlsAccess.SetCellValue(2, 4, salaryInfo.DepartmentName);
                    xlsAccess.SetCellValue(3, 1, salaryInfo.BasicSalary);
                    xlsAccess.SetCellValue(3, 4, salaryInfo.MealSupplement);
                    xlsAccess.SetCellValue(4, 1, salaryInfo.SSB);
                    xlsAccess.SetCellValue(4, 4, salaryInfo.OtherBenefits);
                    xlsAccess.SetCellValue(5, 1, salaryInfo.Bounty);
                    xlsAccess.SetCellValue(5, 4, salaryInfo.OtherDeduction);
                    xlsAccess.SetCellValue(6, 1, salaryInfo.Commission);
                    xlsAccess.SetCellValue(6, 4, salaryInfo.NetPayroll);
                    xlsAccess.SetCellValue(7, 1, salaryInfo.Remark == null ? string.Empty : salaryInfo.Remark);

                    for (int index = 0; index < salaryProcedureInfoWrap.SalaryProcedureInfoList.Count; index++)
                    {
                        xlsAccess.SetCellValue(index + 10, 0, salaryProcedureInfoWrap.SalaryProcedureInfoList[index].SheetID);
                        xlsAccess.SetCellValue(index + 10, 1, salaryProcedureInfoWrap.SalaryProcedureInfoList[index].SettleDate.ToString("yyyy-MM-dd"));
                        xlsAccess.SetCellValue(index + 10, 2, salaryProcedureInfoWrap.SalaryProcedureInfoList[index].BSType == null ? "" : salaryProcedureInfoWrap.SalaryProcedureInfoList[index].BSType);
                        xlsAccess.SetCellValue(index + 10, 3, salaryProcedureInfoWrap.SalaryProcedureInfoList[index].Customer == null ? "" : salaryProcedureInfoWrap.SalaryProcedureInfoList[index].Customer);
                        xlsAccess.SetCellValue(index + 10, 4, salaryProcedureInfoWrap.SalaryProcedureInfoList[index].ProcedureName == null ? "" : salaryProcedureInfoWrap.SalaryProcedureInfoList[index].ProcedureName);
                        xlsAccess.SetCellValue(index + 10, 5, salaryProcedureInfoWrap.SalaryProcedureInfoList[index].Price);
                    }

                    //xlsAccess.SetPrintArea("A1:F12");

                    /*
                     * xlsAccess.SaveAs(ResourceMap.AppFolderPathHashtable[AppFolderPath.Outputs] as string + salaryInfo.EmployeeName + "_" + salaryInfo.DepartmentName + "_" + salaryInfo.Year + "年" + salaryInfo.Month + "月_工资单.xls");
                     */
                    return(SaveWithDialog());
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                msg = ex.Message + ex.StackTrace.ToString();
                return(false);
            }
        }