Exemplo n.º 1
0
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        lblEMsg.Visible = false;
        string[] Catg;
        Profile pro = new Profile();
        try
        {
            if (lstid.Text == "")
            {
                lblEMsg.Text = "Please select Category ID";
                lblEMsg.Visible = true;
            }
            else
            {
                Catg = new string[15];

                Catg[0] = lstid.Text;
                Catg[1] = txtCName.Text;
                Catg[2] = txtcDesc.Text;
                if (chkStatus.Checked == true)
                {
                    Catg[3] = "A";
                }
                else
                {
                    Catg[3] = "I";
                }

                bool status;
                status = pro.UpdateCategory(Catg);

                if (status == false)
                {
                    lblEMsg.Visible = true;
                    lblEMsg.Text = "Category updation Failed";
                }
                lblEMsg.Visible = true;
                lblEMsg.Text = "Category updated.";

                //Load all the Category First.
                /*string sql = "SELECT Category_ID FROM CATEGORY";
                SqlDataReader sdr;
                sdr = pro.ReturnMDetails(sql);
                lstid.Items.Clear();
                while (sdr.Read())
                {
                    lstid.Items.Add(sdr["Category_ID"].ToString().Trim());
                }
                sdr.Close();
                return;*/
                //txtCName.Text = "";
                //txtcDesc.Text = "";
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }