Beispiel #1
0
        public SigmaResultType AddCompany(TypeCompany objCompany)
        {
            TransactionScope scope = null;
            SigmaResultType result = new SigmaResultType();

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

            List<SqlParameter> paramList = new List<SqlParameter>();
            paramList.Add(new SqlParameter("@Name", objCompany.Name));
            paramList.Add(new SqlParameter("@IsClient", objCompany.IsClient));
            paramList.Add(new SqlParameter("@Address", objCompany.Address));
            paramList.Add(new SqlParameter("@ContactName", objCompany.ContactName));
            paramList.Add(new SqlParameter("@ContactPhone", objCompany.ContactPhone));
            paramList.Add(new SqlParameter("@ContactFax", objCompany.ContactFax));
            paramList.Add(new SqlParameter("@ContactEmail", objCompany.ContactEmail));
            paramList.Add(new SqlParameter("@ContractTypeCode", objCompany.ContractTypeCode));
            paramList.Add(new SqlParameter("@CompanyTypeCode", objCompany.CompanyTypeCode));
            paramList.Add(new SqlParameter("@LogoFilePath", objCompany.LogoFilePath));
            paramList.Add(new SqlParameter("@CreatedBy", objCompany.CreatedBy));
            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_AddCompany", paramList.ToArray());
                result.IsSuccessful = true;
                result.ScalarValue = (int)outParam.Value;
                scope.Complete();

            }

            return result;
        }
 public SigmaResultType AddCompany(TypeCompany objCompany)
 {
     SigmaResultType result = new SigmaResultType();
     try
     {
         CompanyMgr companyMgr = new CompanyMgr();
         result = companyMgr.AddCompany(objCompany);
         return result;
     }
     catch (Exception ex)
     {
         // Log Exception
         ExceptionHelper.logException(ex);
         result.IsSuccessful = false;
         result.ErrorMessage = ex.Message;
         return result;
     }
 }
Beispiel #3
0
        public SigmaResultType UpdateCompany(TypeCompany objCompany)
        {
            TransactionScope scope = null;
            SigmaResultType result = new SigmaResultType();

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

            List<SqlParameter> paramList = new List<SqlParameter>();
            paramList.Add(new SqlParameter("@CompanyId", objCompany.CompanyId));
            paramList.Add(new SqlParameter("@Name", objCompany.Name));
            paramList.Add(new SqlParameter("@IsClient", objCompany.IsClient));
            paramList.Add(new SqlParameter("@Address", objCompany.Address));
            paramList.Add(new SqlParameter("@ContactName", objCompany.ContactName));
            paramList.Add(new SqlParameter("@ContactPhone", objCompany.ContactPhone));
            paramList.Add(new SqlParameter("@ContactFax", objCompany.ContactFax));
            paramList.Add(new SqlParameter("@ContactEmail", objCompany.ContactEmail));
            paramList.Add(new SqlParameter("@ContractTypeCode", objCompany.ContractTypeCode));
            paramList.Add(new SqlParameter("@CompanyTypeCode", objCompany.CompanyTypeCode));
            paramList.Add(new SqlParameter("@LogoFilePath", objCompany.LogoFilePath));
            paramList.Add(new SqlParameter("@UpdatedBy", objCompany.UpdatedBy));

            using (scope = new TransactionScope(TransactionScopeOption.Required))
            {
                result.AffectedRow = SqlHelper.ExecuteNonQuery(connStr, "usp_UpdateCompany", paramList.ToArray());
                result.IsSuccessful = true;
                scope.Complete();

            }

            return result;
        }
Beispiel #4
0
        public SigmaResultType RemoveCompany(TypeCompany objCompany)
        {
            SigmaResultType result = new SigmaResultType();
            TransactionScope scope = null;

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

            // Compose parameters
            SqlParameter[] parameters = new SqlParameter[] {
                    new SqlParameter("@companyId", objCompany.CompanyId)
                };

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

            return result;
        }