コード例 #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
ファイル: scan.aspx.cs プロジェクト: WsuCS3750/CCSInventory
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        Container container=null;
        try
        {

            short binNumber = 0;

            if(short.TryParse(txtValue.Text, out binNumber))
            {

                using (CCSEntities db = new CCSEntities())
                {
                    container = (from c in db.Containers
                                 where c.BinNumber == binNumber
                                 select c).FirstOrDefault();
                }

                if (container != null)
                {
                    Response.Redirect("menu.aspx?id=" + container.BinNumber);
                }
            }
            else
            {
                lblError.Text = "Invalid Bin Number!";
            }
        }
        catch (System.Threading.ThreadAbortException) { }
        catch (Exception ex)
        {
            LogError.logError(ex);
            Response.Redirect("../errorpages/error.aspx");
        }
    }
コード例 #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        using (CCSEntities db = new CCSEntities())
        {
            List<Container> lstContainers = (from c in db.Containers where c.Weight !=0 select c).ToList();

            DataTable dt = new DataTable();
            dt.Columns.Add("ID");
            dt.Columns.Add("Type");
            dt.Columns.Add("Date");
            dt.Columns.Add("img");

            for (int i = 0; i < lstContainers.Count; i++)
            {
                dt.Rows.Add(
                    lstContainers.ElementAt(i).BinNumber,
                    (bool)lstContainers.ElementAt(i).isUSDA ?
                        lstContainers.ElementAt(i).USDACategory.Description : lstContainers.ElementAt(i).FoodCategory.CategoryType,
                    DateTime.Today.ToString("d"),
                    "barcode.ashx?data=" + lstContainers.ElementAt(i).BinNumber
                );
            }

            rptLabels.DataSource = dt;
            rptLabels.DataBind();
        }
    }
コード例 #4
0
    /// <summary>
    /// Loads any of the previously chosen options with the template into the interface
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (!Page.IsPostBack)
            {
                if (Session["reportTemplateRow"] == null || Session["reportTemplate"] == null)
                    Response.Redirect(Config.DOMAIN() + "desktop/reports");

                OutgoingReportTemplate template = (OutgoingReportTemplate)Session["reportTemplate"];

                using (CCSEntities db = new CCSEntities())
                {
                    lstAgencies.SelectedType = template.AgenciesSelection;
                    lstAgencies.AvailableList = (from f in db.Agencies
                                                    select new { ID = f.AgencyID, Display = f.AgencyName }).ToList();

                    lstAgencies.SelectedIDs = template.Agencies;
                }

            }
        }
        catch (System.Threading.ThreadAbortException) { }
        catch (Exception ex)
        {
            LogError.logError(ex);
            Response.Redirect("~/errorpages/error.aspx");
        }
    }
コード例 #5
0
    /// <summary>
    /// Loads any of the previously chosen options with the template into the interface
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (!Page.IsPostBack)
            {
                if (Session["reportTemplateRow"] == null || Session["reportTemplate"] == null)
                    Response.Redirect(Config.DOMAIN() + "desktop/reports");

                IFoodUSDACategeories template = (IFoodUSDACategeories)Session["reportTemplate"];

                using (CCSEntities db = new CCSEntities())
                {
                    lstRegularFood.SelectedType = template.CategoriesSelection;
                    lstUSDA.SelectedType = template.USDASelection;

                    lstRegularFood.AvailableList = (from f in db.FoodCategories
                                                    select new { ID = f.FoodCategoryID, Display =  f.CategoryType }).ToList();
                    lstUSDA.AvailableList = (from u in db.USDACategories
                                             select new { ID = u.USDAID, Display = "(" + u.USDANumber + ") " + u.Description }).ToList();

                    lstUSDA.SelectedIDs = template.USDACategories;
                    lstRegularFood.SelectedIDs = template.FoodCategories;
                }

            }
        }
        catch (System.Threading.ThreadAbortException) { }
        catch (Exception ex)
        {
            LogError.logError(ex);
            Response.Redirect("~/errorpages/error.aspx");
        }
    }
