Example #1
0
 protected void gvDept_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     try
     {
         if (e.CommandName == "del")
         {
             int index = int.Parse(e.CommandArgument.ToString());
             // int key = Convert.ToInt32(gvDept.DataKeys[index].Value.ToString());
             IncomeProjection estf = CommonBLL.GetIncomePro(index);
             CommonBLL.DeleteIncomePro(estf);
             BindGrid();
             success.Visible   = true;
             success.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>&times;</button> Record deleted successfully!!.";
             return;
         }
         if (e.CommandName == "edt")
         {
             hid.Value              = "Update";
             dvID.Visible           = false;
             btnSubmit.Text         = "Update";
             dvAdd.Visible          = true;
             dvRentalIncome.Visible = false;
             //GridViewRow row = gvDept.SelectedRow;
             int index             = int.Parse(e.CommandArgument.ToString());
             IncomeProjection estf = CommonBLL.GetIncomePro(index);
             txtID.Text = estf.ID.ToString();
             if (estf.IncomeTypeId.ToString() == forfeitedAsset || estf.IncomeTypeId.ToString() == rentalIncon)
             {
                 dvProperty.Visible        = true;
                 dvDetail.Visible          = false;
                 ddlProperty.SelectedValue = estf.PropertyID.Value.ToString();
             }
             else
             {
                 dvDetail.Visible   = true;
                 dvProperty.Visible = false;
                 txtDetail.Text     = estf.Details;
             }
             txtTot.Text = estf.Amount.ToString();
             ddlIncomeType.SelectedValue = estf.IncomeTypeId.ToString();
             ddlMonth.SelectedValue      = estf.Month.ToString();
         }
     }
     catch (Exception ex)
     {
         error.Visible   = true;
         error.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>&times;</button> An error occurred. kindly try again!!!";
         Utility.WriteError("Error: " + ex.InnerException);
     }
 }