public ActionResult Delete(String email, FormCollection collection)
        {
            System.Diagnostics.Debug.WriteLine("******* email ********");
            System.Diagnostics.Debug.WriteLine(email);

            DemandViewModel d = new DemandViewModel();



            d.email = email;

            HttpClient client = new HttpClient();

            client.BaseAddress = new Uri("http://localhost:18080/");

            HttpResponseMessage response = client.PostAsJsonAsync <DemandViewModel>("JAVAEE-web/rest/admin/deletedemande", d).Result;

            if (response.IsSuccessStatusCode)
            {
                //  client.PostAsJsonAsync<demande>("JAVAEE-web/rest/admin/deletedemande", d);
                // .ContinueWith((postTask) => postTask.Result.EnsureSuccessStatusCode());

                return(RedirectToAction("allDemands"));
            }
            else
            {
                ViewBag.result = "Demand does not exist";
            }
            return(View());
        }
        public ActionResult CreateDemand(FormCollection collection)
        {
            DemandViewModel d = new DemandViewModel();

            d.email      = collection["email"];
            d.firstName  = collection["firstName"];
            d.lastName   = collection["lastName"];
            d.speciality = collection["speciality"];
            d.state      = collection["state"];

            HttpClient client = new HttpClient();

            client.BaseAddress = new Uri("http://localhost:18080/");

            HttpResponseMessage response = client.PostAsJsonAsync <DemandViewModel>("JAVAEE-web/rest/admin/adddemande", d).Result;

            if (response.IsSuccessStatusCode)
            {
                ViewBag.succ = "Demand succesfully created";
            }
            else
            {
                ViewBag.fail = "Demand already exist";
            }



            return(View());
        }
Beispiel #3
0
        public ActionResult Edit(DemandViewModel demandViewModel)

        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(RedirectToAction("Index"));
                }

                var tblDemand = _dbContext.tbl_Demand.Find(demandViewModel.DemandId);

                if (tblDemand != null)
                {
                    tblDemand.itemId     = demandViewModel.ItemId;
                    tblDemand.supplierId = demandViewModel.SupplierId;
                    tblDemand.unitId     = demandViewModel.UnitId;
                    tblDemand.demandQty  = demandViewModel.DemandQty;
                    tblDemand.demandNo   = Session.GetDataFromSession <int>(DemandViewModel.DemandKey);

                    _dbContext.Entry(tblDemand).State = EntityState.Modified;
                    _dbContext.SaveChanges();

                    Success($"<b>{tblDemand.tbl_ItemMaster.name} </b> Item was successfully update to the database.", true);
                }
            }
            catch (Exception ex)
            {
                ErrorMessage();
            }

            return(RedirectToAction("Index"));
        }
Beispiel #4
0
 public ActionResult New(DemandViewModel demandViewModel)
 {
     Session.RemoveAllFromSession();
     _loadViewBags();
     Warning("New demand created", true);
     return(RedirectToAction("Index"));
 }
Beispiel #5
0
        public ActionResult Save(DemandViewModel demandViewModel)

        {
            try
            {
                var tempTblDemand = new tbl_Demand
                {
                    itemId     = demandViewModel.ItemId,
                    supplierId = demandViewModel.SupplierId,
                    unitId     = demandViewModel.UnitId,
                    demandQty  = demandViewModel.DemandQty,
                    demandNo   = Session.GetDataFromSession <int>(DemandViewModel.DemandKey)
                };

                if (!ModelState.IsValid)
                {
                    return(RedirectToAction("Index"));
                }


                _dbContext.tbl_Demand.Add(tempTblDemand);
                _dbContext.SaveChanges();

                Success($"<b>{demandViewModel.Item} </b> Item was successfully added to the database.", true);
            }
            catch (Exception ex)
            {
                ErrorMessage();
            }

            return(RedirectToAction("Index"));
        }
        public ActionResult Delete(String email)
        {
            System.Diagnostics.Debug.WriteLine("******* email ********");
            System.Diagnostics.Debug.WriteLine(email);

            DemandViewModel d = new DemandViewModel();

            d.email = email;


            string     str;
            HttpClient client = new HttpClient();

            client.BaseAddress = new Uri("http://localhost:18080/");
            HttpResponseMessage response = client.PostAsJsonAsync <DemandViewModel>("JAVAEE-web/rest/admin/getonedemand", d).Result;

            if (response.IsSuccessStatusCode)
            {
                str = response.Content.ReadAsStringAsync().Result;
                var result = JsonConvert.DeserializeObject <DemandViewModel>(str);
                ViewBag.email      = result.email;
                ViewBag.firstName  = result.firstName;
                ViewBag.lastName   = result.lastName;
                ViewBag.speciality = result.speciality;
                ViewBag.state      = result.state;
            }
            else
            {
                ViewBag.result = "Not found !";
            }

            return(View());
        }
