Esempio n. 1
0
        public CommonResult<string> AddCyCompany(CyCompanyEntity entity, IDbTransaction trans = null)
        {
            try
            {
                return CyUserProvider.AddCyCompany(entity, trans);
            }
            catch (Exception)
            {

                throw;
            }
        }
Esempio n. 2
0
        public CommonResult<string> AddCyCompany(CyCompanyEntity entity, IDbTransaction trans = null)
        {
            var commonResult = new CommonResult<string>();
            const string sql = @"INSERT INTO [dbo].[CyCompany]
                                                   ([UserNo]
                                                   ,[CompanyName]
                                                   ,[Industry]
                                                   ,[ContactName]
                                                   ,[ContactPhone]
                                                   ,[ContactEmail]
                                                   ,[CompanyTel]
                                                   ,[CompanyFax]
                                                   ,[CompanyAddress]
                                                   ,[CompanyWebsite]
                                                   ,[CompanyProfile]
                                                   ,[CreateUserNo]
                                                   ,[CreateTime]
                                                   ,[UpdateUserNo]
                                                   ,[UpdateTime]
                                                   ,[DataStatus])
                                             VALUES
                                                   (@UserNo
                                                   ,@CompanyName
                                                   ,@Industry
                                                   ,@ContactName
                                                   ,@ContactPhone
                                                   ,@ContactEmail
                                                   ,@CompanyTel
                                                   ,@CompanyFax
                                                   ,@CompanyAddress
                                                   ,@CompanyWebsite
                                                   ,@CompanyProfile
                                                   ,@CreateUserNo
                                                   ,@CreateTime
                                                   ,@UpdateUserNo
                                                   ,@UpdateTime
                                                   ,@DataStatus)";
            if (trans == null)
            {
                using (var conn = DbHelper.CreateOpenConnection(DbConnectionStringConfig.CyMainDbConnectionStringName))
                {
                    try
                    {
                        var rows = conn.Execute(sql, entity);

                        commonResult.Success = true;
                        commonResult.Message = "执行成功";
                        commonResult.EffectRows = rows;
                    }
                    catch (Exception ex)
                    {
                        commonResult.Success = false;
                        commonResult.IsHappenEx = true;
                        commonResult.Message = "执行失败";
                        commonResult.ExMessage = ex.Message;
                        commonResult.ExData = ex;
                    }
                }
            }
            else
            {
                try
                {
                    var rows = trans.Connection.Execute(sql, entity, transaction: trans);

                    commonResult.Success = true;
                    commonResult.Message = "执行成功";
                    commonResult.EffectRows = rows;
                }
                catch (Exception ex)
                {
                    commonResult.Success = false;
                    commonResult.IsHappenEx = true;
                    commonResult.Message = "执行失败";
                    commonResult.ExMessage = ex.Message;
                    commonResult.ExData = ex;
                }
            }
            return commonResult;
        }