public ActionResult TProjects_Update([DataSourceRequest] DataSourceRequest request, TProjectViewModel vm)
        {
            if (vm != null && ModelState.IsValid)
            {
                var entity = _tasks.One(vm.ProjectId);
                if (entity != null)
                {
                    ConvertToTProject(vm, entity);

                    entity.ModifiedDate = DateTime.Now;
                    entity.ModifiedBy   = User.Identity.Name;
                    entity.DataStatus   = EnumDataStatus.Updated.ToString();

                    _tasks.Update(entity);
                }
            }

            return(Json(ModelState.ToDataSourceResult()));
        }
Beispiel #2
0
        private void ConvertToTBap(TBapViewModel vm, TBap entity, string ParentProjectId)
        {
            entity.ProjectId = string.IsNullOrEmpty(ParentProjectId) ? null : _TProjectTasks.One(ParentProjectId);
            entity.WorkId    = string.IsNullOrEmpty(vm.WorkId) ? null : _TWorkTasks.One(vm.WorkId);

            entity.BapPeriod = new DateTime(vm.BapPeriod.Value.Year, vm.BapPeriod.Value.Month, 1);
            entity.BapQty    = vm.BapQty;
            entity.BapTotal  = vm.BapQty * vm.WorkPrice;
            entity.BapStatus = vm.BapStatus;
            entity.BapDesc   = vm.BapDesc;
        }
        private void ConvertToTProjectCost(TProjectCostViewModel vm, TProjectCost entity)
        {
            entity.CostId    = string.IsNullOrEmpty(vm.CostId) ? null : _MCostTasks.One(vm.CostId);
            entity.EquipId   = string.IsNullOrEmpty(vm.EquipId) ? null : _MEquipTasks.One(vm.EquipId);
            entity.ProjectId = string.IsNullOrEmpty(vm.ProjectId) ? null : _TProjectTasks.One(vm.ProjectId);

            entity.ProjectCostDate  = vm.ProjectCostDate;
            entity.ProjectCostQty   = vm.ProjectCostQty;
            entity.ProjectCostTotal = vm.ProjectCostQty * vm.ProjectCostPrice;
            entity.ProjectCostDesc  = vm.ProjectCostDesc;
            entity.ProjectCostPrice = vm.ProjectCostPrice;
        }
        private void ConvertToTInvoice(TInvoiceViewModel vm, TInvoice entity, string ParentProjectId)
        {
            entity.ProjectId = string.IsNullOrEmpty(ParentProjectId) ? null : _TProjectTasks.One(ParentProjectId);

            entity.InvoicePeriod     = new DateTime(vm.InvoicePeriod.Value.Year, vm.InvoicePeriod.Value.Month, 1);
            entity.InvoiceStartDate  = vm.InvoiceStartDate;
            entity.InvoiceEndDate    = vm.InvoiceEndDate;
            entity.InvoiceNo         = vm.InvoiceNo;
            entity.InvoiceDate       = vm.InvoiceDate;
            entity.InvoiceLastStatus = vm.InvoiceLastStatus;
            entity.InvoicePaidDate   = vm.InvoicePaidDate;
            //entity.InvoiceValue = vm.InvoiceValue;
            //entity.InvoiceRetention = vm.InvoiceRetention;
            //entity.InvoicePpn = vm.InvoicePpn;
            //entity.InvoiceTotal = vm.InvoiceTotal;
        }
        private void ConvertToTSalary(TSalaryViewModel vm, TSalary entity)
        {
            MEmployee emp = string.IsNullOrEmpty(vm.EmployeeId) ? null : _MEmployeeTasks.One(vm.EmployeeId);

            entity.EmployeeId = emp;
            entity.ProjectId  = string.IsNullOrEmpty(vm.ProjectId) ? null : _TProjectTasks.One(vm.ProjectId);

            entity.SalaryPeriod = new DateTime(vm.SalaryPeriod.Value.Year, vm.SalaryPeriod.Value.Month, 1);

            if (emp != null)
            {
                entity.SalaryGapok     = emp.EmployeeBasicSalary;
                entity.SalaryWorkQty   = _absenDetTasks.GetTotalQtyByEmp(emp.Id, entity.SalaryPeriod);
                entity.SalaryWorkTotal = emp.EmployeeDailyAllowance * entity.SalaryWorkQty;
                entity.SalaryTotal     = entity.SalaryGapok + entity.SalaryWorkTotal;
            }
            //entity.SalaryStatus = vm.SalaryStatus;
            //entity.SalaryDesc = vm.SalaryDesc;
        }