예제 #1
0
    public string InsertSolutionType(ClsSolutionType data)
    {
        string errMsg = "";
        PuroTouchSQLDataContext puroTouchContext = new PuroTouchSQLDataContext();

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



            puroTouchContext.GetTable <ClsSolutionType>().InsertOnSubmit(oNewRow);
            // Submit the changes to the database.
            puroTouchContext.SubmitChanges();
        }
        catch (Exception ex)
        {
            errMsg = ex.Message.ToString();
        }
        return(errMsg);
    }
예제 #2
0
    public string UpdateSolutionType(ClsSolutionType data)
    {
        string errMsg = "";
        PuroTouchSQLDataContext puroTouchContext = new PuroTouchSQLDataContext();

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

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

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