コード例 #6
0
ファイル: view.aspx.cs プロジェクト: WsuCS3750/CCSInventory
 private void bindGridView()
 {
     try
     {
         if (short.TryParse(Request.QueryString["id"], out id))
         {
             List<Adjustment> lstAdjustment;
             using (CCSEntities db = new CCSEntities())
             {
                 lstAdjustment = db.Adjustments.Where(x => x.AuditID == id).ToList();
             }
             if (lstAdjustment.Count > 0)
             {
                 gvAdjustments.DataSource = lstAdjustment;
                 gvAdjustments.DataBind();
             }
             else
                 lblNoAdjustments.Visible = true;
         }
         else
             Response.Redirect("default.aspx");
     }
     catch (System.Threading.ThreadAbortException) { }
     catch (Exception ex)
     {
         LogError.logError(ex);
         Response.Redirect("../errorpages/error.aspx");
     }
 }
コード例 #7
0
ファイル: add.aspx.cs プロジェクト: WsuCS3750/CCSInventory
    protected void btnSave_Click(object sender, EventArgs e)
    {
        try
        {
            lblMessage.Text = "";

            if (txtDistributionType.Text.Length == 0)                       // if distribution type isn't empty
                lblMessage.Text = "The distribution type can't be blank";
            else if (txtDistributionType.Text.Length > 30)                  // if distribution isn't too long
                lblMessage.Text = "The distribution type can't be longer than 30 characters in length";
            else if (isDistributionTypeExisting(txtDistributionType.Text))  // if distribution type doesn't already exist
                lblMessage.Text = "A distribution type of that name already exists";
            else
            {
                DistributionType dt = new DistributionType();
                dt.DistributionType1 = txtDistributionType.Text;

                using (CCSEntities db = new CCSEntities())
                {
                    db.DistributionTypes.Add(dt);
                    db.SaveChanges();
                }
                LogChange.logChange("Added Distribution Type " + txtDistributionType.Text, DateTime.Now, short.Parse(Session["userID"].ToString()));
                Response.Redirect("default.aspx");
            }
        }
        catch (System.Threading.ThreadAbortException) { }
        catch (Exception ex)
        {
            LogError.logError(ex);
            Response.Redirect("../errorpages/error.aspx");
        }
    }
コード例 #8
0
ファイル: LogError.cs プロジェクト: WsuCS3750/CCSInventory
    /// bulk of code written by: Alex Marcum - 11/20/2012
    public static void logError(Exception ex)
    {
        System.Diagnostics.StackFrame stackFrame = new System.Diagnostics.StackFrame(1, true);

        //System.IO.FileInfo temp = new System.IO.FileInfo(fileName);
        //fileName = temp.Name;

        //Class Name is the Whole path to the Filename
        string fileName = stackFrame.GetFileName();
        string functionName = stackFrame.GetMethod().Name.ToString();
        int line = stackFrame.GetFileLineNumber();

        try
        {
            using (CCSEntities db = new CCSEntities())
            {
                ErrorLog el = new ErrorLog();

                el.TimeStamp = DateTime.Now;
                el.FileName = fileName;
                el.FunctionName = functionName;
                el.LineNumber = line.ToString();
                el.ErrorText = ex.Message;

                db.ErrorLogs.Add(el);
                db.SaveChanges();
            }
        }
        catch (Exception /*ex*/)
        {
        }
    }
コード例 #9
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            container = (Container)Session["Container"];

            if (container == null)
            {
                Response.Redirect("default.aspx");
            }

            lblID.Text = container.BinNumber.ToString();
            //lblID.Text = container.ContainerID.ToString();
            lblWeight.Text = container.Weight.ToString();

            using (CCSEntities db = new CCSEntities())
            {
                lblLocation.Text = (from l in db.Locations
                                    where l.LocationID == container.LocationID
                                    select l).First().RoomName;

                lblType.Text = (from t in db.FoodCategories
                                where t.FoodCategoryID == container.FoodCategoryID
                                select t).First().CategoryType;

            }
        }
        catch (Exception ex)
        {
            LogError.logError(ex);
            Response.Redirect("../errorpages/error.aspx");
        }
    }
コード例 #10
0
ファイル: edit.aspx.cs プロジェクト: WsuCS3750/CCSInventory
    private void loadLocation()
    {
        lblMessage.Text = "";

        if (Request.QueryString["id"] != null)
            id = int.Parse(Request.QueryString["id"]);
        else
            Response.Redirect("default.aspx");

        try
        {
            using (CCSEntities db = new CCSEntities())
            {
                var location = (from l in db.Locations
                      where l.LocationID == id
                      select l).FirstOrDefault();

                if (location != null)
                {
                    txtLocation.Text = location.RoomName;
                    txtLocationId.Text = location.LocationID.ToString();
                }
                else
                    lblMessage.Text = "The specified location was not found.";
            }

        }
        catch (Exception ex)
        {
            LogError.logError(ex);
            Response.Redirect("../errorpages/error.aspx");
        }
    }
