示例#1
0
 protected void btnSavePurpose_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtPurposeCode.Text != "" && txtPDescription.Text != "")
         {
             objAttachmentcls             = new AttachmentCls();
             objAttachmentcls.PurposeCode = txtPurposeCode.Text.Trim();
             objAttachmentcls.PurposeDesc = txtPDescription.Text.Trim();
             if (btnSavePurpose.Text == "Save")
             {
                 int res = objAttachmentcls.InsertPurpose();
                 if (res > 0)
                 {
                     ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Data Saved Successfully');", true);
                 }
                 else
                 {
                     ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Data Not Saved');", true);
                 }
             }
             else
             {
                 int res = objAttachmentcls.UpdatePurpose();
                 if (res > 0)
                 {
                     ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Data Updated Successfully');", true);
                 }
                 else
                 {
                     ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Data Not Updated');", true);
                 }
             }
         }
         else
         {
             ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Please enter all data');", true);
         }
     }
     catch (Exception ex)
     {
         ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Due to some technical issue record not found');", true);
     }
 }