//private static List<Entity02> Entity02List = new List<Entity02>();
 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"];
         BindGuardianList();
         BindTeamList();
         if (string.IsNullOrEmpty(pid))
         {
             Response.Redirect("~/Default.aspx");
         }
         //else if (add == "yes")
         //{
         //    //Discontinued.Enabled = false;
         //}
         else if (add == "no")
         {
             Controller02 sysmgr = new Controller02();
             Entity02     info   = null;
             info = sysmgr.FindByPKID(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;
                 GuardianList.SelectedValue   = info.GuardianID.ToString();
                 TeamList.SelectedValue       = info.TeamID.ToString();
                 Age.Text                     = info.Age.ToString();
                 Gender.Text                  = info.Gender.ToUpper();
                 AlbertaHealthCareNumber.Text = info.AlbertaHealthCareNumber;
                 MedicalAlertDetails.Text     =
                     info.MedicalAlertDetails == null ? "" : info.MedicalAlertDetails;
             }
         }
     }
 }
 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");
     }
 }
Exemple #3
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;
                 }
             }
         }
     }
 }