public void InsertNewContact(int customerID) { var cc = new CUSTOMER_CONTACT { CUSTOMER_ROWID = customerID, CONTACT_ACTIVE = true, isAccountPayable = false, isProjectManager = false, isSiteContact = false, }; _db.CUSTOMER_CONTACT.Add(cc); _db.SaveChanges(); }
private void HandleAccountContact(int jobID, int jcID, string contactID, int customerRowID, string firstName, string lastName, string phone, string accountID, int type) { try { /* contact info */ int vContactID = CommonMethods.GetMISID(TableName.Customer_Contact, contactID, accountID, salesForceProjectID); if (vContactID == 0) { /* check if the contact is existent */ vContactID = CommonMethods.GetContactCompanyMISID(TableName.Customer_Contact, contactID, accountID); if (vContactID == 0) { /* add new contact */ FsCustomerContact cc = new FsCustomerContact(customerRowID); cc.InsertContact(); int contact_id = SqlCommon.GetNewlyInsertedRecordID(TableName.Customer_Contact); if (contact_id > 0) { CommonMethods.InsertToMISSalesForceMapping(TableName.Customer_Contact, contactID, contact_id.ToString(), accountID, salesForceProjectID); } vContactID = contact_id; } } /* update */ CUSTOMER_CONTACT customer_contact = _db.CUSTOMER_CONTACT.FirstOrDefault(x => x.CONTACT_ID == vContactID); if (customer_contact != null) { customer_contact.CONTACT_FIRST_NAME = firstName; customer_contact.CONTACT_LAST_NAME = lastName; customer_contact.CONTACT_PHONE = phone; _db.Entry(customer_contact).State = EntityState.Modified; _db.SaveChanges(); } UpdateSales_JobMasterList_Customer(jcID, jobID, vContactID, customerRowID, type); LogMethods.Log.Debug("HandleAccountContact:Debug:" + "Done"); } catch (Exception e) { LogMethods.Log.Error("HandleAccountContact:Error:" + e.Message); } }
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."; } }
public MyCustomerContact(int contactID) { Value = _db.CUSTOMER_CONTACT.Find(contactID); }