Exemple #1
0
        public void ImportAddressFromCustomer()
        {
            //Subcontract-->Project-->IsInstallTo->Contact and Customer

            var subcontract = new MySubContract(Value.SubContractID);
            var msc         = new MySalesJobMasterListCustomer(subcontract.Value.JobID);

            msc.SetInstallTo();

            if (msc.CustomerID < 1000)
            {
                Result = "Request Failed, No Install to Customer Selected.";
            }
            else
            {
                var myCustomer = new MyCustomer(msc.CustomerID);
                var myContact  = new MyCustomerContact(msc.ContactID);

                string addr = myCustomer.Value.ADDR_1;
                if (!Convert.IsDBNull(myCustomer.Value.ADDR_2))
                {
                    addr = addr + " " + myCustomer.Value.ADDR_2;
                }

                Value.Address = addr;

                Value.City       = myCustomer.Value.CITY;
                Value.Postcode   = myCustomer.Value.ZIPCODE;
                Value.Province   = myCustomer.Value.STATE;
                Value.ShipToName = myCustomer.Value.NAME;

                string attenName = MyConvert.ConvertToString(myContact.Value.CONTACT_HONORIFIC) + " ";
                attenName += MyConvert.ConvertToString(myContact.Value.CONTACT_FIRST_NAME) + " ";
                attenName += MyConvert.ConvertToString(myContact.Value.CONTACT_LAST_NAME);

                Value.AttnName  = attenName.Trim();
                Value.AttnPhone = MyConvert.ConvertToString(myContact.Value.CONTACT_PHONE);

                _db.Entry(Value).State = EntityState.Modified;
                _db.SaveChanges();

                Result = "ok";
            }
        }
        public void ImportAddressFromCustomer(string importCustomerType)
        {
            //Subcontract-->Project-->IsInstallTo->Contact and Customer
            var workorder = new MyWorkorder(Value.WoID);
            var msc       = new MySalesJobMasterListCustomer(workorder.Value.jobID);

            if (importCustomerType == "InstallTo")
            {
                msc.SetInstallTo();
            }

            if (importCustomerType == "QuoteTo")
            {
                msc.SetQuoteTo();
            }

            if (importCustomerType == "BillTo")
            {
                msc.SetBillTo();
            }

            var mc = new MyCustomer(msc.CustomerID);

            _customer = mc.Value;
            var mcc = new MyCustomerContact(msc.ContactID);

            _contact = mcc.Value;


            if (_customer != null)
            {
                string addr = _customer.ADDR_1;
                if (!Convert.IsDBNull(_customer.ADDR_2))
                {
                    addr = addr + " " + _customer.ADDR_2;
                }

                Value.Address = addr;

                Value.City       = _customer.CITY;
                Value.Postcode   = _customer.ZIPCODE;
                Value.Province   = _customer.STATE;
                Value.ShipToName = _customer.NAME;

                string attenName = MyConvert.ConvertToString(_contact.CONTACT_HONORIFIC) + " ";
                attenName += MyConvert.ConvertToString(_contact.CONTACT_FIRST_NAME) + " ";
                attenName += MyConvert.ConvertToString(_contact.CONTACT_LAST_NAME);

                Value.AttnName  = attenName.Trim();
                Value.AttnPhone = MyConvert.ConvertToString(_contact.CONTACT_PHONE);


                //For Delivery Note

                Value.DeliveryDate = DateTime.Today;

                Value.WorkorderNumber = workorder.Value.WorkorderNumber;


                var emp = new FsEmployee(Convert.ToInt32(workorder.Value.Sales));

                Value.AeName  = emp.NickName;
                Value.AePhone = emp.GetCompanyPhoneExtension();


                Value.InvoiceNumber = workorder.GetInvoices();

                Value.NoteTypeID = 0;


                _db.Entry(Value).State = EntityState.Modified;
                _db.SaveChanges();

                Result = "ok";
            }
            else
            {
                Result = "Could not find the specified Customer.";
            }
        }