Example #1
0
    public string InsertTaskType(ClsTaskType data)
    {
        string errMsg = "";
        PuroTouchSQLDataContext puroTouchContext = new PuroTouchSQLDataContext();

        try
        {
            tblTaskType oNewRow = new tblTaskType()
            {
                //idTaskType = (Int32)data.idTaskType,
                TaskType  = data.TaskType,
                CreatedBy = data.CreatedBy,
                CreatedOn = (DateTime?)data.CreatedOn,
                //UpdatedBy = data.UpdatedBy,
                //UpdatedOn = (DateTime?)data.UpdatedOn,
                idOnboardingPhase = data.idOnboardingPhase,
                ActiveFlag        = data.ActiveFlag
            };



            puroTouchContext.GetTable <tblTaskType>().InsertOnSubmit(oNewRow);
            // Submit the changes to the database.
            puroTouchContext.SubmitChanges();
            //newID = oNewRow.idTaskType;
        }
        catch (Exception ex)
        {
            errMsg = ex.Message.ToString();
        }
        return(errMsg);
    }
Example #2
0
    private ClsTaskType populateObj(UserControl userControl)
    {
        ClsTaskType oTaskType = new ClsTaskType();

        //oTaskType.idTaskType = Convert.ToInt16((userControl.FindControl("lblTaskTypeID") as Label).Text);

        oTaskType.TaskType   = (userControl.FindControl("txtTaskType") as RadTextBox).Text;
        oTaskType.ActiveFlag = (userControl.FindControl("ActiveFlag") as RadButton).Checked;


        oTaskType.UpdatedBy = (string)(Session["userName"]);
        oTaskType.UpdatedOn = Convert.ToDateTime(DateTime.Now);
        RadComboBox cbxOnboardingPhase = (userControl.FindControl("cbxOnboardingPhase") as RadComboBox);

        oTaskType.idOnboardingPhase = Convert.ToInt16(cbxOnboardingPhase.SelectedValue);
        return(oTaskType);
    }
Example #3
0
 protected void rgTaskType_UpdateCommand(object sender, GridCommandEventArgs e)
 {
     try
     {
         UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);
         Label       errorMsg    = (Label)userControl.FindControl("lblErrorMessage");
         ClsTaskType oTaskType   = populateObj(userControl);
         oTaskType.idTaskType = Convert.ToInt16((userControl.FindControl("lblTaskTypeID") as Label).Text);
         RadComboBox cbxOnboardingPhase = (userControl.FindControl("cbxOnboardingPhase") as RadComboBox);
         oTaskType.idOnboardingPhase = Convert.ToInt16(cbxOnboardingPhase.SelectedValue);
         string updateMsg = "";
         if (IsValid)
         {
             if (oTaskType != null)
             {
                 updateMsg = tt.UpdateTaskType(oTaskType);
                 if (updateMsg == "")
                 {
                     pnlsuccess.Visible = true;
                     lblSuccess.Text    = "Successfully updated Task Type " + "'" + oTaskType.TaskType + "'";
                 }
                 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;
     }
 }
Example #4
0
 protected void rgTaskType_InsertCommand(object sender, GridCommandEventArgs e)
 {
     try
     {
         UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);
         Label       errorMsg    = (Label)userControl.FindControl("lblErrorMessage");
         ClsTaskType oTaskType   = populateObj(userControl);
         string      insertMsg   = "";
         if (IsValid)
         {
             if (oTaskType != null)
             {
                 insertMsg = tt.InsertTaskType(oTaskType);
                 if (insertMsg == "")
                 {
                     pnlsuccess.Visible = true;
                     lblSuccess.Text    = "Successfully Added New Task Type " + oTaskType.TaskType;
                 }
                 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;
     }
 }
Example #5
0
    public string UpdateTaskType(ClsTaskType data)
    {
        string errMsg = "";
        PuroTouchSQLDataContext puroTouchContext = new PuroTouchSQLDataContext();

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

                // Execute the query, and change the column values
                // you want to change.
                foreach (tblTaskType updRow in query)
                {
                    updRow.TaskType          = data.TaskType;
                    updRow.ActiveFlag        = data.ActiveFlag;
                    updRow.idTaskType        = data.idTaskType;
                    updRow.UpdatedBy         = data.UpdatedBy;
                    updRow.UpdatedOn         = data.UpdatedOn;
                    updRow.idOnboardingPhase = data.idOnboardingPhase;
                }

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