public ActionResult AddNew(CompanySalesDailyParam model)
        {
            db.CompanySalesDailyParam.Add(model);
            db.SaveChanges();

            return(RedirectToAction("Edit", "CompanySalesDailies", new { id = model.CompanySalesDailyId }));
        }
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            CompanySalesDailyParam companySalesDailyParam = await db.CompanySalesDailyParam.FindAsync(id);

            db.CompanySalesDailyParam.Remove(companySalesDailyParam);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
        public async Task <ActionResult> Edit([Bind(Include = "Id,CompanySalesDailyId,ParamName,SubParamItem,ItemAmount")] CompanySalesDailyParam companySalesDailyParam)
        {
            if (ModelState.IsValid)
            {
                db.Entry(companySalesDailyParam).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(companySalesDailyParam));
        }
        public async Task <ActionResult> Create([Bind(Include = "Id,CompanySalesDailyId,ParamName,SubParamItem,ItemAmount")] CompanySalesDailyParam companySalesDailyParam)
        {
            if (ModelState.IsValid)
            {
                db.CompanySalesDailyParam.Add(companySalesDailyParam);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(companySalesDailyParam));
        }
        public ActionResult AddNew(int dailyId, string paramName)
        {
            var model = new CompanySalesDailyParam();

            model.CompanySalesDailyId = dailyId;
            model.Id           = 0;
            model.ParamName    = paramName;
            model.SubParamItem = "其他";
            model.ItemAmount   = 0;

            return(PartialView("_PartialAddDailySalesParam", model));
        }
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CompanySalesDailyParam companySalesDailyParam = await db.CompanySalesDailyParam.FindAsync(id);

            if (companySalesDailyParam == null)
            {
                return(HttpNotFound());
            }
            return(View(companySalesDailyParam));
        }
        public List <CompanySalesDailyParam> GetDefaultDailyParamList(int dailyId, string paramName)
        {
            List <CompanySalesDailyParam> result = new List <Models.CompanySalesDailyParam>();
            var paramDicts = from p in db.ParamDict
                             where p.ParamName == paramName
                             select p;

            foreach (ParamDict paramDict in paramDicts)
            {
                CompanySalesDailyParam companyBusinessDailyParam = new CompanySalesDailyParam();
                companyBusinessDailyParam.CompanySalesDailyId = dailyId;
                companyBusinessDailyParam.Id           = 0;
                companyBusinessDailyParam.ParamName    = paramName;
                companyBusinessDailyParam.SubParamItem = paramDict.SubItemName;
                companyBusinessDailyParam.ItemAmount   = 0;

                result.Add(companyBusinessDailyParam);
            }
            return(result);
        }