Exemple #1
0
 protected void rgGrid_UpdateCommand(object sender, GridCommandEventArgs e)
 {
     try
     {
         UserControl       userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);
         Label             errorMsg    = (Label)userControl.FindControl("lblErrorMessage");
         clsFreightAuditor oRow        = populateObj(userControl);
         oRow.idFreightAuditor = Convert.ToInt16((userControl.FindControl("lblVendorTypeID") as Label).Text);
         string updateMsg = "";
         if (IsValid)
         {
             if (oRow != null)
             {
                 updateMsg = SrvFreightAuditor.UpdateFreightAuditor(oRow);
                 if (updateMsg == "")
                 {
                     pnlsuccess.Visible = true;
                     lblSuccess.Text    = "Successfully updated information for " + "'" + oRow.idFreightAuditor + "'";
                 }
                 else
                 {
                     errorMsg.Visible = true;
                     errorMsg.Text    = updateMsg;
                     e.Canceled       = true;
                 }
             }
         }
         else
         {
             // display error
             errorMsg.Visible = true;
             errorMsg.Text    = "Please enter Required fields";
             e.Canceled       = true;
         }
     }
     catch (Exception ex)
     {
         pnlDanger.Visible = true;
         lblDanger.Text    = ex.Message.ToString();
         e.Canceled        = true;
     }
 }
Exemple #2
0
 protected void rgGrid_InsertCommand(object sender, GridCommandEventArgs e)
 {
     try
     {
         UserControl       userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);
         Label             errorMsg    = (Label)userControl.FindControl("lblErrorMessage");
         clsFreightAuditor oRow        = populateObj(userControl);
         string            insertMsg   = "";
         if (IsValid)
         {
             if (oRow != null)
             {
                 insertMsg = SrvFreightAuditor.UpdateFreightAuditor(oRow);
                 if (insertMsg == "")
                 {
                     pnlsuccess.Visible = true;
                     lblSuccess.Text    = "Successfully Added New Record " + oRow.idFreightAuditor;
                 }
                 else
                 {
                     errorMsg.Visible = true;
                     errorMsg.Text    = insertMsg;
                     e.Canceled       = true;
                 }
             }
         }
         else
         {
             // display error
             errorMsg.Visible = true;
             errorMsg.Text    = "Please enter Required fields";
             e.Canceled       = true;
         }
     }
     catch (Exception ex)
     {
         pnlDanger.Visible = true;
         lblDanger.Text    = ex.Message.ToString();
         e.Canceled        = true;
     }
 }