예제 #1
0
 /// <summary>
 /// Fatching row details into Textboxes on Edit button click.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName.Equals(CommonConstants.EditRow))
     {
         int         index = Convert.ToInt32(e.CommandArgument);
         GridViewRow row   = grdView1.Rows[index];
         Session[CommonConstants.SelectedRowIndex] = row.RowIndex;
         txtPolicyNo.Text    = row.Cells[0].Text;
         txtPolicyNo.Enabled = CommonConstants.False;
         txtUserName.Text    = row.Cells[2].Text;
         txtRequestDate.Text = row.Cells[3].Text;
         txtMailId.Text      = row.Cells[4].Text;
         TextBox tbox = (TextBox)row.FindControl("GrdTxtBusinessReason");
         txtBusinessReason.Text  = tbox.Text.ToString();
         txtRootSegCount.Text    = row.Cells[6].Text;
         txtMachineSegCount.Text = row.Cells[7].Text;
         txtFaceSegCount.Text    = row.Cells[8].Text;
     }
     if (e.CommandName.Equals(CommonConstants.DeleteRow))
     {
         int status;
         int index = Convert.ToInt32(e.CommandArgument);
         PolicyDetailsBusinessEntity   policyDetails  = new PolicyDetailsBusinessEntity();
         MilePostBuzLogic              milePostBuzObj = new MilePostBuzLogic();
         UserInfoDetailsBusinessEntity userInfo       = (UserInfoDetailsBusinessEntity)Session[CommonConstants.UserInfo];
         try
         {
             GridViewRow row = grdView1.Rows[index];
             policyDetails.PolicyNo = row.Cells[0].Text;
             policyDetails.UserId   = userInfo.UserId;
             status = milePostBuzObj.DeletePolicyDetails(policyDetails);
             if (status == CommonConstants.StatusOne)
             {
                 ScriptManager.RegisterStartupScript(this, GetType(), CommonConstants.ShowAlert, CommonConstants.SuccessDeleted, true);
                 LoadGrid();
             }
         }
         catch (Exception ex)
         {
             HandleLogging.AddtoLogFile(ex.Message, CommonConstants.PolicyEntry);
             Response.Redirect(CommonConstants.Error);
         }
         finally
         {
             if (!txtPolicyNo.Enabled)
             {
                 txtPolicyNo.Enabled = CommonConstants.True;
             }
             txtPolicyNo.Text        = string.Empty;
             txtRequestDate.Text     = string.Empty;
             txtRootSegCount.Text    = string.Empty;
             txtBusinessReason.Text  = string.Empty;
             txtMachineSegCount.Text = string.Empty;
             txtFaceSegCount.Text    = string.Empty;
         }
     }
 }