コード例 #11
0
ファイル: edit.aspx.cs プロジェクト: WsuCS3750/CCSInventory
    private void removeLocation()
    {
        try
        {
            lblMessage.Text = "";

            using (CCSEntities db = new CCSEntities())
            {
                // ensure that the record is selected
                var location = (from l in db.Locations
                      where l.LocationID == id
                      select l).FirstOrDefault();

                if (location != null)
                {
                    db.Locations.Remove(location);   // remove specified record
                    db.SaveChanges();               // commit changes

                    Response.Redirect("default.aspx");
                }
                else
                    lblMessage.Text = "An unexpected problem occurred: Please try again later.";
            }
        }
        catch (Exception ex)
        {
            LogError.logError(ex);
            Response.Redirect("../errorpages/error.aspx");
        }
    }
コード例 #12
0
    private void addLocation()
    {
        try
        {
            lblMessage.Text = "";

            using (CCSEntities db = new CCSEntities())
            {
                Location newLocation = new Location(); // create a new food category with the specified name

                if (txtAddLocation.Text != "")
                {
                    newLocation.RoomName = txtAddLocation.Text;

                    db.Locations.Add(newLocation); // add the new food category record
                    db.SaveChanges();
                }
                else
                    lblMessage.Text = "You must specify a location";
            }
        }

        catch (Exception ex)
        {
            LogError.logError(ex);
            Response.Redirect("../errorpages/error.aspx");
        }
    }
コード例 #13
0
ファイル: edit.aspx.cs プロジェクト: WsuCS3750/CCSInventory
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            if (Request.QueryString["id"] != null)
            {
                id = int.Parse(Request.QueryString["id"]);
                using (CCSEntities db = new CCSEntities())
                {

                    ddlState.DataSource = db.States.ToList();
                    ddlState.DataBind();

                    a = (from ag in db.Agencies where ag.AgencyID == id select ag).First();

                    if(a != null){
                        txtAgencyName.Text = a.AgencyName;
                        txtStreet1.Text = a.Address.StreetAddress1;
                        txtStreet2.Text = a.Address.StreetAddress2;
                        txtCity.Text = a.Address.City.CityName;
                        txtZip.Text = a.Address.Zipcode.ZipCode1;
                        ddlState.SelectedIndex = (int)a.Address.StateID;
                    }
                }
            }
        }
    }
コード例 #14
0
ファイル: edit.aspx.cs プロジェクト: WsuCS3750/CCSInventory
    // check if a category with the same name already exists
    private Boolean isFoodCategoryPresent(String fcName)
    {
        Boolean result = true;
        FoodCategory fc;
        try
        {
            lblMessage.Text = "";

            using (CCSEntities db = new CCSEntities())
            {
                fc = (from category in db.FoodCategories
                      where category.CategoryType.Equals(fcName)
                      select category).FirstOrDefault();
            }

            if (fc == null)
                result = false;
            else if (fc.FoodCategoryID == int.Parse(lblID.Text))
                result = false;
        }
        catch (System.Threading.ThreadAbortException) { }
        catch (Exception ex)
        {
            LogError.logError(ex);
            Response.Redirect("../errorpages/error.aspx");
        }

        return result;
    }
