示例#1
0
        protected void SearchProductsPartial_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(PartialProductNameV2.Text))
            {
                errormsgs.Add("Please enter a partial product name for the search");
                LoadMessageDisplay(errormsgs, "alert alert-info");
                ProductGridViewV2.DataSource = null;
                ProductGridViewV2.DataBind();
            }
            else
            {
                try
                {
                    Controller02    sysmgr = new Controller02();
                    List <Entity02> info   = sysmgr.FindByPartialName(PartialProductNameV2.Text);
                    if (info.Count == 0)
                    {
                        errormsgs.Add("No data found for the partial product name search");
                        LoadMessageDisplay(errormsgs, "alert alert-info");
                    }
                    else
                    {
                        info.Sort((x, y) => x.ProductName.CompareTo(y.ProductName));
                        //load the multiple record control

                        //GridView
                        ProductGridViewV2.DataSource = info;
                        ProductGridViewV2.DataBind();
                    }
                }
                catch (Exception ex)
                {
                    errormsgs.Add(GetInnerException(ex).ToString());
                    LoadMessageDisplay(errormsgs, "alert alert-danger");
                }
            }
        }
 protected void Fetch_Click(object sender, EventArgs e)
 {
     if (List01.SelectedIndex == 0)
     {
         MessageLabel.Text = "Select a team to view details";
         //clear details
         Coach.Text          = "";
         AssistantCoach.Text = "";
         Wins.Text           = "";
         Losses.Text         = "";
     }
     else
     {
         try
         {
             Controller02    sysmgr = new Controller02();
             List <Entity02> info   = null;
             info = sysmgr.FindByID(int.Parse(List01.SelectedValue));
             info.Sort((x, y) => x.PlayerName.CompareTo(y.PlayerName));
             List02.DataSource = info;
             List02.DataBind();
             // Team info
             Controller01 teamController = new Controller01();
             Entity01     teamInfo       = null;
             teamInfo            = teamController.TeamGet(int.Parse(List01.SelectedValue));
             Coach.Text          = teamInfo.Coach;
             AssistantCoach.Text = teamInfo.AssistantCoach;
             Wins.Text           = teamInfo.Wins.ToString();
             Losses.Text         = teamInfo.Losses.ToString();
         }
         catch (Exception ex)
         {
             MessageLabel.Text = ex.Message;
         }
     }
 }
        protected void Update_Click(object sender, EventArgs e)
        {
            int id = 0;

            if (string.IsNullOrEmpty(ID.Text))
            {
                errormsgs.Add("Search for a record to update");
            }
            else if (!int.TryParse(ID.Text, out id))
            {
                errormsgs.Add("Id is invalid");
            }
            Validation(sender, e);
            if (errormsgs.Count > 1)
            {
                LoadMessageDisplay(errormsgs, "alert alert-info");
            }
            else
            {
                try
                {
                    Controller02 sysmgr = new Controller02();
                    Entity02     item   = new Entity02();
                    item.ProductID   = int.Parse(ID.Text);
                    item.ProductName = Name.Text.Trim();
                    if (SupplierList.SelectedIndex == 0)
                    {
                        item.SupplierID = null;
                    }
                    else
                    {
                        item.SupplierID = int.Parse(SupplierList.SelectedValue);
                    }
                    item.CategoryID      = int.Parse(CategoryList.SelectedValue);
                    item.QuantityPerUnit =
                        string.IsNullOrEmpty(QuantityPerUnit.Text) ? null : QuantityPerUnit.Text;
                    if (string.IsNullOrEmpty(UnitPrice.Text))
                    {
                        item.UnitPrice = null;
                    }
                    else
                    {
                        item.UnitPrice = decimal.Parse(UnitPrice.Text);
                    }
                    if (string.IsNullOrEmpty(UnitsInStock.Text))
                    {
                        item.UnitsInStock = null;
                    }
                    else
                    {
                        item.UnitsInStock = Int16.Parse(UnitsInStock.Text);
                    }
                    if (string.IsNullOrEmpty(UnitsOnOrder.Text))
                    {
                        item.UnitsOnOrder = null;
                    }
                    else
                    {
                        item.UnitsOnOrder = Int16.Parse(UnitsOnOrder.Text);
                    }
                    if (string.IsNullOrEmpty(ReorderLevel.Text))
                    {
                        item.ReorderLevel = null;
                    }
                    else
                    {
                        item.ReorderLevel = Int16.Parse(ReorderLevel.Text);
                    }
                    item.Discontinued = Discontinued.Checked;
                    int rowsaffected = sysmgr.Update(item);
                    if (rowsaffected > 0)
                    {
                        errormsgs.Add("Record has been updated");
                        LoadMessageDisplay(errormsgs, "alert alert-success");
                    }
                    else
                    {
                        errormsgs.Add("Record was not found");
                        LoadMessageDisplay(errormsgs, "alert alert-warning");
                    }
                }
                catch (Exception ex)
                {
                    errormsgs.Add(GetInnerException(ex).ToString());
                    LoadMessageDisplay(errormsgs, "alert alert-danger");
                }
            }
        }
 protected void Add_Click(object sender, EventArgs e)
 {
     Validation(sender, e);
     if (errormsgs.Count > 1)
     {
         LoadMessageDisplay(errormsgs, "alert alert-info");
     }
     else
     {
         try
         {
             Controller02 sysmgr = new Controller02();
             Entity02     item   = new Entity02();
             //No ProductID here as the database will give a new one back when we add
             item.ProductName = Name.Text.Trim(); //NOT NULL
             if (SupplierList.SelectedIndex == 0) //NULL
             {
                 item.SupplierID = null;
             }
             else
             {
                 item.SupplierID = int.Parse(SupplierList.SelectedValue);
             }
             //CategoryID can be NULL in database but NOT NULL when record is added in this CRUD page
             item.CategoryID      = int.Parse(CategoryList.SelectedValue);
             item.QuantityPerUnit =
                 string.IsNullOrEmpty(QuantityPerUnit.Text) ? null : QuantityPerUnit.Text; //NULL
             //UnitPrice can be NULL in database but NOT NULL when record is added in this CRUD page
             item.UnitPrice = decimal.Parse(UnitPrice.Text);
             if (string.IsNullOrEmpty(UnitsInStock.Text)) //NULL
             {
                 item.UnitsInStock = null;
             }
             else
             {
                 item.UnitsInStock = Int16.Parse(UnitsInStock.Text);
             }
             if (string.IsNullOrEmpty(UnitsOnOrder.Text)) //NULL
             {
                 item.UnitsOnOrder = null;
             }
             else
             {
                 item.UnitsOnOrder = Int16.Parse(UnitsOnOrder.Text);
             }
             if (string.IsNullOrEmpty(ReorderLevel.Text)) //NULL
             {
                 item.ReorderLevel = null;
             }
             else
             {
                 item.ReorderLevel = Int16.Parse(ReorderLevel.Text);
             }
             item.Discontinued = false; //NOT NULL
             int newID = sysmgr.Add(item);
             ID.Text = newID.ToString();
             errormsgs.Add("Record has been added");
             LoadMessageDisplay(errormsgs, "alert alert-success");
             UpdateButton.Enabled = true;
             DeleteButton.Enabled = true;
             Discontinued.Enabled = true;
         }
         catch (Exception ex)
         {
             errormsgs.Add(GetInnerException(ex).ToString());
             LoadMessageDisplay(errormsgs, "alert alert-danger");
         }
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     errormsgs.Clear();
     Message.DataSource = null;
     Message.DataBind();
     if (!Page.IsPostBack)
     {
         errormsgs.Add("IsPostBack = False");
         LoadMessageDisplay(errormsgs, "alert alert-info");
         pagenum = Request.QueryString["page"];
         pid     = Request.QueryString["pid"];
         add     = Request.QueryString["add"];
         BindCategoryList();
         BindSupplierList();
         if (string.IsNullOrEmpty(pid))
         {
             Response.Redirect("~/Default.aspx");
         }
         else if (add == "yes")
         {
             Discontinued.Enabled = false;
             UpdateButton.Enabled = false;
             DeleteButton.Enabled = false;
         }
         else
         {
             AddButton.Enabled = false;
             Controller02 sysmgr = new Controller02();
             Entity02     info   = null;
             info = sysmgr.FindByPKID(int.Parse(pid));
             if (info == null)
             {
                 errormsgs.Add("Record is not in Database.");
                 LoadMessageDisplay(errormsgs, "alert alert-info");
                 Clear(sender, e);
             }
             else
             {
                 ID.Text   = info.ProductID.ToString(); //NOT NULL
                 Name.Text = info.ProductName;          //NOT NULL
                 if (info.CategoryID.HasValue)          //NULL
                 {
                     CategoryList.SelectedValue = info.CategoryID.ToString();
                 }
                 else
                 {
                     CategoryList.SelectedIndex = 0;
                 }
                 if (info.SupplierID.HasValue) //NULL
                 {
                     SupplierList.SelectedValue = info.SupplierID.ToString();
                 }
                 else
                 {
                     SupplierList.SelectedIndex = 0;
                 }
                 QuantityPerUnit.Text =
                     info.QuantityPerUnit == null ? "" : info.QuantityPerUnit;                       //NULL
                 UnitPrice.Text =
                     info.UnitPrice.HasValue ? string.Format("{0:0.00}", info.UnitPrice.Value) : ""; //NULL
                 UnitsInStock.Text =
                     info.UnitsInStock.HasValue ? info.UnitsInStock.Value.ToString() : "";           //NULL
                 UnitsOnOrder.Text =
                     info.UnitsOnOrder.HasValue ? info.UnitsOnOrder.Value.ToString() : "";           //NULL
                 ReorderLevel.Text =
                     info.ReorderLevel.HasValue ? info.ReorderLevel.Value.ToString() : "";           //NULL
                 Discontinued.Checked = info.Discontinued;                                           //NOT NULL
             }
         }
     }
     else
     {
         errormsgs.Add("IsPostBack = True");
     }
 }
示例#6
0
 protected void Page_Load(object sender, EventArgs e)
 {
     Message.DataSource = null;
     Message.DataBind();
     if (!Page.IsPostBack)
     {
         pagenum = Request.QueryString["page"];
         pid     = Request.QueryString["pid"];
         add     = Request.QueryString["add"];
         errormsgs.Add("The page you came from is: " + pagenum);
         errormsgs.Add("You passed this ProductID: " + pid);
         errormsgs.Add("You passed this Add option: " + add);
         LoadMessageDisplay(errormsgs, "alert alert-info");
         BindCategoryList();
         BindSupplierList();
         if (string.IsNullOrEmpty(pid))
         {
             Response.Redirect("~/Default.aspx");
         }
         else if (add == "yes")
         {
             Discontinued.Enabled = false;
         }
         else
         {
             Controller02 sysmgr = new Controller02();
             Entity02     info   = null;
             info = sysmgr.FindByPKID(int.Parse(pid));
             if (info == null)
             {
                 errormsgs.Add("Product is no longer on file.");
                 LoadMessageDisplay(errormsgs, "alert alert-info");
                 Clear_Click(sender, e);
             }
             else
             {
                 ProductID.Text       = info.ProductID.ToString();
                 ProductName.Text     = info.ProductName;
                 QuantityPerUnit.Text =
                     info.QuantityPerUnit == null ? "" : info.QuantityPerUnit;
                 UnitPrice.Text =
                     info.UnitPrice.HasValue ? string.Format("{0:0.00}", info.UnitPrice.Value) : "";
                 UnitsInStock.Text =
                     info.UnitsInStock.HasValue ? info.UnitsInStock.Value.ToString() : "";
                 UnitsOnOrder.Text =
                     info.UnitsOnOrder.HasValue ? info.UnitsOnOrder.Value.ToString() : "";
                 ReorderLevel.Text =
                     info.ReorderLevel.HasValue ? info.ReorderLevel.Value.ToString() : "";
                 Discontinued.Checked = info.Discontinued;
                 if (info.CategoryID.HasValue)
                 {
                     CategoryList.SelectedValue = info.CategoryID.ToString();
                 }
                 else
                 {
                     CategoryList.SelectedIndex = 0;
                 }
                 if (info.SupplierID.HasValue)
                 {
                     SupplierList.SelectedValue = info.SupplierID.ToString();
                 }
                 else
                 {
                     SupplierList.SelectedIndex = 0;
                 }
             }
         }
     }
 }
示例#7
0
        protected void Add_Click(object sender, EventArgs e)
        {
            bool validdata = Validation(sender, e);

            if (validdata)
            {
                try
                {
                    Controller02 sysmgr = new Controller02();
                    Entity02     item   = new Entity02();
                    item.ProductName = ProductName.Text.Trim();
                    if (CategoryList.SelectedIndex == 0)
                    {
                        item.CategoryID = null;
                    }
                    else
                    {
                        item.CategoryID = int.Parse(CategoryList.SelectedValue);
                    }
                    if (SupplierList.SelectedIndex == 0)
                    {
                        item.SupplierID = null;
                    }
                    else
                    {
                        item.SupplierID = int.Parse(SupplierList.SelectedValue);
                    }
                    item.QuantityPerUnit =
                        string.IsNullOrEmpty(QuantityPerUnit.Text) ? null : QuantityPerUnit.Text;
                    if (string.IsNullOrEmpty(UnitPrice.Text))
                    {
                        item.UnitPrice = null;
                    }
                    else
                    {
                        item.UnitPrice = decimal.Parse(UnitPrice.Text);
                    }
                    if (string.IsNullOrEmpty(UnitsInStock.Text))
                    {
                        item.UnitsInStock = null;
                    }
                    else
                    {
                        item.UnitsInStock = Int16.Parse(UnitsInStock.Text);
                    }
                    if (string.IsNullOrEmpty(UnitsOnOrder.Text))
                    {
                        item.UnitsOnOrder = null;
                    }
                    else
                    {
                        item.UnitsOnOrder = Int16.Parse(UnitsOnOrder.Text);
                    }
                    if (string.IsNullOrEmpty(ReorderLevel.Text))
                    {
                        item.ReorderLevel = null;
                    }
                    else
                    {
                        item.ReorderLevel = Int16.Parse(ReorderLevel.Text);
                    }
                    item.Discontinued = false;
                    int newProductID = sysmgr.Add(item);
                    ProductID.Text = newProductID.ToString();
                    errormsgs.Add("Product has been added");
                    LoadMessageDisplay(errormsgs, "alert alert-success");
                    //BindProductList(); //by default, list will be at index 0
                    //ProductList.SelectedValue = ProductID.Text;
                }
                catch (DbUpdateException ex)
                {
                    UpdateException updateException = (UpdateException)ex.InnerException;
                    if (updateException.InnerException != null)
                    {
                        errormsgs.Add(updateException.InnerException.Message.ToString());
                    }
                    else
                    {
                        errormsgs.Add(updateException.Message);
                    }
                    LoadMessageDisplay(errormsgs, "alert alert-danger");
                }
                catch (DbEntityValidationException ex)
                {
                    foreach (var entityValidationErrors in ex.EntityValidationErrors)
                    {
                        foreach (var validationError in entityValidationErrors.ValidationErrors)
                        {
                            errormsgs.Add(validationError.ErrorMessage);
                        }
                    }
                    LoadMessageDisplay(errormsgs, "alert alert-danger");
                }
                catch (Exception ex)
                {
                    errormsgs.Add(GetInnerException(ex).ToString());
                    LoadMessageDisplay(errormsgs, "alert alert-danger");
                }
            }
        }
示例#8
0
 public void InitializeView()
 {
     controller02 = GameObject.FindGameObjectWithTag("Painel2 - Tutorial").GetComponent <Controller02>();
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            Message.DataSource = null;
            Message.DataBind();
            if (!Page.IsPostBack)
            {
                pagenum = Request.QueryString["page"];
                pid     = Request.QueryString["pid"];
                add     = Request.QueryString["add"];
                BindCategoryList();
                BindSupplierList();
                if (string.IsNullOrEmpty(pid))
                {
                    Response.Redirect("~/Default.aspx");
                }
                else if (add == "yes")
                {
                    UpdateButton.Enabled = false;
                    DeleteButton.Enabled = false;
                }
                else
                {
                    AddButton.Enabled = false;
                    Controller02 sysmgr = new Controller02();
                    Entity02     info   = null;
                    info = sysmgr.FindByPLID(int.Parse(pid));
                    if (info == null)
                    {
                        errormsgs.Add("Record is no longer on file.");
                        LoadMessageDisplay(errormsgs, "alert alert-info");
                        Clear_Click(sender, e);
                    }
                    else
                    {
                        ID.Text        = info.PlayerID.ToString();
                        FirstName.Text = info.FirstName;
                        LastName.Text  = info.LastName;
                        Age.Text       = info.Age.ToString();
                        Gender.Text    = info.Gender;
                        AlbertaHealthCareNumber.Text = info.AlbertaHealthCareNumber;
                        MedicalAlertDetails.Text     = info.MedicalAlertDetails;


                        if (info.GuardianID.HasValue)
                        {
                            CategoryList.SelectedValue = info.GuardianID.ToString();
                        }
                        else
                        {
                            CategoryList.SelectedIndex = 0;
                        }
                        if (info.TeamID.HasValue)
                        {
                            SupplierList.SelectedValue = info.TeamID.ToString();
                        }
                        else
                        {
                            SupplierList.SelectedIndex = 0;
                        }
                    }
                }
            }
        }
 protected void Add_Click(object sender, EventArgs e)
 {
     Validation(sender, e);
     if (errormsgs.Count > 0)
     {
         LoadMessageDisplay(errormsgs, "alert alert-info");
     }
     else
     {
         try
         {
             Controller02 sysmgr = new Controller02();
             Entity02     item   = new Entity02();
             item.ProductName = Name.Text.Trim();
             if (SupplierList.SelectedIndex == 0)
             {
                 item.SupplierID = null;
             }
             else
             {
                 item.SupplierID = int.Parse(SupplierList.SelectedValue);
             }
             item.QuantityPerUnit =
                 string.IsNullOrEmpty(QuantityPerUnit.Text) ? null : QuantityPerUnit.Text;
             if (string.IsNullOrEmpty(UnitPrice.Text))
             {
                 item.UnitPrice = null;
             }
             else
             {
                 item.UnitPrice = decimal.Parse(UnitPrice.Text);
             }
             if (string.IsNullOrEmpty(UnitsInStock.Text))
             {
                 item.UnitsInStock = null;
             }
             else
             {
                 item.UnitsInStock = Int16.Parse(UnitsInStock.Text);
             }
             if (string.IsNullOrEmpty(UnitsOnOrder.Text))
             {
                 item.UnitsOnOrder = null;
             }
             else
             {
                 item.UnitsOnOrder = Int16.Parse(UnitsOnOrder.Text);
             }
             if (string.IsNullOrEmpty(ReorderLevel.Text))
             {
                 item.ReorderLevel = null;
             }
             else
             {
                 item.ReorderLevel = Int16.Parse(ReorderLevel.Text);
             }
             item.Discontinued = false;
             int newID = sysmgr.Add(item);
             ID.Text = newID.ToString();
             errormsgs.Add("Product has been added");
             LoadMessageDisplay(errormsgs, "alert alert-success");
         }
         catch (Exception ex)
         {
             errormsgs.Add(GetInnerException(ex).ToString());
             LoadMessageDisplay(errormsgs, "alert alert-danger");
         }
     }
 }