Ejemplo n.º 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     oModelsProperties = new ModelsProperties(0, dsn);
     if (Request.QueryString["mid"] != null && Request.QueryString["mid"] != "")
     {
         intModel = Int32.Parse(Request.QueryString["mid"]);
         if (intModel > 0)
         {
             lblName.Text = oModelsProperties.Get(intModel, "name");
         }
     }
     if (Request.QueryString["id"] != null && Request.QueryString["id"] != "")
     {
         intID = Int32.Parse(Request.QueryString["id"]);
         if (IsPostBack == false)
         {
             panOne.Visible = true;
             DataSet ds = oModelsProperties.GetThreshold(intID);
             if (ds.Tables[0].Rows.Count > 0)
             {
                 txtFrom.Text       = ds.Tables[0].Rows[0]["qty_from"].ToString();
                 txtTo.Text         = ds.Tables[0].Rows[0]["qty_to"].ToString();
                 txtNumber.Text     = ds.Tables[0].Rows[0]["number_days"].ToString();
                 chkEnabled.Checked = (ds.Tables[0].Rows[0]["enabled"].ToString() == "1");
                 btnSubmit.Text     = "Update";
             }
             else
             {
                 btnSubmit.Text = "Add";
             }
         }
     }
     else if (intModel > 0)
     {
         panAll.Visible     = true;
         rptView.DataSource = oModelsProperties.GetThresholds(intModel, 0);
         rptView.DataBind();
         lblNone.Visible = (rptView.Items.Count == 0);
     }
     btnSubmit.Attributes.Add("onclick", "return ValidateNumber0('" + txtFrom.ClientID + "','Please enter a valid number for the quantity')" +
                              " && ValidateNumber0('" + txtTo.ClientID + "','Please enter a valid number for the quantity')" +
                              " && ValidateNumber0('" + txtNumber.ClientID + "','Please enter a valid number for the number of days')" +
                              ";");
 }