Beispiel #7
0
        public ActionResult Demand(string sortOrder, string Search, string DateSearch, int Page = 0)
        {
            DemandViewModel Data = new DemandViewModel();

            //將傳入值Search(搜尋)放入頁面模型中
            if (!String.IsNullOrEmpty(DateSearch))
            {
                Data.DateSearch = DateSearch;
            }
            else
            {
                Data.DateSearch = DateSearch;
            }
            Data.Search    = Search;
            Data.sortOrder = sortOrder;
            //新增頁面模型中的分頁
            if (Page == 0)
            {
                Data.Paging = new ForPaging();
            }
            else
            {
                Data.Paging = new ForPaging(Page);
            }
            Data.DataList = GetDataList(Data.Paging, Data.Search, Data.DateSearch, sortOrder);
            //將頁面資料傳入View中
            ViewData["InvoiceDetail"] = db.InvoiceDetail.ToList();
            return(View(Data));
        }
        public async Task <IActionResult> Post([FromBody] DemandViewModel editModel)
        {
            var demand = _mapper.Map <Demand>(editModel);
            var dt     = DateTime.Now;

            demand.BillCode = dt.ToString("yyMMddHHmmss");
            demand.MakeDate = dt;
            demand.Maker    = this.aspNetUser.Name;

            int r = await _demandService.AddAsync(demand);

            return(ApiResult(r > 0? "提交成功!" : "提交失败!"));
        }
        private List <DemandViewModel> CreateDemandViewModels(IEnumerable <Demand> demands)
        {
            List <DemandViewModel> demandViewModels = new List <DemandViewModel>();

            foreach (var demand in demands)
            {
                DemandViewModel demandViewModel = new DemandViewModel();
                demandViewModel.Id           = demand.Id;
                demandViewModel.DemandCode   = demand.DemandCode;
                demandViewModel.DemandType   = demand.DemandType.ToString();
                demandViewModel.DemandDetail = demand.DemandDetail;
                demandViewModel.User         = demand.User.UserName;
                demandViewModel.Customer     = demand.Customer.Name;
                demandViewModel.CreateTime   = demand.CreateTime;
                demandViewModel.DemandPhase  = demand.DemandPhase.ToString();
                var alignRecords       = demand.OperationRecords.Where(item => item.OperationType == OperationType.需求对齐).OrderBy(item => item.DateTime);
                var alignRecordsString = "";
                foreach (var record in alignRecords)
                {
                    alignRecordsString = alignRecordsString + record.DateTime + record.RecordDetail + "\n";
                }
                alignRecordsString.TrimEnd('\n');
                demandViewModel.AlignRecords = alignRecordsString;
                var analyseRecords       = demand.OperationRecords.Where(item => item.OperationType == OperationType.需求分析).OrderBy(item => item.DateTime);
                var analyseRecordsString = "";
                foreach (var record in analyseRecords)
                {
                    analyseRecordsString = analyseRecordsString + record.DateTime + record.RecordDetail + "\n";
                }
                analyseRecordsString.TrimEnd('\n');
                demandViewModel.AnalyseRecords  = analyseRecordsString;
                demandViewModel.SoftwareVersion = demand.SoftwareVersion == null ? "" : demand.SoftwareVersion.VersionName;
                if (demand.SoftwareVersion == null)
                {
                    demandViewModel.ReleaseDate = "";
                }
                else if (demand.SoftwareVersion.VersionProgress == VersionProgress.已发布)
                {
                    demandViewModel.ReleaseDate = demand.SoftwareVersion.ReleaseDate?.ToString("yyyy-MM-dd");
                }
                else
                {
                    demandViewModel.ReleaseDate = "(预计)" + demand.SoftwareVersion.ExpectedReleaseDate.ToString("yyyy-MM-dd");
                }
                demandViewModel.Remarks = demand.Remarks;
                demandViewModels.Add(demandViewModel);
            }

            return(demandViewModels);
        }
        public async Task <ActionResult> RegisterDemands(Guid?Id)
        {
            try
            {
                Section section = await Db.Sections.Where(x => x.Id == Id).FirstOrDefaultAsync <Section>();

                if (section == null)
                {
                    throw new Exception();
                }

                if (section.IsActivedSimulation == false && section.Periods.Count() > 0)
                {
                    Flash.Error("El Modelo de gestión ha finalizado");
                    return(RedirectToAction("Index"));
                }

                if (section.IsActivedSimulation == false)
                {
                    Flash.Error("Error", "No ha sido activada la simulación");
                    return(RedirectToAction("Index"));
                }

                var       caseStudyQuery = Db.CaseStudies.Where(x => x.Id == section.CaseStudyId);
                CaseStudy caseStudy      = await caseStudyQuery.FirstOrDefaultAsync();

                DemandViewModel sellViewModel = new DemandViewModel
                {
                    ProductDemands = caseStudy.InitialCharges.Select(y => new ProductDemand {
                        Product = y.Product
                    }).OrderBy(t => t.Product.Number).ToList <ProductDemand>(),
                    Section   = section,
                    SectionId = section.Id,
                };
                return(View(sellViewModel));
            }
            catch
            {
                Flash.Error("Error", "Ha ocurrido un error inesperado");
                return(RedirectToAction("Index"));
            }
        }
