Ejemplo n.º 1
0
        public SigmaResultType UpdateProgressTypeMap(TypeProgressTypeMap objProgressTypeMap)
        {
            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("@ProgressTypeMapId", Utilities.ToInt32(objProgressTypeMap.ProgressTypeMapId.ToString().Trim())),
                new SqlParameter("@DisciplineCode", objProgressTypeMap.DisciplineCode.Trim()),
                new SqlParameter("@TaskCategoryId", Utilities.ToInt32(objProgressTypeMap.TaskCategoryId.ToString().Trim())),
                new SqlParameter("@TaskTypeId", Utilities.ToInt32(objProgressTypeMap.TaskTypeId.ToString().Trim())),
                new SqlParameter("@ProgressTypeId", Utilities.ToInt32(objProgressTypeMap.ProgressTypeId.ToString().Trim())),
                new SqlParameter("@UpdatedBy", userinfo.SigmaUserId.Trim())
            };

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

                scope.Complete();
            }

            return result;
        }
Ejemplo n.º 2
0
        public DataSet ListTaskType(TypeProgressTypeMap objProgressTypeMap)
        {
            // Get connection string
            string connStr = ConnStrHelper.getDbConnString();

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

            // Get Data
            DataSet ds = SqlHelper.ExecuteDataset(connStr, "usp_ListTaskTypeNotAssignProgressTypeMap", parameters);

            // return
            return ds;
        }
Ejemplo n.º 3
0
        //public SigmaResultType GetProgressTypeMap(string progressTypeMapId)
        //{
        //    SigmaResultType result = new SigmaResultType();
        //    // Get connection string
        //    string connStr = ConnStrHelper.getDbConnString();
        //    // Compose parameters
        //    SqlParameter[] parameters = new SqlParameter[] {
        //            new SqlParameter("@ProgressTypeMapId", progressTypeMapId)
        //        };
        //    // Get Data
        //    DataSet ds = SqlHelper.ExecuteDataset(connStr, "usp_GetProgressTypeMap", parameters);
        //    // Convert to REST/JSON String
        //    result.JsonDataSet = JsonHelper.convertDataTableToJson(ds.Tables[0]);
        //    result.AffectedRow = 1;
        //    result.IsSuccessful = true;
        //    // return
        //    return result;
        //}
        //public SigmaResultType ListProgressTypeMap(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_ListProgressTypeMap", 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 AddProgressTypeMap(TypeProgressTypeMap objProgressTypeMap)
        {
            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("@DisciplineCode", objProgressTypeMap.DisciplineCode.Trim()));
            paramList.Add(new SqlParameter("@TaskCategoryId", Utilities.ToInt32(objProgressTypeMap.TaskCategoryId.ToString().Trim())));
            if (objProgressTypeMap.TaskTypeId > 0)
            {
                paramList.Add(new SqlParameter("@TaskTypeId", Utilities.ToInt32(objProgressTypeMap.TaskTypeId.ToString().Trim())));
            }
            else
            {
                paramList.Add(new SqlParameter("@TaskTypeId", DBNull.Value));
            }
            paramList.Add(new SqlParameter("@ProgressTypeId", Utilities.ToInt32(objProgressTypeMap.ProgressTypeId.ToString().Trim())));
            paramList.Add(new SqlParameter("@CreatedBy", userinfo.SigmaUserId.Trim()));
            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_AddProgressTypeMap", paramList.ToArray());
                result.IsSuccessful = true;
                result.ScalarValue = (int)outParam.Value;

                scope.Complete();
            }

            return result;
        }
Ejemplo n.º 4
0
        //public SigmaResultType RemoveProgressTypeMap(TypeProgressTypeMap objProgressTypeMap)
        //{
        //    SigmaResultType result = new SigmaResultType();
        //    TransactionScope scope = null;
        //    // Get connection string
        //    string connStr = ConnStrHelper.getDbConnString();
        //    // Compose parameters
        //    SqlParameter[] parameters = new SqlParameter[] {
        //            new SqlParameter("@ProgressTypeMapId", objProgressTypeMap.ProgressTypeMapId)
        //        };
        //    using (scope = new TransactionScope(TransactionScopeOption.Required))
        //    {
        //        result.AffectedRow = SqlHelper.ExecuteNonQuery(connStr, "usp_RemoveProgressTypeMap", parameters);
        //        result.IsSuccessful = true;
        //        scope.Complete();
        //    }
        //    return result;
        //}
        //public SigmaResultType MultiProgressTypeMap(List<TypeProgressTypeMap> listObj)
        //{
        //    TransactionScope scope = null;
        //    SigmaResultType result = new SigmaResultType();
        //    // Get connection string
        //    string connStr = ConnStrHelper.getDbConnString();
        //    using (scope = new TransactionScope(TransactionScopeOption.RequiresNew))
        //    {
        //        foreach (TypeProgressTypeMap anObj in listObj)
        //        {
        //            switch (anObj.SigmaOperation)
        //            {
        //                case "C":
        //                    AddProgressTypeMap(anObj);
        //                    break;
        //                case "U":
        //                    UpdateProgressTypeMap(anObj);
        //                    break;
        //                case "D":
        //                    RemoveProgressTypeMap(anObj);
        //                    break;
        //            }
        //        }
        //        scope.Complete();
        //    }
        //    return result;
        //}
        public SigmaResultType AddProgressTypeMapInfo(TypeProgressTypeMap objProgressTypeMap)
        {
            TypeUserInfo userinfo = AuthMgr.GetUserInfo();

            DataSet taskTypeDataSet = null;
            List<TypeProgressTypeMap> progressTypeMapList = new List<TypeProgressTypeMap>(); ;
            TransactionScope scope = null;
            SigmaResultType result = new SigmaResultType();
            SigmaResultType resultProgressTypeMap = new SigmaResultType();

            using (scope = new TransactionScope(TransactionScopeOption.RequiresNew))
            {
                if (objProgressTypeMap.SigmaOperation == SigmaOperation.INSERT)
                {
                    resultProgressTypeMap = AddProgressTypeMap(objProgressTypeMap);
                    taskTypeDataSet = ListTaskType(objProgressTypeMap);

                    foreach (DataRow item in taskTypeDataSet.Tables[0].Rows)
                    {
                        TypeProgressTypeMap progressTypeMap = new TypeProgressTypeMap();
                        progressTypeMap.DisciplineCode = objProgressTypeMap.DisciplineCode;
                        progressTypeMap.TaskCategoryId = objProgressTypeMap.TaskCategoryId;
                        progressTypeMap.TaskTypeId = int.Parse(item["TaskTypeId"].ToString());
                        progressTypeMap.ProgressTypeId = objProgressTypeMap.ProgressTypeId;
                        progressTypeMap.CreatedBy = userinfo.SigmaUserId;
                        progressTypeMap.UpdatedBy = userinfo.SigmaUserId;
                        progressTypeMapList.Add(progressTypeMap);
                    }
                }
                else if (objProgressTypeMap.SigmaOperation == SigmaOperation.UPDATE)
                {
                    resultProgressTypeMap = UpdateProgressTypeMap(objProgressTypeMap);
                    taskTypeDataSet = ListTaskType(objProgressTypeMap);

                    foreach (DataRow item in taskTypeDataSet.Tables[0].Rows)
                    {
                        TypeProgressTypeMap progressTypeMap = new TypeProgressTypeMap();
                        progressTypeMap.SigmaOperation = SigmaOperation.INSERT;
                        progressTypeMap.DisciplineCode = objProgressTypeMap.DisciplineCode;
                        progressTypeMap.TaskCategoryId = objProgressTypeMap.TaskCategoryId;
                        progressTypeMap.TaskTypeId = int.Parse(item["TaskTypeId"].ToString());
                        progressTypeMap.ProgressTypeId = objProgressTypeMap.ProgressTypeId;
                        progressTypeMap.CreatedBy = userinfo.SigmaUserId;
                        progressTypeMap.UpdatedBy = userinfo.SigmaUserId;
                        progressTypeMapList.Add(progressTypeMap);
                    }
                }

                if (resultProgressTypeMap.IsSuccessful && progressTypeMapList.Count > 0)
                {
                    foreach (var item in progressTypeMapList)
                    {
                        switch (item.SigmaOperation)
                        {
                            case SigmaOperation.INSERT:
                                AddProgressTypeMap(item);
                                break;
                            case SigmaOperation.UPDATE:
                                UpdateProgressTypeMap(item);
                                break;
                        }
                    }
                }

                result.AffectedRow = resultProgressTypeMap.AffectedRow;
                result.ScalarValue = resultProgressTypeMap.ScalarValue;
                result.IsSuccessful = true;

                scope.Complete();
            }
            return result;
        }
Ejemplo n.º 5
0
        public SigmaResultType UpdateProgressTypeMap(TypeProgressTypeMap objProgressTypeMap)
        {
            SigmaResultType result = new SigmaResultType();

            try
            {
                ProgressTypeMgr progressTypeMgr = new ProgressTypeMgr();
                result = progressTypeMgr.AddProgressTypeMapInfo(objProgressTypeMap);
                return result;
            }
            catch (Exception ex)
            {
                // Log Exception
                ExceptionHelper.logException(ex);
                result.IsSuccessful = false;
                result.ErrorMessage = ex.Message;
                return result;
            }
        }