예제 #1
0
        public IActionResult AddOrChangeLot(int id)
        {
            CountScore();
            currentLot = db.Lots.FirstOrDefault(l => l.Id == id);


            ChangeLot model = currentLot != null ? new ChangeLot
            {
                NameLot         = currentLot.NameLot,
                Description     = currentLot.Descrition,
                Quantity        = currentLot.Quantity,
                StartPrice      = currentLot.StartPrice,
                RedemptionPrice = currentLot.RedemptionPrice,
                DateStart       = currentLot.DateStart.ToString("yyyy-MM-ddThh:mm"),
                Id      = currentLot.Id,
                Status  = currentLot.Status,
                Picture = currentLot.Picture
            } : new ChangeLot();

            if (currentLot != null)
            {
                TimeSpan diff = currentLot.DateEnd - currentLot.DateStart;
                model.Hours = diff.Hours;
                Bid bid = GetMaxBid();
                if (bid != null)
                {
                    model.MaxBid  = bid.Sum;
                    model.HostBid = db.Users.FirstOrDefault(u => u.Id == bid.HostId).Nickname;
                }
                else
                {
                    model.MaxBid  = 0;
                    model.HostBid = "";
                }

                if (model.Picture == null)
                {
                    model.Picture = "no_image.png";
                }

                model.NameHost = db.Users.FirstOrDefault(u => u.Id == currentLot.HostId).Nickname;

                ViewBag.DateStart = currentLot.DateStart.ToString("dd.MM.yyyy hh:mm");
            }


            return(View(model));
        }
예제 #2
0
 protected void btnEnter_Click(object sender, EventArgs e)
 {
     if (ddlLabelType.SelectedValue == "模具条码")
     {
         if (CheckMould() == "fail")
         {
             return;
         }
         CRUD.setWorkFlowDDL(ddlWorkflow, "Mould");
     }
     else if (ddlLabelType.SelectedValue == "制造条码")
     {
         if (CheckProduct() == "fail")
         {
             return;
         }
         CRUD.setWorkFlowDDL(ddlWorkflow, "Film");
     }
     //显示批次流程ID
     ddlWorkflow.ClearSelection();
     ddlWorkflow.Items.FindByValue(ViewState["FlowID"].ToString()).Selected = true;
     //加载流程站点
     ChangeLot.QueryWorkSite(ddlStation, ddlWorkflow.SelectedValue);
 }
예제 #3
0
 protected void ddlWorkflow_TextChanged(object sender, EventArgs e)
 {
     ChangeLot.QueryWorkSite(ddlStation, ddlWorkflow.SelectedValue);
 }
예제 #4
0
        public async Task <IActionResult> AddOrChangeLot(ChangeLot model)
        {
            CountScore();
            if (ModelState.IsValid)
            {
                currentLot = db.Lots.FirstOrDefault(l => l.Id == model.Id);
                if (currentLot == null)
                {
                    currentLot = new Lot
                    {
                        NameLot         = model.NameLot,
                        Quantity        = model.Quantity,
                        StartPrice      = model.StartPrice,
                        RedemptionPrice = model.RedemptionPrice,
                        Descrition      = Request.Form["DescriptionLot"].ToString()
                    };

                    if (model.DateStart != null)
                    {
                        currentLot.DateStart = DateTime.Parse(model.DateStart);
                        if (currentLot.DateStart.AddMinutes(1) < DateTime.Now)
                        {
                            ModelState.AddModelError("DateStart", "Дата начала не может быть меньше текущей даты");
                            return(View(model));
                        }
                    }
                    else
                    {
                        currentLot.DateStart = DateTime.Now;
                    }

                    currentLot.DateEnd = currentLot.DateStart.AddHours(model.Hours);
                    currentLot.Picture = model.Picture;

                    User currentUser = db.Users.FirstOrDefault(u => u.Nickname == User.Identity.Name);
                    currentLot.HostId = currentUser.Id;

                    db.Lots.Add(currentLot);

                    await db.SaveChangesAsync();

                    return(RedirectToAction("Lots", "Home"));
                }
                else
                {
                    currentLot.NameLot         = model.NameLot;
                    currentLot.Descrition      = Request.Form["DescriptionLot"].ToString();
                    currentLot.Quantity        = model.Quantity;
                    currentLot.StartPrice      = model.StartPrice;
                    currentLot.RedemptionPrice = model.RedemptionPrice;
                    if (model.DateStart == null)
                    {
                        currentLot.DateStart = DateTime.Now;
                    }
                    else
                    {
                        currentLot.DateStart = DateTime.Parse(model.DateStart);
                    }
                    if (currentLot.DateStart.AddMinutes(1) < DateTime.Now)
                    {
                        ModelState.AddModelError("DateStart", "Дата начала не может быть меньше текущей даты");
                        return(View(model));
                    }

                    currentLot.DateEnd = currentLot.DateStart.AddHours(model.Hours);

                    await db.SaveChangesAsync();

                    return(RedirectToAction("Lots", "Home"));
                }
            }
            return(View(model));
        }