Пример #1
0
        public bool InsertCompanyProfile(b2bCompanyProfile model)
        {
            #region set default
            model.RowFlag      = 2;
            model.RowVersion   = 1;
            model.CreatedBy    = "sa";
            model.ModifiedBy   = "sa";
            model.ModifiedDate = DateTimeNow;
            model.CreatedDate  = DateTimeNow;
            #endregion

            qDB.b2bCompanyProfiles.InsertOnSubmit(model);
            qDB.SubmitChanges();
            IsResult = true;
            return(IsResult);
        }
Пример #2
0
        public bool InsertCompany(Ouikum.Common.Register model)
        {
            b2bCompany        data        = new b2bCompany();
            b2bCompanyProfile compProfile = new b2bCompanyProfile();

            if (model.ServiceType < 1 || model.ServiceType == null)
            {
                model.ServiceType = 3;
            }

            #region set b2bCompany
            if (model.CompLevel == 0)
            {
                model.CompLevel = 1;
            }
            data.MemberID = model.MemberID;
            data.emCompID = model.emCompID;
            if (model.ServiceType > 0)
            {
                data.CompCode = GenCompCode((int)model.ServiceType, (int)model.emCompID).ToString();
            }
            else
            {
                data.CompCode = GenCompCode(2, (int)model.emCompID).ToString();
            }
            data.CompLevel = model.CompLevel;
            if (model.CompLevel == 3)
            {
                data.ExpireDate = model.ExpireDate;
            }
            data.CompWebsiteTemplate = 0;
            data.DisplayName         = model.DisplayName.Trim();
            data.ContactFirstName    = model.FirstName_register.Trim();
            data.ContactLastName     = model.LastName.Trim();
            data.ServiceType         = DataManager.ConvertToByte(model.ServiceType);
            data.CompName            = model.CompName.Trim();
            data.BizTypeID           = model.BizTypeID;
            data.CompCountryID       = model.CountryID;
            data.CompProvinceID      = model.ProvinceID;
            data.CompDistrictID      = model.DistrictID;
            data.CompPhone           = model.Phone;
            data.ContactCountryID    = model.CountryID;
            data.ContactProvinceID   = model.ProvinceID;
            data.ContactDistrictID   = model.DistrictID;


            data.ContactEmail      = model.Emails.Trim();
            data.ContactPhone      = model.Phone;
            data.FactoryCountryID  = model.CountryID;
            data.FactoryProvinceID = model.ProvinceID;
            data.FactoryDistrictID = model.DistrictID;
            data.FactoryPhone      = model.Phone;
            data.IsShow            = true;
            data.CompPostalCode    = model.PostalCode;
            data.ContactPostalCode = model.PostalCode;
            data.FactoryPostalCode = model.PostalCode;
            data.CompFax           = model.Fax;
            data.ContactFax        = model.Fax;
            data.FactoryFax        = model.Fax;
            data.ProductCount      = 0;
            data.ViewCount         = 0;
            data.BuyLeadCount      = 0;
            data.isNotification    = true;
            data.IsTrust           = DataManager.ConvertToBool(DataManager.ConvertToInteger(model.IsTrust));
            data.IsSME             = DataManager.ConvertToBool(DataManager.ConvertToInteger(model.IsSME));
            if (!string.IsNullOrEmpty(model.BizTypeOther) && model.BizTypeID == 13)
            {
                data.BizTypeOther = model.BizTypeOther.Trim();
            }
            #endregion

            #region set b2bCompanyProfile
            compProfile.emCompProfileID = model.emCompProfileID;
            compProfile.CompBizType     = (byte)model.BizTypeID;
            compProfile.CompName        = model.CompName.Trim();
            compProfile.AddrLine1       = model.AddrLine1;
            compProfile.CountryID       = model.CountryID;
            compProfile.ProvinceID      = model.ProvinceID;
            compProfile.DistrictID      = model.DistrictID;
            compProfile.PostalCode      = model.PostalCode;
            compProfile.IsShow          = true;
            if (!string.IsNullOrEmpty(compProfile.CompBizTypeOther) && compProfile.CompBizType == 13)
            {
                compProfile.CompBizTypeOther = model.BizTypeOther.Trim();
            }
            #endregion

            using (var trans = new TransactionScope())
            {
                InsertCompany(data);

                compProfile.CompID = data.CompID;
                InsertCompanyProfile(compProfile);
                UpdateCompanySignIn(data.CompID, false);

                #region Set CompCode ที่ได้ เข้า Register Model กลับไป
                model.CompCode = data.CompCode;
                #endregion

                trans.Complete();
                IsResult = true;
            }

            return(IsResult);
        }