コード例 #15
0
    // @author: Anthony Dietrich - Save Food Out Edit Data
    // Saves Edit Data from the Food Out version of the editfood page.
    protected void btnEditFoodOutSave_Click(object sender, EventArgs e)
    {
        try
        {
            using (CCSEntities db = new CCSEntities())
            {

                short shFoodOutID = short.Parse(Session["editWhat"].ToString());

                FoodOut editFoodOut = (from c in db.FoodOuts
                                       where c.DistributionID.Equals(shFoodOutID)
                                       select c).FirstOrDefault();

                if (chkUSDA.Checked == true)
                {
                    //save ddlUSDA info, set FoodCatID to null
                    int ID = int.Parse(ddlFoodOutUSDA.SelectedValue);
                    USDACategory uc = db.USDACategories.Single(x => x.USDAID == ID);

                    editFoodOut.FoodCategoryID = null;
                    editFoodOut.USDACategory = uc;
                    editFoodOut.Weight = Convert.ToDouble(txtFoodOutWeight.Text);
                    editFoodOut.Count = short.Parse(txtFoodOutCount.Text);
                    editFoodOut.TimeStamp = Convert.ToDateTime(txtFoodOutTime.Text);

                    db.SaveChanges();
                    lblResponse.Visible = true;
                    lblResponse.Text = "Changes to Distribution ID: " + txtFoodOutDistID.Text + ", successfully saved!";

                }
                if (chkUSDA.Checked == false)
                {
                    //save ddlFoodCat info, set USDAID to null
                    editFoodOut.DistributionID = short.Parse(txtFoodOutDistID.Text);
                    editFoodOut.FoodCategoryID = short.Parse(ddlFoodOutCategoryType.SelectedValue);
                    editFoodOut.USDAID = null;
                    editFoodOut.Weight = Convert.ToDouble(txtFoodOutWeight.Text);
                    editFoodOut.TimeStamp = Convert.ToDateTime(txtFoodOutTime.Text);
                    if (txtFoodOutCount.Text.Length != 0)
                    {
                        editFoodOut.Count = short.Parse(txtFoodOutCount.Text);
                    }
                    else editFoodOut.Count = null;

                    db.SaveChanges();
                    lblResponse.Visible = true;
                    lblResponse.Text = "Changes to Distribution ID: " + txtFoodOutDistID.Text + ", successfully saved!";

                }
            }
        }
        catch (System.Threading.ThreadAbortException) { }
        catch (Exception ex)
        {
            LogError.logError(ex);
            Response.Redirect("../errorpages/error.aspx");
        }
    }
コード例 #16
0
    // @author: Anthony Dietrich - Save Add User Data
    // Saves User Data from the Add version of the Edit page
    protected void btnAddSave_Click(object sender, EventArgs e)
    {
        // Ensure all required fields are filled out
        if (txtFirstName.Text.Equals("") || txtLastName.Text.Equals("") || txtUserName.Text.Equals("") || txtPass.Text.Equals(""))
        {
            lblResponse.Visible = true;
            lblResponse.ForeColor = System.Drawing.Color.Red;
            lblResponse.Text = "Please fill out all fields!";
        }else
        {
            try
            {
                using (CCSEntities db = new CCSEntities())
                {
                    User user = new User();
                    user.FirstName = txtFirstName.Text;
                    user.LastName = txtLastName.Text;
                    user.UserName = txtUserName.Text;
                    user.Password = txtPass.Text;
                    if (ddlAddAdmin.SelectedItem.ToString().Equals("Yes"))
                        user.Admin = true;
                    if (ddlAddAdmin.SelectedItem.ToString().Equals("No"))
                        user.Admin = false;

                    // Check for duplicate userName
                    if (db.Users.Where(u => u.UserName.ToLower() == txtUserName.Text.ToLower()).Count() > 0)
                    {
                        lblResponse.Visible = true;
                        lblResponse.ForeColor = System.Drawing.Color.Red;
                        lblResponse.Text = "Cannot add duplicate username: "******"!";
                    }
                    else
                    {
                        db.Users.Add(user);
                        db.SaveChanges();

                        // Check to make sure the new user got saved
                        if (db.Users.Where(u => u.UserName.ToLower() == txtUserName.Text.ToLower()).Count() > 0)
                        {
                            lblResponse.Visible = true;
                            lblResponse.Text = "Success!  Username: "******" added to the system!";
                        }
                        else
                        {
                            lblResponse.Visible = true;
                            lblResponse.Text = "Error saving to the database!";
                        }
                    }
                }
            }
            catch (System.Threading.ThreadAbortException) { }
            catch (Exception ex)
            {
                LogError.logError(ex);
                Response.Redirect("../errorpages/error.aspx");
            }
        }
    }
コード例 #17
0
ファイル: add.aspx.cs プロジェクト: WsuCS3750/CCSInventory
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         using(CCSEntities db = new CCSEntities()){
             ddlState.DataSource = db.States.ToList();
             ddlState.DataBind();
         }
     }
 }
コード例 #18
0
ファイル: dgtest.aspx.cs プロジェクト: WsuCS3750/CCSInventory
    protected void Page_Load(object sender, EventArgs e)
    {
        using (CCSEntities db = new CCSEntities())
        {

            var d = (from a in db.Addresses
                  where a.Zipcode.ZipCode1 == "84401"
                  select new { a.StreetAddress1, a.City.CityName, a.Zipcode.ZipCode1 }).ToList();
            grid.DataSource = d;
        }
        grid.DataBind();
    }
