Beispiel #1
0
        public bool AddNewFile(int pID, WSFileItem fi, int uID)
        {
            WorkSummary nf = new WorkSummary();

            nf.File_NewName    = fi.fileNamePresent;
            nf.File_OldName    = fi.fileName;
            nf.File_UploadTime = Convert.ToDateTime(fi.updateTime);
            nf.File_Submiter   = (new Person_Infos()).GetPerson_info(uID);
            nf.File_SavePath   = fi.path;
            nf.File_ExtType    = fi.ext;
            return((new WorkSummaryCatalog()).AddFiletoCatalog(pID, nf));
        }
        /// <summary>
        /// 生成工作安排表。
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void mCalendar_DateChanged(object sender, DateRangeEventArgs e)
        {
            YearAndMonthStr = e.Start.ToString("yyyy-MM");
            WorkSummary WS = new WorkSummary(YearAndMonthStr);

            V_Work_Schedule._YearAndMonthStr = YearAndMonthStr;
            //先生成工作计划安排
            int affectedCount = WS.generateARSummary();

            //获取相应的工作安排记录
            System.Data.DataTable dt = WS.getARSummary();
            this.dgv.DataSource = dt;
            DGVHelper.AutoSizeForDGV(dgv);
        }
Beispiel #3
0
 public bool AddFiletoCatalog(int pID, WorkSummary nf)
 {
     try
     {
         using (var db = base.NewDB())
         {
             db.WCatalogs.Where(s => s.Catalog_Id == pID).First().Files_Included.Add(nf);
             db.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnGenerateWorkSchedule_Click(object sender, EventArgs e)
        {
            //获取MonthCalendar的值
            //依据Work Summary 生成一张工作安排表
            V_Work_Schedule v_W_S = new V_Work_Schedule();

            V_Work_Schedule._YearAndMonthStr = this.YearAndMonthStr;
            if (!WorkSummary.ifExistsWorkSummary(this.YearAndMonthStr))
            {
                ShowResult.show(lblResult, "请先导入5月份考勤记录!", false);
                timerRestoreTheLblResult.Enabled = true;
                return;
            }
            //生成工作表。
            v_W_S.GenWorkSchedule();
            MSG msg = v_W_S.genExcel(out xlsFilePath);

            ShowResult.show(lblResult, msg.Msg, msg.Flag);
            this.timerRestoreTheLblResult.Enabled = true;
        }
        public BillingModel GetMTSBilling(string fromDate, string toDate, string userName, string location)
        {
            BillingModel billingModel = new BillingModel();

            List <Task> tasks = null;

            if (!string.IsNullOrEmpty(fromDate) && string.IsNullOrEmpty(toDate))
            {
                DateTime from = Convert.ToDateTime(fromDate);

                if (userName == null)
                {
                    if (location == null)
                    {
                        tasks = this.db.Tasks.Include("Project").Include("Employee").Include("WorkCodesActivity").Where(x => x.ExecutionDate == from).ToList();
                    }
                    else
                    {
                        tasks = this.db.Tasks.Include("Project").Include("Employee").Include("WorkCodesActivity").Where(x => x.ExecutionDate == from && x.Employee.Location.Name.Equals(location)).ToList();
                    }
                }
                else
                {
                    if (location == null)
                    {
                        tasks = this.db.Tasks.Include("Project").Include("Employee").Include("Login").Include("WorkCodesActivity").Where(x => x.ExecutionDate == from && x.Employee.Logins.FirstOrDefault().UserId.Equals(userName)).ToList();
                    }
                    else
                    {
                        tasks = this.db.Tasks.Include("Project").Include("Employee").Include("Login").Include("WorkCodesActivity").Where(x => x.ExecutionDate == from && x.Employee.Logins.FirstOrDefault().UserId.Equals(userName) && x.Employee.Location.Name.Equals(location)).ToList();
                    }
                }
            }
            else
            {
                DateTime from = Convert.ToDateTime(fromDate);
                DateTime to   = Convert.ToDateTime(toDate);

                if (userName == null)
                {
                    if (location == null)
                    {
                        tasks = this.db.Tasks.Include("Project").Include("Employee").Include("WorkCodesActivity").Where(x => x.ExecutionDate >= from && x.ExecutionDate <= to).OrderBy(x => x.ExecutionDate).ToList();
                    }
                    else
                    {
                        tasks = this.db.Tasks.Include("Project").Include("Employee").Include("WorkCodesActivity").Where(x => x.ExecutionDate >= from && x.ExecutionDate <= to && x.Employee.Location.Name.Equals(location)).OrderBy(x => x.ExecutionDate).ToList();
                    }
                }
                else
                {
                    if (location == null)
                    {
                        tasks = this.db.Tasks.Include("Project").Include("Employee").Include("WorkCodesActivity").Where(x => x.ExecutionDate >= from && x.ExecutionDate <= to && x.Employee.Logins.FirstOrDefault().UserId.Equals(userName)).OrderBy(x => x.ExecutionDate).ToList();
                    }
                    else
                    {
                        tasks = this.db.Tasks.Include("Project").Include("Employee").Include("WorkCodesActivity").Where(x => x.ExecutionDate >= from && x.ExecutionDate <= to && x.Employee.Logins.FirstOrDefault().UserId.Equals(userName) && x.Employee.Location.Name.Equals(location)).OrderBy(x => x.ExecutionDate).ToList();
                    }
                }
            }

            tasks.ForEach(x =>
            {
                WorkSummary workSummary = billingModel.Summary.Where(y => y.WorkCode.Equals(x.WorkCodesActivity.Name) && y.Employee.Equals(x.Employee.LastName + ", " + x.Employee.FirstName)).FirstOrDefault();

                if (workSummary == null)
                {
                    workSummary                = new WorkSummary();
                    workSummary.WorkCode       = x.WorkCodesActivity.Name;
                    workSummary.Employee       = x.Employee.LastName + ", " + x.Employee.FirstName;
                    workSummary.BillRate       = (x.Employee.BillRate.HasValue ? x.Employee.BillRate.Value : 0);
                    workSummary.Company        = x.Employee.CompanyName;
                    workSummary.Hours          = x.Hours.Value;
                    workSummary.Total          = x.Charge.Value;
                    workSummary.Costperhour    = (x.Employee.Cost.HasValue ? x.Employee.Cost.Value : 0);
                    workSummary.TotalCost      = (x.Employee.Cost.HasValue ? x.Employee.Cost.Value * x.Hours.Value : 0);
                    workSummary.BillableAmount = (x.Employee.BillRate.HasValue ? x.Employee.BillRate.Value * x.Hours.Value : 0);
                    workSummary.PayableAmount  = (x.Employee.Cost.HasValue ? x.Employee.Cost.Value * x.Hours.Value : 0);
                    workSummary.Margin         = workSummary.BillableAmount - workSummary.PayableAmount;
                    //(x.Employee.BillRate.HasValue ? x.Employee.BillRate.Value * x.Hours : 0) - (x.Employee.Cost.HasValue ? x.Employee.Cost.Value * x.Hours : 0);

                    billingModel.Summary.Add(workSummary);
                }
                else
                {
                    //decimal MarginSub;
                    //MarginSub = workSummary.BillableAmount - workSummary.PayableAmount;
                    //workSummary.Margin += MarginSub;
                    //-workSummary.BillableAmount - workSummary.PayableAmount;
                    workSummary.TotalCost      += (x.Employee.Cost.HasValue ? x.Employee.Cost.Value * x.Hours.Value : 0);
                    workSummary.PayableAmount  += (x.Employee.Cost.HasValue ? x.Employee.Cost.Value * x.Hours.Value : 0);
                    workSummary.BillableAmount += (x.Employee.BillRate.HasValue ? x.Employee.BillRate.Value * x.Hours.Value : 0);
                    workSummary.Margin          = workSummary.BillableAmount - workSummary.PayableAmount;
                    workSummary.Hours          += x.Hours.Value;
                    workSummary.Total          += x.Charge.Value;
                }
            });

            billingModel.Summary = billingModel.Summary.OrderBy(x => x.Company).OrderBy(x => x.Employee).ToList();

            return(billingModel);
        }