コード例 #1
0
ファイル: menu.aspx.cs プロジェクト: WsuCS3750/CCSInventory
    protected void btnMoveAllOut_Click(object sender, EventArgs e)
    {
        List<FoodOut> foodOut = new List<FoodOut>();
        IEnumerable<FoodIn> foodInRecords = null;

        using (CCSEntities db = new CCSEntities())
        {
            foodInRecords = db.FoodIns.Where(x => foodInIDs.Contains(x.FoodInID));

            foreach (var foodInRecord in foodInRecords)
            {
                FoodOut newFoodOut = new FoodOut();
                newFoodOut.TimeStamp = foodInRecord.TimeStamp;
                newFoodOut.FoodCategory = foodInRecord.FoodCategory;
                newFoodOut.USDACategory = foodInRecord.USDACategory;
                newFoodOut.FoodCategoryID = foodInRecord.FoodCategoryID;
           	newFoodOut.FoodSourceTypeID = foodInRecord.FoodSource.FoodSourceTypeID;
                newFoodOut.USDAID = foodInRecord.USDAID;
                newFoodOut.Weight = (double)foodInRecord.Weight;
                newFoodOut.Count = foodInRecord.Count ?? 0;
                foodOut.Add(newFoodOut);
            }
        }

        Session["foodOut"] = foodOut;
        Response.Redirect("~/outgoing-food/quickout.aspx");
    }
コード例 #2
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        using (CCSEntities db = new CCSEntities())
        {
            short Agency = 0;
            short FoodSourceType = short.Parse(ddlDonorType.SelectedValue);
            short DistributionType = short.Parse(ddlDistributionType.SelectedValue);

            if (ddlAgency.SelectedIndex != 0)
                Agency = short.Parse(ddlAgency.SelectedValue);
            foreach (var foodOut in foodOutRecords)
            {
                FoodOut newFoodOut = new FoodOut();
                newFoodOut.DistributionTypeID = DistributionType;
                newFoodOut.FoodSourceTypeID = FoodSourceType;
                newFoodOut.FoodCategoryID = foodOut.FoodCategoryID;
                newFoodOut.USDAID = foodOut.USDAID;
                newFoodOut.TimeStamp = foodOut.TimeStamp;
                newFoodOut.Count = foodOut.Count;
                newFoodOut.Weight = foodOut.Weight;
                newFoodOut.BinNumber = foodOut.BinNumber;
                newFoodOut.DateCreated = DateTime.Now;

                if(ddlAgency.SelectedIndex != 0)
                    newFoodOut.AgencyID = Agency;

                db.FoodOuts.Add(newFoodOut);
            }

            db.SaveChanges();
        }

        if (Request.QueryString["redirect"] != null)
            Response.Redirect(Request.QueryString["redirect"]);

        pnlInput.Visible = false;
        pnlSuccess.Visible = true;
    }
コード例 #3
0
ファイル: menu.aspx.cs プロジェクト: WsuCS3750/CCSInventory
    private void MoveOut(int index)
    {
        List<FoodOut> foodOut = new List<FoodOut>();
        FoodIn foodInRecord = null;

        using (CCSEntities db = new CCSEntities())
        {
            foodInRecord = db.FoodIns.Find(index);

            FoodOut newFoodOut = new FoodOut();
            newFoodOut.TimeStamp = foodInRecord.TimeStamp;
            newFoodOut.FoodCategory = foodInRecord.FoodCategory;
            newFoodOut.USDACategory = foodInRecord.USDACategory;
            newFoodOut.FoodCategoryID = foodInRecord.FoodCategoryID;
            newFoodOut.FoodSourceTypeID = foodInRecord.FoodSource.FoodSourceTypeID;
            newFoodOut.USDAID = foodInRecord.USDAID;
            newFoodOut.Weight = (double)foodInRecord.Weight;
            newFoodOut.Count = foodInRecord.Count ?? 0;
            foodOut.Add(newFoodOut);
        }
        Session["foodOut"] = foodOut;
        Response.Redirect("~/outgoing-food/quickout.aspx");
    }