Exemple #1
0
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        lblEMsg.Visible = false;
        string[] Auth;
        Profile pro = new Profile();
        try
        {
            if (lstid.SelectedItem.Text == "")
            {
                lblEMsg.Text = "Please select Author ID";
                lblEMsg.Visible = true;
            }
            else
            {
                Auth = new string[15];

                Auth[0] = lstid.Text;
                Auth[1] = txtAName.Text;
                Auth[2] = txtAdd.Text;
                Auth[3] = txtPhone.Text;
                Auth[4] = txtFax.Text;
                Auth[5] = txtEmail.Text;
                if (chkStatus.Checked == true)
                {
                    Auth[6] = "A";
                }
                else
                {
                    Auth[6] = "I";
                }

                bool status;
                status = pro.UpdateAuthor(Auth);

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

                //Load all the Category First.
                string sql = "SELECT Author_ID FROM Author";
                SqlDataReader sdr;
                sdr = pro.ReturnMDetails(sql);
                lstid.Items.Clear();
                while (sdr.Read())
                {
                    lstid.Items.Add(sdr["Author_ID"].ToString().Trim());
                }
                sdr.Close();
                txtAName.Text = "";
                txtAdd.Text = "";
                txtPhone.Text = "";
                txtFax.Text = "";
                txtEmail.Text = "";
                chkStatus.Checked = false;
                return;
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }