예제 #1
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        lblEMsg.Visible = false;
        string[] Auth;
        try
        {
            string sql = "SELECT COUNT(*) FROM Author WHERE Author_NAME = '" + txtAName.Text + "' And Status = 'A'";
            SqlDataReader sdr;
            Profile pro = new Profile();
            sdr = pro.ReturnMDetails(sql);

            sdr.Read();
            int RegNo = (int)sdr[0];
            if (RegNo > 0)
            {
                lblEMsg.Text = "Author Name already exists.";
                lblEMsg.Visible = true;
                sdr.Close();
                return;
            }
            else
            {
                Auth = new string[15];

                Auth[0] = txtAuthor.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[7] = "I";
                }

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

                if (status == false)
                {
                    lblEMsg.Visible = true;
                    lblEMsg.Text = "Author creation Failed";
                }
                lblEMsg.Visible = true;
                lblEMsg.Text = "Author added.";
                ReadAuthor();
                txtAName.Text = "";
                txtAdd.Text = "";
                txtPhone.Text = "";
                txtFax.Text = "";
                txtemail.Text = "";
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }