Exemple #1
0
        public ActionResult Save(int id = 0)
        {
            Finance_Statistics model = null;

            if (id > 0)
            {
                model = Bll.BllFinance_Statistics.First(o => o.Id == id && o.Display != 2);
                if (model == null)
                {
                    return(LayerAlertSuccessAndRefresh("加载数据失败,未找到该数据"));
                }
            }

            return(View(model));
        }
Exemple #2
0
        public ActionResult Save(Finance_Statistics statistics)
        {
            //关键字段不能为空
            if (statistics.SaleDate == null ||
                string.IsNullOrWhiteSpace(statistics.DepartmentName))
            {
                return(LayerMsgErrorAndReturn("销售日期或部门不能为空!"));
            }

            //数据是否重复
            Finance_Statistics model = Bll.BllFinance_Statistics.First(o => o.Id != statistics.Id &&
                                                                       o.SaleDate == statistics.SaleDate &&
                                                                       o.DepartmentName == statistics.DepartmentName &&
                                                                       o.Display != 2);

            if (model != null)
            {
                return(LayerMsgErrorAndReturn("添加数据失败,该条数据已存在,请确认后重新提交!"));
            }

            if (statistics.Id < 1)
            {
                model = new Finance_Statistics();
            }
            else
            {
                model = Bll.BllFinance_Statistics.First(o => o.Id == statistics.Id && o.Display != 2) ?? new Finance_Statistics();
            }

            model.Year                      = statistics.SaleDate.GetValueOrDefault().Year;
            model.Month                     = statistics.SaleDate.GetValueOrDefault().Month;
            model.Day                       = statistics.SaleDate.GetValueOrDefault().Day;
            model.SaleDate                  = statistics.SaleDate;
            model.DepartmentName            = statistics.DepartmentName;
            model.BusinessIncome            = statistics.BusinessIncome;
            model.BudgetaryValue            = statistics.BudgetaryValue;
            model.BusinessIncomeRate        = Bll.BllFinance_Statistics.GetBusinessRate(model.BusinessIncome, model.BudgetaryValue);
            model.ActualReceipts            = statistics.ActualReceipts;
            model.ActualDeliveryOrderNumber = statistics.ActualDeliveryOrderNumber;
            model.PlanDeliveryOrderNumber   = statistics.PlanDeliveryOrderNumber;
            model.DeliveryPunctualityRate   = Bll.BllFinance_Statistics.GetBusinessRate(model.ActualDeliveryOrderNumber, model.PlanDeliveryOrderNumber);

            model.LastDate   = DateTime.Now;
            model.LastUserId = MyInfo.Id;

            bool isok = false;

            //没有ID就新增,反之修改
            if (model.Id < 1)
            {
                model.AddDate   = model.LastDate;
                model.AddUserId = model.LastUserId;
                model.Display   = 1;

                isok = Bll.BllFinance_Statistics.Insert(model) > 0;
            }
            else
            {
                isok = Bll.BllFinance_Statistics.Update(model) > 0;
            }

            return(LayerMsgSuccessAndRefresh("保存" + (isok ? "成功" : "失败")));
        }