Пример #1
0
        public List <string> SaveGroups(List <Groups> groups)
        {
            List <string> ErrorMessage = new List <string>();


            DataTable dtCreateGroups = CollectionHelper.ConvertTo(groups, "MSNo,RefNo,Active,CreatedUser,UpdatedUser,MultiCity,Text_CloneGroupSNo,Text_UserTypeSNo,Text_PenaltyType");

            GroupBusiness groupBusiness = new GroupBusiness();

            if (!groupBusiness.ValidateBaseBusiness("Groups", dtCreateGroups, "SAVE"))
            {
                ErrorMessage = groupBusiness.ErrorMessage;
                return(ErrorMessage);
            }

            SqlParameter param = new SqlParameter();

            param.ParameterName = "@GroupsTable";
            param.SqlDbType     = System.Data.SqlDbType.Structured;
            param.Value         = dtCreateGroups;

            SqlParameter[] Parameters = { param };

            DataSet ds       = SqlHelper.ExecuteDataset(DMLConnectionString.WebConfigConnectionString, "CreateGroups", Parameters);
            int     ret      = Convert.ToInt32(ds.Tables[0].Rows[0]["ErrorNumber"]);
            int     groupSNo = Convert.ToInt32(ds.Tables[0].Rows[0]["GroupSNo"]);

            GroupBusiness.GroupSNo = groupSNo;
            if (ret > 0)
            {
                if (ret > 1000)
                {
                    string serverErrorMessage = groupBusiness.ReadServerErrorMessages(ret, "Groups");
                    if (!string.IsNullOrEmpty(serverErrorMessage))
                    {
                        ErrorMessage.Add(serverErrorMessage);
                    }
                }
                else
                {
                    //For DataBase Exceptions like 'Foreign Key refrence Errors' etc
                    string dataBaseExceptionMessage = groupBusiness.ReadServerErrorMessages(ret, groupBusiness.DatabaseExceptionFileName);
                    if (!string.IsNullOrEmpty(dataBaseExceptionMessage))
                    {
                        ErrorMessage.Add(dataBaseExceptionMessage);
                    }
                }
            }

            return(ErrorMessage);
        }
Пример #2
0
        public List <string> DeleteGroups(List <string> listID)
        {
            //validate Business Rule
            List <string> ErrorMessage  = new List <string>();
            GroupBusiness groupBusiness = new GroupBusiness();

            if (listID.Count > 1)
            {
                string RecordID = listID[0].ToString();
                string UserID   = listID[1].ToString();

                SqlParameter[] Parameters = { new SqlParameter("@SNo", Convert.ToInt32(RecordID)), new SqlParameter("@UserID", Convert.ToInt32(UserID)) };

                int ret = (int)SqlHelper.ExecuteScalar(DMLConnectionString.WebConfigConnectionString, "DeleteGroups", Parameters);
                if (ret > 0)
                {
                    if (ret > 1000)
                    {
                        string serverErrorMessage = groupBusiness.ReadServerErrorMessages(ret, "Groups");
                        if (!string.IsNullOrEmpty(serverErrorMessage))
                        {
                            ErrorMessage.Add(serverErrorMessage);
                        }
                    }
                    else
                    {
                        //For DataBase Exceptions like 'Foreign Key refrence Errors' etc
                        string dataBaseExceptionMessage = groupBusiness.ReadServerErrorMessages(ret, groupBusiness.DatabaseExceptionFileName);
                        if (!string.IsNullOrEmpty(dataBaseExceptionMessage))
                        {
                            ErrorMessage.Add(dataBaseExceptionMessage);
                        }
                    }
                }
            }
            else
            {
                //For DataBase Exceptions like 'Foreign Key refrence Errors' etc
                string dataBaseExceptionMessage = groupBusiness.ReadServerErrorMessages(9001, groupBusiness.DatabaseExceptionFileName);
                if (!string.IsNullOrEmpty(dataBaseExceptionMessage))
                {
                    ErrorMessage.Add(dataBaseExceptionMessage);
                }
                //Error
            }
            return(ErrorMessage);
        }