Exemple #1
0
        public SigmaResultType UpdateCWP(TypeCWP objCWP)
        {
            TypeUserInfo userinfo = AuthMgr.GetUserInfo();

            TransactionScope scope = null;
            SigmaResultType result = new SigmaResultType();

            // Get connection string
            string connStr = ConnStrHelper.getDbConnString();

            // Compose parameters
            SqlParameter[] parameters = new SqlParameter[] {
                new SqlParameter("@CwpId", Utilities.ToInt32(objCWP.CwpId.ToString().Trim())),
                new SqlParameter("@CwaId", Utilities.ToInt32(objCWP.CwaId.ToString().Trim())),
                new SqlParameter("@CwpName", objCWP.CwpName.Trim()),
                new SqlParameter("@DisciplineCode", objCWP.DisciplineCode.Trim()),
                new SqlParameter("@Description", objCWP.Description.Trim()),
                new SqlParameter("@UpdatedBy", userinfo.SigmaUserId.Trim()),
                new SqlParameter("@ProjectId", userinfo.CurrentProjectId)
            };

            using (scope = new TransactionScope(TransactionScopeOption.Required))
            {
                result.AffectedRow = SqlHelper.ExecuteNonQuery(connStr, "usp_UpdateCWP", parameters);
                result.IsSuccessful = true;

                scope.Complete();
            }

            return result;
        }
Exemple #2
0
        //public SigmaResultType ListCWP(string offset, string max, string s_option, string s_key, string o_option, string o_desc)
        //{
        //    SigmaResultType result = new SigmaResultType();
        //    // Get connection string
        //    string connStr = ConnStrHelper.getDbConnString();
        //    // Compose parameters
        //    List<SqlParameter> parameters = new List<SqlParameter>();
        //    parameters.Add(new SqlParameter("@MaxNumRows", (max == null ? 1000 : int.Parse(max))));
        //    parameters.Add(new SqlParameter("@RetrieveOffset", (offset == null ? 0 : int.Parse(offset))));
        //    parameters.Add(new SqlParameter("@SortColumn", o_option));
        //    parameters.Add(new SqlParameter("@SortOrder", (o_desc != null ? o_desc.ToUpper() : null)));
        //    // Get Data
        //    DataSet ds = SqlHelper.ExecuteDataset(connStr, "usp_ListCWP", parameters.ToArray());
        //    // Convert to REST/JSON String
        //    result.JsonDataSet = JsonHelper.convertDataTableToJson(ds.Tables[0]);
        //    result.AffectedRow = (int)ds.Tables[1].Rows[0][0]; // returning count
        //    result.ScalarValue = (int)ds.Tables[2].Rows[0][0]; // total count by search
        //    result.IsSuccessful = true;
        //    // return
        //    return result;
        //}
        public SigmaResultType AddCWP(TypeCWP objCWP)
        {
            TypeUserInfo userinfo = AuthMgr.GetUserInfo();

            TransactionScope scope = null;
            SigmaResultType result = new SigmaResultType();

            // Get connection string
            string connStr = ConnStrHelper.getDbConnString();

            List<SqlParameter> paramList = new List<SqlParameter>();
            paramList.Add(new SqlParameter("@CwaId", Utilities.ToInt32(objCWP.CwaId.ToString().Trim())));
            paramList.Add(new SqlParameter("@CwpName", objCWP.CwpName.Trim()));
            paramList.Add(new SqlParameter("@DisciplineCode", objCWP.DisciplineCode.Trim()));
            paramList.Add(new SqlParameter("@Description", objCWP.Description.Trim()));
            paramList.Add(new SqlParameter("@CreatedBy", userinfo.SigmaUserId.Trim()));
            paramList.Add(new SqlParameter("@ProjectId", userinfo.CurrentProjectId));
            SqlParameter outParam = new SqlParameter("@NewId", SqlDbType.Int);
            outParam.Direction = ParameterDirection.Output;
            paramList.Add(outParam);

            using (scope = new TransactionScope(TransactionScopeOption.Required))
            {
                result.AffectedRow = SqlHelper.ExecuteNonQuery(connStr, CommandType.StoredProcedure, "usp_AddCWP", paramList.ToArray());
                result.IsSuccessful = true;
                result.ScalarValue = (int)outParam.Value;

                scope.Complete();
            }

            return result;
        }
Exemple #3
0
        public SigmaResultType RemoveCWP(TypeCWP objCWP)
        {
            SigmaResultType result = new SigmaResultType();
            TransactionScope scope = null;

            // Get connection string
            string connStr = ConnStrHelper.getDbConnString();

            // Compose parameters
            SqlParameter[] parameters = new SqlParameter[] {
                new SqlParameter("@CwpId", Utilities.ToInt32(objCWP.CwpId.ToString().Trim()))
            };

            using (scope = new TransactionScope(TransactionScopeOption.Required))
            {
                result.AffectedRow = SqlHelper.ExecuteNonQuery(connStr, "usp_RemoveCWP", parameters);
                result.IsSuccessful = true;
                scope.Complete();
            }

            return result;
        }
        //public SigmaResultType ListCWP()
        //{
        //    SigmaResultType result = new SigmaResultType();
        //    try
        //    {
        //        var queryStr = WebOperationContext.Current.IncomingRequest.UriTemplateMatch.QueryParameters;
        //        string max = queryStr["max"];
        //        string offset = queryStr["offset"];
        //        string s_option = queryStr["s_option"];
        //        string s_key = queryStr["s_key"];
        //        string o_option = queryStr["o_option"];
        //        string o_desc = queryStr["o_desc"];
        //        CWAMgr CWAMgr = new CWAMgr();
        //        result = CWAMgr.ListCWP(offset, max, s_option, s_key, o_option, o_desc);
        //        return result;
        //    }
        //    catch (Exception ex)
        //    {
        //        // Log Exception
        //        ExceptionHelper.logException(ex);
        //        result.IsSuccessful = false;
        //        result.ErrorMessage = ex.Message;
        //        return result;
        //    }
        //}
        //public SigmaResultType AddCWP(TypeCWP objCWP)
        //{
        //    SigmaResultType result = new SigmaResultType();
        //    try
        //    {
        //        CWAMgr CWAMgr = new CWAMgr();
        //        result = CWAMgr.AddCWP(objCWP);
        //        return result;
        //    }
        //    catch (Exception ex)
        //    {
        //        // Log Exception
        //        ExceptionHelper.logException(ex);
        //        result.IsSuccessful = false;
        //        result.ErrorMessage = ex.Message;
        //        return result;
        //    }
        //}
        public SigmaResultType UpdateCWP(TypeCWP objCWP)
        {
            SigmaResultType result = new SigmaResultType();

            try
            {
                CWAMgr CWAMgr = new CWAMgr();
                result = CWAMgr.UpdateCWP(objCWP);
                return result;
            }
            catch (Exception ex)
            {
                // Log Exception
                ExceptionHelper.logException(ex);
                result.IsSuccessful = false;
                result.ErrorMessage = ex.Message;
                return result;
            }
        }