protected void btnUpdate_Click(object sender, EventArgs e)
    {///Add Exception handilng try catch change by vishal 21-05-2012
        try
        {
            string vardateFrom;
            string vardateTo;
            string varemail   = "";
            int    contractid = Convert.ToInt32(Request.QueryString[0]);
            objContract.Contractname = txtContractName.Text;
            objContract.Contractid   = contractid;
            string[] tempdate = txtActiveFrom.Text.ToString().Split(("/").ToCharArray());
            vardateFrom = tempdate[2] + "-" + tempdate[1] + "-" + tempdate[0];

            objContract.Activefrom = vardateFrom;

            string[] tempdate1 = txtActiveTo.Text.ToString().Split(("/").ToCharArray());
            vardateTo               = tempdate1[2] + "-" + tempdate1[1] + "-" + tempdate1[0];
            objContract.Activeto    = vardateTo;
            objContract.Description = txtdesc.Text;
            objContract.Vendorid    = Convert.ToInt32(drpVendor.SelectedValue);
            objContract.Update();
            objContractToAsset.Delete(contractid);
            for (int i = ListAsset.Items.Count - 1; i >= 0; i--)
            {
                objContractToAsset.Assetid    = Convert.ToInt32(ListAsset.Items[i].Value);
                objContractToAsset.Contractid = contractid;
                objContractToAsset.Insert();
            }


            if (chkLevel1.Checked == true)
            {
                for (int i = listLevel1.Items.Count - 1; i >= 0; i--)
                {
                    if (listLevel1.Items[i].Selected == true)
                    {
                        varemail = varemail + listLevel1.Items[i].Text + ",";
                    }
                }

                objContractNotfy.Contractid       = contractid;
                objContractNotfy.Sendnotification = false;
                objContractNotfy.Sentto           = varemail;
                objContractNotfy.Beforedays       = Convert.ToInt32(txtBeforeDays.Text);
                objContractNotfy.Update();
                Response.Redirect("../Contract/DisplayAllContract.aspx");
            }
        }
        catch (Exception ex)
        {
            string myScript;
            myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>";
            Page.RegisterClientScriptBlock("MyScript", myScript);
            return;
        }
    }
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        string vardateFrom;
        string vardateTo;
        string varemail   = "";
        int    contractid = Convert.ToInt16(Request.QueryString[0]);

        objContract.Contractname = txtContractName.Text;
        objContract.Contractid   = contractid;
        string[] tempdate = txtActiveFrom.Text.ToString().Split(("/").ToCharArray());
        vardateFrom = tempdate[2] + "-" + tempdate[1] + "-" + tempdate[0];

        objContract.Activefrom = vardateFrom;

        string[] tempdate1 = txtActiveTo.Text.ToString().Split(("/").ToCharArray());
        vardateTo               = tempdate1[2] + "-" + tempdate1[1] + "-" + tempdate1[0];
        objContract.Activeto    = vardateTo;
        objContract.Description = txtdesc.Text;
        objContract.Vendorid    = Convert.ToInt16(drpVendor.SelectedValue);
        objContract.Update();
        objContractToAsset.Delete(contractid);
        for (int i = ListAsset.Items.Count - 1; i >= 0; i--)
        {
            objContractToAsset.Assetid    = Convert.ToInt16(ListAsset.Items[i].Value);
            objContractToAsset.Contractid = contractid;
            objContractToAsset.Insert();
        }


        if (chkLevel1.Checked == true)
        {
            for (int i = listLevel1.Items.Count - 1; i >= 0; i--)
            {
                if (listLevel1.Items[i].Selected == true)
                {
                    varemail = varemail + listLevel1.Items[i].Text + ",";
                }
            }

            objContractNotfy.Contractid       = contractid;
            objContractNotfy.Sendnotification = false;
            objContractNotfy.Sentto           = varemail;
            objContractNotfy.Beforedays       = Convert.ToInt16(txtBeforeDays.Text);
            objContractNotfy.Update();
            Response.Redirect("../Contract/DisplayAllContract.aspx");
        }
    }