コード例 #19
0
ファイル: edit.aspx.cs プロジェクト: WsuCS3750/CCSInventory
    protected void btnSave_Click(object sender, EventArgs e)
    {
        id = int.Parse(Request.QueryString["id"]);
        using (CCSEntities db = new CCSEntities())
        {
            a = (from ag in db.Agencies where ag.AgencyID == id select ag).First();
            //Update simple fields
            if(txtAgencyName.Text != "")
                a.AgencyName = txtAgencyName.Text;
            if (txtStreet1.Text != "")
                a.Address.StreetAddress1 = txtStreet1.Text;
            if (txtStreet2.Text != "")
                a.Address.StreetAddress2 = txtStreet2.Text;
            a.Address.StateID = (short)ddlState.SelectedIndex;

            string zip = txtZip.Text;
            string city = txtCity.Text;

            //does new zip already exist?
            if ((from z in db.Zipcodes where z.ZipCode1 == zip select z).Count() > 0)
            {
                //zip already exists, use existing zip
                a.Address.ZipID = (from z in db.Zipcodes where z.ZipCode1 == zip select z.ZipID).First();
            }
            else
            {
                //create new zip
                Zipcode z = new Zipcode();
                z.ZipCode1 = zip;
                db.Zipcodes.Add(z);
                a.Address.Zipcode = z;
            }

            //Does new city already exist?
            if ((from c in db.Cities where c.CityName == city select c).Count() > 0)
            {
                //zip already exists, use existing zip
                a.Address.City = (from c in db.Cities where c.CityName == city select c).First();
            }
            else
            {
                //create new zip
                City c = new City();
                c.CityName = city;
                db.Cities.Add(c);
                a.Address.City = c;
            }
            db.SaveChanges();
            saved.Visible = true;

        }
    }
コード例 #20
0
ファイル: print.aspx.cs プロジェクト: WsuCS3750/CCSInventory
    /// <summary>
    /// Loads the records passed in the session into the interface
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (Session["newFoodInIDs"] != null)
            {
                ids = (List<short>)Session["newFoodInIDs"];

                using (CCSEntities db = new CCSEntities())
                {
                    var foodInRecords = (from c in db.FoodIns
                                         where ids.Contains(c.FoodInID)
                                         select c);

                    lblAddress.Text = foodInRecords.First().FoodSource.Address.StreetAddress1 + " " + foodInRecords.First().FoodSource.Address.StreetAddress2;
                    lblCity.Text = foodInRecords.First().FoodSource.Address.City.CityName;
                    lblDateRecived.Text = foodInRecords.First().TimeStamp.ToString("d");
                    lblDonor.Text = foodInRecords.First().FoodSource.Source;
                    lblState.Text = foodInRecords.First().FoodSource.Address.State.StateShortName;
                    lblZip.Text = foodInRecords.First().FoodSource.Address.Zipcode.ZipCode1;

                    foreach (var foodIn in foodInRecords)
                    {
                        System.Web.UI.HtmlControls.HtmlTableRow row = new System.Web.UI.HtmlControls.HtmlTableRow();
                        System.Web.UI.HtmlControls.HtmlTableCell cat = new System.Web.UI.HtmlControls.HtmlTableCell();
                        System.Web.UI.HtmlControls.HtmlTableCell weight = new System.Web.UI.HtmlControls.HtmlTableCell();

                        cat.InnerText = foodIn.FoodCategory == null ? foodIn.USDACategory.Description : foodIn.FoodCategory.CategoryType;
                        weight.InnerText = foodIn.Weight.ToString();
                        row.Cells.Add(weight);
                        row.Cells.Add(cat);
                        row.Cells.Add(new System.Web.UI.HtmlControls.HtmlTableCell());
                        tableItems.Rows.Add(row);
                    }

                    if (foodInRecords.Count() < 5)
                        AddBlankRows(5 - foodInRecords.Count());
                }
            }
            else
            {
                AddBlankRows(6);
            }

        }
        catch (System.Threading.ThreadAbortException) { }
        catch (Exception ex)
        {
            LogError.logError(ex);
            Response.Redirect("../errorpages/error.aspx");
        }
    }
コード例 #21
0
    /// <summary>
    /// Returns a list of data base on the template passed in
    /// </summary>
    /// <param name="template">The template to base the data on</param>
    /// <param name="db">The context to use for grabbing the data</param>
    /// <returns>List of Food Categories specified by the template</returns>
    public static List<FoodCategory> GetFoodCategoriesBySelection(IFoodUSDACategeories template, CCSEntities db)
    {
        List<FoodCategory> foodCategoriesData = null;

            if (template.CategoriesSelection == ReportTemplate.SelectionType.ALL)
            {
                foodCategoriesData = db.FoodCategories.OrderBy(f => f.CategoryType).ToList();
            }
            else if (template.CategoriesSelection == ReportTemplate.SelectionType.REGULAR)
            {
                foodCategoriesData = (from f in db.FoodCategories
                    where f.Perishable == false && f.NonFood == false
                    orderby f.CategoryType
                    select f).ToList();

        //              Original
        //            foodCategoriesData = (from f in db.FoodCategories
        //                                  where f.Perishable == false && f.NonFood == false
        //                                  orderby f.CategoryType
        //                                  select f).ToList();
            }
            else if (template.CategoriesSelection == ReportTemplate.SelectionType.PERISHABLE)
            {
                foodCategoriesData = (from f in db.FoodCategories
                                        where f.Perishable == true
                                        orderby f.CategoryType
                                        select f).ToList();
            }
            else if (template.CategoriesSelection == ReportTemplate.SelectionType.NONFOOD)
            {
                foodCategoriesData = (from f in db.FoodCategories
                                        where f.NonFood == true
                                        orderby f.CategoryType
                                        select f).ToList();
            }
            else if (template.CategoriesSelection == ReportTemplate.SelectionType.SOME)
            {
                List<short> selectedCategories = new List<short>();
                foreach (var i in template.FoodCategories)
                    selectedCategories.Add(short.Parse(i));

                foodCategoriesData = (from f in db.FoodCategories
                                        where selectedCategories.Contains(f.FoodCategoryID)
                                        orderby f.CategoryType
                                        select f).ToList();
            }

            return foodCategoriesData;
    }
コード例 #22
0
    /// <summary>
    /// Loads any of the previously chosen options with the template into the interface
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (!Page.IsPostBack)
            {
                if (Session["reportTemplateRow"] == null || Session["reportTemplate"] == null)
                    Response.Redirect(Config.DOMAIN() + "desktop/reports");

                IncomingReportTemplate template = (IncomingReportTemplate)Session["reportTemplate"];

                using (CCSEntities db = new CCSEntities())
                {
                    List<FoodSource> foodSources = null;

                    if (template.FoodSourceTypesSelection == ReportTemplate.SelectionType.SOME)
                    {
                        List<short> selectedTypes = new List<short>();
                        foreach (var i in template.FoodSourceTypes)
                            selectedTypes.Add(short.Parse(i));

                        foodSources = (from f in db.FoodSources
                                        where selectedTypes.Contains((short)f.FoodSourceTypeID)
                                        select f).ToList();
                    }
                    else
                    {
                        foodSources = (from f in db.FoodSources
                                       select f).ToList();
                    }
                    lstFoodSources.SelectedType = template.FoodSourcesSelection;
                    lstFoodSources.AvailableList = (from f in foodSources
                                                    select new { ID = f.FoodSourceID, Display = f.Source }).ToList();

                    lstFoodSources.SelectedIDs = template.FoodSources;
                }

            }
        }
        catch (System.Threading.ThreadAbortException) { }
        catch (Exception ex)
        {
            LogError.logError(ex);
            Response.Redirect("~/errorpages/error.aspx");
        }
    }
コード例 #23
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         using (CCSEntities db = new CCSEntities())
         {
             grdAgency.DataSource = (from a in db.Agencies
                                     select new
                                     {
                                         ID = a.AgencyID,
                                         Name = a.AgencyName,
                                         City = a.Address.City.CityName
                                     }).ToList();
             grdAgency.DataBind();
         }
     }
 }
コード例 #24
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            id = int.Parse(Request.QueryString["id"]);

            using (CCSEntities db = new CCSEntities())
            {
                Container container = (from c in db.Containers
                             where c.BinNumber == (Int16)id
                             select c).FirstOrDefault();

                String type = (bool)container.isUSDA ?
                    container.USDACategory.Description + " (" + container.USDACategory.USDANumber + ") " + container.Cases + " Cases" :
                    container.FoodCategory.CategoryType + " - " + container.Weight + " Lbs";

                decimal weight = container.Weight;

                string date = DateTime.Today.ToString("d");
                string sId = id.ToString();
                int len = sId.Length;
                for (int i = len-1; i > 0; i--)
                {
                    sId = sId.Insert(i, " ");
                }

                lblBinNumber.Text = sId;
                lblCategory.Text = type;
                image.Src = "barcode.ashx?data=" + id;
                lblDate.Text = date;

                lblBinNumber2.Text = sId;
                lblCategory2.Text = type;
                image2.Src = "barcode.ashx?data=" + id;
                lblDate2.Text = date;
            }
        }
        catch (Exception ex)
        {
            lblBinNumber.Text = "Error: invalid id";
            image.Visible = false;
        }
    }
コード例 #25
0
ファイル: locate.aspx.cs プロジェクト: WsuCS3750/CCSInventory
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         if (!Page.IsPostBack)
         {
             using (CCSEntities db = new CCSEntities())
             {
                 ddlType.DataSource = db.FoodCategories.OrderBy(x => x.CategoryType).ToList();
                 ddlType.DataBind();
             }
         }
     }
     catch (Exception ex)
     {
         LogError.logError(ex);
         Response.Redirect("../errorpages/error.aspx");
     }
 }
コード例 #26
0
    private void bindGridView()
    {
        try
        {

            using (CCSEntities db = new CCSEntities())
            {
                var errorLogs = (from a in db.ErrorLogs
                              select a).OrderByDescending(x => x.TimeStamp);

                gvErrorLog.DataSource = errorLogs.ToList();
                gvErrorLog.DataBind();
            }
        }
        catch (Exception ex)
        {
            lblMessage.Text = "An unexpected problem occurred: " + ex.Message;
        }
    }
コード例 #27
0
    private void updateGridView()
    {
        try
        {
            lblMessage.Text = "";

            using (CCSEntities db = new CCSEntities())
            {
                List<Location> lstLocations = db.Locations.OrderBy(x => x.RoomName).ToList();

                gvLocation.DataSource = lstLocations;
                gvLocation.DataBind();
            }
        }
        catch (Exception ex)
        {
            LogError.logError(ex);
            Response.Redirect("../errorpages/error.aspx");
        }
    }
コード例 #28
0
    private void bindGridView()
    {
        try
        {
            using (CCSEntities db = new CCSEntities())
            {
                var distributionTypes = db.DistributionTypes.ToList();
                distributionTypes.Sort((x, y) => String.Compare(x.DistributionType1, y.DistributionType1));

                gvDistributionTypes.DataSource = distributionTypes;
                gvDistributionTypes.DataBind();
            }
        }
        catch (System.Threading.ThreadAbortException) { }
        catch (Exception ex)
        {
            LogError.logError(ex);
            Response.Redirect("../errorpages/error.aspx");
        }
    }
コード例 #29
0
    private void LoadDropDowns()
    {
        using (CCSEntities db = new CCSEntities())
            {
                ddlDistributionType.DataSource = db.DistributionTypes.ToList().OrderBy(x => x.DistributionType1);
                ddlDistributionType.DataBind();

                ddlAgency.DataSource = db.Agencies.ToList().OrderBy(x => x.AgencyName);
                ddlAgency.DataBind();

                ddlDonorType.DataSource = db.FoodSourceTypes.ToList().OrderBy(x => x.FoodSourceType1);
                ddlDonorType.DataBind();

                foreach(var f in foodOutRecords)
                {
                    if (f.FoodSourceTypeID != null)
                        ddlDonorType.SelectedValue = f.FoodSourceTypeID.ToString();
                }
            }
    }
コード例 #30
0
    private void bindGridView()
    {
        try
        {

            using (CCSEntities db = new CCSEntities())
            {
                var changeLogs = (from a in db.Logs
                                  select new { a.Description, a.Date, UserName = a.User.FirstName + " " + a.User.LastName }).OrderByDescending(x => x.Date);

                gvChangeLog.DataSource = changeLogs.ToList();
                gvChangeLog.DataBind();
            }
        }
        catch (Exception ex)
        {
            lblMessage.Text = "An unexpected problem occurred. Please try again later.";

            LogError.logError(ex);
        }
    }