Exemple #1
0
        public void Update(Interface.IcompanyCustomer companyCustomer)
        {
            using (LMCdatabaseDataContext dbContext = new LMCdatabaseDataContext(this.connectionString))
            {
                var companyCustomerUpdateing = dbContext.tblCompanyCustomers.SingleOrDefault(
                    x => x.companyCustomersNo == companyCustomer.CompanyCustomersNo);
                if (companyCustomer.Address != string.Empty)
                {
                    companyCustomerUpdateing._address = companyCustomer.Address;
                }

                companyCustomerUpdateing.active = companyCustomer.Active;

                companyCustomerUpdateing.altPhoneNo = companyCustomer.AltPhoneNo;

                if (companyCustomer.ContactPerson != string.Empty)
                {
                    companyCustomerUpdateing.companyContactPerson = companyCustomer.ContactPerson;
                }

                if (companyCustomer.Name != string.Empty)
                {
                    companyCustomerUpdateing.companyName = companyCustomer.Name;
                }

                if (companyCustomer.CvrNo != -1)
                {
                    companyCustomerUpdateing.cvrNo = companyCustomer.CvrNo;
                }

                companyCustomerUpdateing.email = companyCustomer.Email;

                if (companyCustomer.PhoneNo != string.Empty)
                {
                    companyCustomerUpdateing.phoneNo = companyCustomer.PhoneNo;
                }

                if (companyCustomer.PostNo.Id != -1)
                {
                    companyCustomerUpdateing.postNo = companyCustomer.PostNo.Id;
                }

                dbContext.SubmitChanges();
            }
        }
Exemple #2
0
        public void Add(Interface.IcompanyCustomer companyCustomer)
        {
            using (LMCdatabaseDataContext dbContext = new LMCdatabaseDataContext(this.connectionString))
            {
                var newCompanyCustomer = new tblCompanyCustomer()
                {
                    _address             = companyCustomer.Address,
                    active               = companyCustomer.Active,
                    altPhoneNo           = companyCustomer.AltPhoneNo,
                    companyContactPerson = companyCustomer.ContactPerson,
                    companyCustomersNo   = companyCustomer.CompanyCustomersNo,
                    companyName          = companyCustomer.Name,
                    cvrNo   = companyCustomer.CvrNo,
                    email   = companyCustomer.Email,
                    phoneNo = companyCustomer.PhoneNo,
                    postNo  = companyCustomer.PostNo.Id,
                };

                dbContext.tblCompanyCustomers.InsertOnSubmit(newCompanyCustomer);
                dbContext.SubmitChanges();
            }
        }