Beispiel #11
0
        private DemandViewModel FillControlsFromDatabase(int?id)
        {
            var demandViewModel = new DemandViewModel
            {
                DemandNo = Session.GetDataFromSession <int>(DemandViewModel.DemandKey)
            };

            var tblDemand = _dbContext.tbl_Demand.Find(id);

            if (tblDemand == null)
            {
                return(demandViewModel);
            }


            demandViewModel.DemandNo   = Session.GetDataFromSession <int>(DemandViewModel.DemandKey);
            demandViewModel.DemandId   = tblDemand.id;
            demandViewModel.UnitId     = tblDemand.unitId;
            demandViewModel.SupplierId = tblDemand.supplierId;
            demandViewModel.ItemId     = tblDemand.itemId;
            demandViewModel.DemandQty  = tblDemand.demandQty;

            return(demandViewModel);
        }
        public async Task <ActionResult> RegisterDemands(DemandViewModel model)
        {
            if (ModelState.IsValid)
            {
                Section section = await Db.Sections.Where(x => x.Id == model.SectionId).FirstOrDefaultAsync();

                if (section == null)
                {
                    return(HttpNotFound());
                }
                if (section.IsActivedSimulation == false)
                {
                    Flash.Error("El Modelo de gestión ha finalizado");
                    return(RedirectToAction("Index"));
                }
                Period newPeriod = new Period
                {
                    Created      = DateTime.Now,
                    Id           = Guid.NewGuid(),
                    IsLastPeriod = section.CaseStudy.Periods == section.Periods.Count() ? true : false,
                };
                if (newPeriod.IsLastPeriod)
                {
                    section.IsActivedSimulation = false;
                }
                section.Periods.Add(newPeriod);
                Period period = section.Periods.OrderByDescending(x => x.Created).FirstOrDefault();
                period.Demands = new List <Demand>();
                foreach (var productSell in model.ProductDemands)
                {
                    if (TryValidateModel(productSell))
                    {
                        Demand sale = new Demand
                        {
                            Product  = await Db.Products.Where(x => x.Id == productSell.Product.Id).FirstOrDefaultAsync(),
                            Quantity = productSell.Quantity
                        };
                        period.Demands.Add(sale);
                    }
                    else
                    {
                        Flash.Error("Error", "Ha Ocurrido un error inesperado");
                        return(RedirectToAction("Index"));
                    }
                }
                await Db.SaveChangesAsync();

                //llamada a la simulación
                SimulationBL simulation = new SimulationBL();
                simulation.Simulation(await Db.Sections.Where(x => x.Id == section.Id).FirstOrDefaultAsync());
                //Fin de llamada a la simulación

                await Db.SaveChangesAsync();

                Flash.Success("Ok", "Las ventas del período han sido registradas exitosamente");
                return(RedirectToAction("Index"));
            }
            else
            {
                Flash.Error("Error", "Ha Ocurrido un error registrando las ventas");
                return(RedirectToAction("Index"));
            }
        }
        public ActionResult DemandView(int ID)
        {
            DemandViewModel dv = new DemandViewModel(ID);

            return(PartialView("_DemandView", dv));
        }