Exemplo n.º 1
0
 protected void rgGrid_InsertCommand(object sender, GridCommandEventArgs e)
 {
     try
     {
         UserControl    userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);
         Label          errorMsg    = (Label)userControl.FindControl("lblErrorMessage");
         ClsRequestType oRow        = populateObj(userControl);
         string         insertMsg   = "";
         if (IsValid)
         {
             if (oRow != null)
             {
                 insertMsg = cls.InsertRequestType(oRow);
                 if (insertMsg == "")
                 {
                     pnlsuccess.Visible = true;
                     lblSuccess.Text    = "Successfully Added New Record " + oRow.RequestType;
                 }
                 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;
     }
 }
Exemplo n.º 2
0
    public string UpdateRequestType(ClsRequestType data)
    {
        string errMsg = "";
        PuroTouchSQLDataContext puroTouchContext = new PuroTouchSQLDataContext();

        try
        {
            if (data.idRequestType > 0)
            {
                // Query the database for the row to be updated.
                var query =
                    from qdata in puroTouchContext.GetTable <tblRequestType>()
                    where qdata.idRequestType == data.idRequestType
                    select qdata;

                // Execute the query, and change the column values
                // you want to change.
                foreach (tblRequestType updRow in query)
                {
                    updRow.RequestType   = data.RequestType;
                    updRow.ActiveFlag    = data.ActiveFlag;
                    updRow.idRequestType = data.idRequestType;
                    updRow.UpdatedBy     = data.UpdatedBy;
                    updRow.UpdatedOn     = data.UpdatedOn;
                }

                // Submit the changes to the database.
                puroTouchContext.SubmitChanges();
            }
            else
            {
                errMsg = "There is No Request Type with ID = " + "'" + data.idRequestType + "'";
            }
        }
        catch (Exception ex)
        {
            errMsg = ex.Message.ToString();
        }
        return(errMsg);
    }