Пример #1
0
    public string InsertEDISolution(ClsEDISolution data)
    {
        string errMsg = "";
        PuroTouchSQLDataContext puroTouchContext = new PuroTouchSQLDataContext();

        try
        {
            tblEDISolution oNewRow = new tblEDISolution()
            {
                Solution  = data.Solution,
                CreatedBy = data.CreatedBy,
                CreatedOn = (DateTime?)data.CreatedOn,
                //UpdatedBy = data.UpdatedBy,
                //UpdatedOn = (DateTime?)data.UpdatedOn,
                ActiveFlag = data.ActiveFlag
            };



            puroTouchContext.GetTable <tblEDISolution>().InsertOnSubmit(oNewRow);
            // Submit the changes to the database.
            puroTouchContext.SubmitChanges();
            //newID = oNewRow.idTaskType;
        }
        catch (Exception ex)
        {
            errMsg = ex.Message.ToString();
        }
        return(errMsg);
    }
Пример #2
0
    private ClsEDISolution populateObj(UserControl userControl)
    {
        ClsEDISolution oRow = new ClsEDISolution();


        oRow.Solution = (userControl.FindControl("txtSolution") as RadTextBox).Text;

        oRow.ActiveFlag = (userControl.FindControl("ActiveFlag") as RadButton).Checked;


        oRow.UpdatedBy = (string)(Session["userName"]);
        oRow.UpdatedOn = Convert.ToDateTime(DateTime.Now);
        return(oRow);
    }
Пример #3
0
 protected void rgGrid_UpdateCommand(object sender, GridCommandEventArgs e)
 {
     try
     {
         UserControl    userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);
         Label          errorMsg    = (Label)userControl.FindControl("lblErrorMessage");
         ClsEDISolution oRow        = populateObj(userControl);
         oRow.idSolution = Convert.ToInt16((userControl.FindControl("idSolution") as Label).Text);
         string updateMsg = "";
         if (IsValid)
         {
             if (oRow != null)
             {
                 updateMsg = cls.UpdateEDISolution(oRow);
                 if (updateMsg == "")
                 {
                     pnlsuccess.Visible = true;
                     lblSuccess.Text    = "Successfully updated information for " + "'" + oRow.Solution + "'";
                 }
                 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;
     }
 }
Пример #4
0
 protected void rgGrid_InsertCommand(object sender, GridCommandEventArgs e)
 {
     try
     {
         UserControl    userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);
         Label          errorMsg    = (Label)userControl.FindControl("lblErrorMessage");
         ClsEDISolution oRow        = populateObj(userControl);
         string         insertMsg   = "";
         if (IsValid)
         {
             if (oRow != null)
             {
                 insertMsg = cls.InsertEDISolution(oRow);
                 if (insertMsg == "")
                 {
                     pnlsuccess.Visible = true;
                     lblSuccess.Text    = "Successfully Added New Record " + oRow.Solution;
                 }
                 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;
     }
 }
Пример #5
0
    public string UpdateEDISolution(ClsEDISolution data)
    {
        string errMsg = "";
        PuroTouchSQLDataContext puroTouchContext = new PuroTouchSQLDataContext();

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

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

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