private void GetClientResponse(IAsyncResult result) { try { Result = ((IClientService)result.AsyncState).EndGetClient(result); } catch (Exception ex) { Error = ex; } finally { service.Close(); service = null; } // Execute Last Caliburn.Micro.Execute.OnUIThread(() => Completed(this, new ResultCompletionEventArgs())); }
private IAcctCustomer ClientMapTo(Client client) { AcctCustomer acctClient = new AcctCustomer(); acctClient.Name = client.ClientName; acctClient.CompanyName = client.ClientName; acctClient.AccountNumber = client.ClientId.ToString(); acctClient.OpenBalance = 0.00d; acctClient.OpenBalanceDate = DateTime.Now; // Terms acctClient.Term = new AcctItemInfo(); acctClient.Term.FullName = client.TermId.ToString(); //Address // Quickbooks API Issues with Contacts, Incomplete API //Contacts if (client.Contacts.Count > 0) { // Set Phone Numbers to the first contact added. Contact contactFirst = client.Contacts.FirstOrDefault(); if (contactFirst != null) { if (contactFirst.PrimaryPhone != null) { acctClient.Phone = contactFirst.PrimaryPhone; if (contactFirst.PrimaryEmail != null) acctClient.Email = contactFirst.PrimaryEmail; acctClient.Contact = contactFirst.FirstName + " " + contactFirst.LastName; } } //acctCustomer.Contacts = new List<AcctContact>(); //foreach (Contact contact in customer.Contacts) { // AcctContact acctContact = new AcctContact(); // acctContact.ContactName = contact.FirstName + " " + contact.LastName; // acctContact.FirstName = contact.FirstName; // acctContact.LastName = contact.LastName; // AcctAdditionalContact acctAddtContact = new AcctAdditionalContact(); // acctAddtContact.ContactName = acctContact.ContactName; // acctContact.AdditionalContactsList.Add(acctAddtContact); // acctCustomer.Contacts.Add(acctContact); //} } return acctClient; }
public SaveClientRequest(Client client) { this.client = client; }
public Client GetClient(int id) { try { Client result = new Client(); using (DbConnection = new MsSqlPersistence(DbConnectionSettings)) { if (DbConnection.IsConnected()) { using (DbCommand) { result = this.GetClient(ref dbConnection, ref dbCommand, id); } }else { throw new Exception("Unable to Connect"); } } return result; }catch { throw; } }
public SmartCollection<Client> GetClientsRecent(int userId) { try { SmartCollection<Client> resultList = new SmartCollection<Client>(); using (DbConnection = new MsSqlPersistence(DbConnectionSettings)) { if (DbConnection.IsConnected()) { using (DbCommand) { DbCommand.CommandType = CommandType.StoredProcedure; DbCommand.CommandText = "uspGetClientsRecent"; DbCommand.Parameters.Clear(); DataTable clientDT = DbConnection.ExecuteQuery(DbCommand); foreach (DataRow row in clientDT.Rows) { Client client = new Client(); client.ClientId = Convert.ToInt32(row["ClientID"]); client.AccountingId = row["AccountingID"].ToString(); client.ClientName = row["ClientName"].ToString(); client.TermId = row["TermID"] != DBNull.Value ? (int)row["TermID"] : -1; if (client.TermId != null && client.TermId != -1) client.Term = new Term() { TermId = (int)row["TermID"], TermName = row["TermName"].ToString() }; client.WebClientYN = row["WebClientYN"] != DBNull.Value ? Convert.ToBoolean(row["WebClientYN"]) : false; client.CreditCheckYN = row["CreditCheckYN"] != DBNull.Value ? Convert.ToBoolean(row["CreditCheckYN"]) : false; client.CreditHoldYN = row["CreditHoldYN"] != DBNull.Value ? Convert.ToBoolean(row["CreditHoldYN"]) : false; client.GMPYN = row["GMPYN"] != DBNull.Value ? Convert.ToBoolean(row["GMPYN"]) : false; client.BillingAddress = row["BillingAddress"].ToString(); client.BillingCity = row["BillingCity"].ToString(); client.BillingStateId = row["BillingStateID"] != DBNull.Value ? (int)row["BillingStateID"] : -1; if (client.BillingStateId != null && client.BillingStateId != -1) client.BillingState = new State() { StateId = (int)row["BillingStateID"], StateName = row["BillingStateName"].ToString() }; client.BillingZip = row["BillingZip"].ToString(); client.BillingCountryId = row["BillingCountryID"] != DBNull.Value ? (int)row["BillingCountryID"] : -1; if (client.BillingCountryId != null && client.BillingCountryId != -1) client.BillingCountry = new Country() { CountryId = (int)row["BillingCountryID"], CountryName = row["BillingCountryName"].ToString() }; client.SameAsBillingYN = row["SameAsBillingYN"] != DBNull.Value ? Convert.ToBoolean(row["SameAsBillingYN"]) : false; client.ShippingAddress = row["ShippingAddress"].ToString(); client.ShippingCity = row["ShippingCity"].ToString(); client.ShippingStateId = row["ShippingStateID"] != DBNull.Value ? (int)row["ShippingStateID"] : -1; if (client.ShippingStateId != null && client.ShippingStateId != -1) client.ShippingState = new State() { StateId = (int)row["ShippingStateID"], StateName = row["ShippingStateName"].ToString() }; client.ShippingZip = row["ShippingZip"].ToString(); client.ShippingCountryId = row["ShippingCountryID"] != DBNull.Value ? (int)row["ShippingCountryID"] : -1; if (client.ShippingCountryId != null && client.ShippingCountryId != -1) client.ShippingCountry = new Country() { CountryId = (int)row["ShippingCountryID"], CountryName = row["ShippingCountryName"].ToString() }; client.CreatedUser = row["CreatedUser"].ToString(); client.CreatedBy = row["CreatedBy"] != DBNull.Value ? (int)row["CreatedBy"] : -1; client.CreatedDate = row["CreatedDate"] != DBNull.Value ? (DateTime)row["CreatedDate"] : (DateTime)SqlDateTime.Null; client.ModifiedBy = row["ModifiedBy"] != DBNull.Value ? (int)row["ModifiedBy"] : -1; client.ModifiedUser = row["ModifiedUser"].ToString(); client.ModifiedDate = row["ModifiedDate"] != DBNull.Value ? (DateTime)row["ModifiedDate"] : (DateTime)SqlDateTime.Null; // Other client objects client.Contacts = GetContacts(client.ClientId); client.Prices = GetClientPricings(client.ClientId); client.Documents = GetClientDocuments(client.ClientId); client.Notes = GetClientNotes(client.ClientId); client.Complaints = GetClientComplaints(client.ClientId); resultList.Add(client); } clientDT = null; } }else { throw new Exception("Unable to Connect"); } } return resultList; }catch { throw; } }
public int SaveContacts(ref MsSqlPersistence dbConnection, ref SqlCommand dbCommand, ref Client client, int userId) { try { int returnValue = 0; foreach (Contact contact in client.Contacts) { if (contact.IsDirty) { /*SystemDAO.SaveChangeAudit<Contact>(ref dbConnection, ref dbCommand, GetContact(ref dbConnection, ref dbCommand, contact.Pk), contact, ModuleNames.Clients, client.Pk, userId); */ dbCommand.Parameters.Clear(); if (contact.ContactId <= 0) { dbCommand.CommandType = CommandType.StoredProcedure; dbCommand.CommandText = "uspInsertContact"; dbCommand.Parameters.Add("@ClientId", System.Data.SqlDbType.Int).Value = client.ClientId; dbCommand.Parameters.Add("@CreatedBy", System.Data.SqlDbType.Int).Value = userId; dbCommand.Parameters.Add("@CreatedDate", System.Data.SqlDbType.DateTime).Value = DateTime.Now; } else { dbCommand.CommandType = CommandType.StoredProcedure; dbCommand.CommandText = "uspUpdateContact"; dbCommand.Parameters.Add("@ContactId", System.Data.SqlDbType.Int).Value = contact.ContactId; dbCommand.Parameters.Add("@ClientId", System.Data.SqlDbType.Int).Value = client.ClientId; dbCommand.Parameters.Add("@ModifiedBy", System.Data.SqlDbType.Int).Value = userId; dbCommand.Parameters.Add("@ModifiedDate", System.Data.SqlDbType.DateTime).Value = DateTime.Now; dbCommand.Parameters.Add("@DeleteDate", System.Data.SqlDbType.DateTime).Value = contact.DeleteDate; } dbCommand.Parameters.Add("@FirstName", System.Data.SqlDbType.Text, 100).Value = contact.FirstName; dbCommand.Parameters.Add("@LastName", System.Data.SqlDbType.Text, 100).Value = contact.LastName; dbCommand.Parameters.Add("@PrimaryEmail", System.Data.SqlDbType.Text, 100).Value = contact.PrimaryEmail; dbCommand.Parameters.Add("@PrimaryEmailSendYN", System.Data.SqlDbType.Bit).Value = contact.PrimaryEmailSendYN; dbCommand.Parameters.Add("@SecondaryEmail", System.Data.SqlDbType.Text, 100).Value = contact.SecondaryEmail; dbCommand.Parameters.Add("@SecondaryEmailSendYN", System.Data.SqlDbType.Bit).Value = contact.SecondaryEmailSendYN; dbCommand.Parameters.Add("@PrimaryPhone", System.Data.SqlDbType.Text, 20).Value = contact.PrimaryPhone; dbCommand.Parameters.Add("@SecondaryPhone", System.Data.SqlDbType.Text, 20).Value = contact.SecondaryPhone; dbCommand.Parameters.Add("@Fax", System.Data.SqlDbType.Text, 20).Value = contact.Fax; dbCommand.Parameters.Add("@FaxSendYN", System.Data.SqlDbType.Bit).Value = contact.FaxSendYN; dbCommand.Parameters.Add("@Comments", System.Data.SqlDbType.Text, 4000).Value = contact.Comments; if (contact.ContactId > 0) { //returnValue = Number of Rows Affected returnValue = dbConnection.ExecuteCommand(dbCommand); } else { // returnValue = Primary Key Id returnValue = (int)dbConnection.ExecuteScalar(dbCommand); contact.ContactId = returnValue; } } } //Return Total Number of Inserted or Updated Records return returnValue; } catch { throw; } }
public int SaveClientPricing(ref MsSqlPersistence dbConnection, ref SqlCommand dbCommand, ref Client client, int userId) { try { int returnValue = 0; foreach (ClientPricing price in client.Prices) { if (price.IsDirty) { SystemDAO.SaveChangeAudit<ClientPricing>(ref dbConnection, ref dbCommand, GetClientPricing(price.ClientPricingId != -1 ? price.ClientPricingId : -1), price, ModuleNames.Clients, client.Pk, userId); dbCommand.Parameters.Clear(); if (price.ClientPricingId <= 0) { dbCommand.CommandType = CommandType.StoredProcedure; dbCommand.CommandText = "uspInsertClientPricing"; dbCommand.Parameters.Add("@CreatedDate", System.Data.SqlDbType.DateTime).Value = DateTime.Now; dbCommand.Parameters.Add("@CreatedBy", System.Data.SqlDbType.Int).Value = userId; }else { dbCommand.CommandType = CommandType.StoredProcedure; dbCommand.CommandText = "uspUpdateClientPricing"; dbCommand.Parameters.Add("@ClientPricingId", System.Data.SqlDbType.Int).Value = price.ClientPricingId; dbCommand.Parameters.Add("@ModifiedDate", System.Data.SqlDbType.DateTime).Value = DateTime.Now; dbCommand.Parameters.Add("@ModifiedBy", System.Data.SqlDbType.Int).Value = userId; dbCommand.Parameters.Add("@DeleteDate", System.Data.SqlDbType.DateTime).Value = price.DeleteDate; } dbCommand.Parameters.Add("@ClientId", System.Data.SqlDbType.Int).Value = client.ClientId; dbCommand.Parameters.Add("@MethodId", System.Data.SqlDbType.Int).Value = price.MethodId; dbCommand.Parameters.Add("@MethodNumberId", System.Data.SqlDbType.Int).Value = price.MethodNumberId; dbCommand.Parameters.Add("@AnalyteId", System.Data.SqlDbType.Int).Value = price.AnalyteId; dbCommand.Parameters.Add("@Description", System.Data.SqlDbType.Text, 100).Value = price.Description; dbCommand.Parameters.Add("@Discount", System.Data.SqlDbType.Decimal).Value = price.Discount ?? 0; dbCommand.Parameters.Add("@FlatRate", System.Data.SqlDbType.Decimal).Value = price.FlatRate ?? 0; returnValue += dbConnection.ExecuteCommand(dbCommand); } } //Return Total Number of Inserted or Updated Records return returnValue; }catch { throw; } }
public int SaveClientNotes(ref MsSqlPersistence dbConnection, ref SqlCommand dbCommand, Client client, int userId) { try { int returnValue = 0; string sql = string.Empty; foreach (ClientNote note in client.Notes) { if (note.IsDirty) { SystemDAO.SaveChangeAudit<ClientNote>(ref dbConnection, ref dbCommand, GetClientNote(ref dbConnection, ref dbCommand, note.Pk), note, ModuleNames.Clients, client.Pk, userId); dbCommand.CommandType = CommandType.StoredProcedure; dbCommand.Parameters.Clear(); sql = string.Empty; if (note.ClientNoteId <= 0) { dbCommand.CommandText = "uspInsertClientNote"; dbCommand.Parameters.Add("@CreatedBy", System.Data.SqlDbType.Int).Value = userId; dbCommand.Parameters.Add("@CreatedDate", System.Data.SqlDbType.DateTime).Value = DateTime.Now; }else { dbCommand.CommandText = "uspUpdateClientNote"; dbCommand.Parameters.Add("@ClientNoteId", System.Data.SqlDbType.Int).Value = note.ClientNoteId; dbCommand.Parameters.Add("@ModifiedBy", System.Data.SqlDbType.Int).Value = userId; dbCommand.Parameters.Add("@ModifiedDate", System.Data.SqlDbType.DateTime).Value = DateTime.Now; dbCommand.Parameters.Add("@DeleteDate", System.Data.SqlDbType.DateTime).Value = note.DeleteDate ?? SqlDateTime.Null; } dbCommand.Parameters.Add("@ClientId", System.Data.SqlDbType.Int).Value = client.ClientId; dbCommand.Parameters.Add("@Note", System.Data.SqlDbType.NVarChar, 4000).Value = note.Note; dbCommand.Parameters.Add("@CopyToSampleYN", System.Data.SqlDbType.Bit).Value = (bool)note.CopyToSampleYN; dbCommand.Parameters.Add("@IncludeOnCOAYN", System.Data.SqlDbType.Bit).Value = (bool)note.IncludeOnCOAYN; returnValue += dbConnection.ExecuteCommand(dbCommand); } } //Return Total Number of Inserted or Updated Records return returnValue; }catch { throw; } }
public void SaveClientDocuments(ref MsSqlPersistence dbConnection, ref SqlCommand dbCommand, Client client, int userId) { try { foreach (var doc in client.Documents) { if (doc.ClientDocumentId < 0) { dbCommand.CommandType = CommandType.StoredProcedure; dbCommand.CommandText = "uspInsertClientDocument"; dbCommand.Parameters.Clear(); dbCommand.Parameters.AddWithValue("@ClientId", client.ClientId); dbCommand.Parameters.AddWithValue("@Filename", doc.Filename); dbCommand.Parameters.AddWithValue("@DocumentData", Convert.FromBase64CharArray(doc.DocumentData.ToCharArray(), 0, doc.DocumentData.Length)); dbCommand.Parameters.AddWithValue("@CreatedBy", userId); dbCommand.Parameters.AddWithValue("@CreatedDate", DateTime.Now); doc.ClientDocumentId = dbConnection.ExecuteCommand(dbCommand); }else if (doc.IsDirty) { dbCommand.CommandType = CommandType.StoredProcedure; dbCommand.CommandText = "uspUpdateClientDocument"; dbCommand.Parameters.Clear(); dbCommand.Parameters.AddWithValue("@ClientDocumentId", doc.ClientDocumentId); dbCommand.Parameters.AddWithValue("@ClientId", client.ClientId); dbCommand.Parameters.AddWithValue("@ModifiedBy", userId); dbCommand.Parameters.AddWithValue("@ModifiedDate", DateTime.Now); dbCommand.Parameters.AddWithValue("@DeleteDate", doc.DeleteDate); dbConnection.ExecuteCommand(dbCommand); } } }catch { throw; } }
public int SaveClientComplaints(ref MsSqlPersistence dbConnection, ref SqlCommand dbCommand, ref Client client, int userId) { try { int returnValue = 0; string sql = string.Empty; foreach (ClientComplaint complaint in client.Complaints) { if (complaint.IsDirty) { SystemDAO.SaveChangeAudit<ClientComplaint>(ref dbConnection, ref dbCommand, GetClientComplaint(ref dbConnection, ref dbCommand, complaint.Pk != null ? complaint.Pk : -1), complaint, ModuleNames.Clients, client.Pk, userId); dbCommand.Parameters.Clear(); sql = string.Empty; if (complaint.ClientComplaintId == null || complaint.ClientComplaintId <= 0) { dbCommand.CommandType = CommandType.StoredProcedure; dbCommand.CommandText = "uspInsertClientComplaint"; dbCommand.Parameters.Add("@CreatedBy", System.Data.SqlDbType.Int).Value = userId; dbCommand.Parameters.Add("@CreatedDate", System.Data.SqlDbType.DateTime).Value = DateTime.Now; }else { dbCommand.CommandType = CommandType.StoredProcedure; dbCommand.CommandText = "uspUpdateClientComplaint"; dbCommand.Parameters.Add("@ClientComplaintId", System.Data.SqlDbType.Int).Value = complaint.ClientComplaintId; dbCommand.Parameters.Add("@ModifiedBy", System.Data.SqlDbType.Int).Value = userId; dbCommand.Parameters.Add("@ModifiedDate", System.Data.SqlDbType.DateTime).Value = DateTime.Now; dbCommand.Parameters.Add("@DeleteDate", System.Data.SqlDbType.DateTime).Value = complaint.DeleteDate ?? SqlDateTime.Null; } dbCommand.Parameters.Add("@ClientId", System.Data.SqlDbType.Int).Value = client.ClientId; dbCommand.Parameters.Add("@ClassificationId", System.Data.SqlDbType.Int).Value = complaint.ClassificationId; dbCommand.Parameters.Add("@StatusYN", System.Data.SqlDbType.Bit).Value = (bool)complaint.StatusYN; dbCommand.Parameters.Add("@Description", System.Data.SqlDbType.NVarChar, 100).Value = complaint.Description; dbCommand.Parameters.Add("@ARLNumber", System.Data.SqlDbType.NVarChar, 100).Value = complaint.ARLNumber != "" ? complaint.ARLNumber : SqlString.Null; dbCommand.Parameters.Add("@RootCause", System.Data.SqlDbType.NVarChar, 100).Value = complaint.RootCause; dbCommand.Parameters.Add("@NotifyUserId", System.Data.SqlDbType.Int).Value = complaint.NotifyUserId; dbCommand.Parameters.Add("@CorrectiveAction", System.Data.SqlDbType.NVarChar, 100).Value = complaint.CorrectiveAction; dbCommand.Parameters.Add("@CorrectiveActionDate", System.Data.SqlDbType.DateTime).Value = complaint.CorrectiveActionDate != null ? (SqlDateTime)complaint.CorrectiveActionDate : SqlDateTime.Null; dbCommand.Parameters.Add("@CorrectiveActionUserId", System.Data.SqlDbType.Int).Value = complaint.CorrectiveActionUserId; returnValue += dbConnection.ExecuteCommand(dbCommand); } } //Return Total Number of Inserted or Updated Records return returnValue; }catch { throw; } }
/// <summary> /// Save Client /// </summary> /// <returns></returns> public int SaveClient(Client client, Guid userToken, int userId) { try { int returnValue = -1; bool insertNewRecord = false; string sql = string.Empty; using (DbConnection = new MsSqlPersistence(DbConnectionSettings, true)) { if (DbConnection.IsConnected()) { using (DbCommand) { try { // Try Catch here allows other exceptions to rollback transactions if (client.IsDirty) { SystemDAO.SaveChangeAudit<Client>(ref dbConnection, ref dbCommand, GetClient(ref dbConnection, ref dbCommand, client.Pk ?? 0), client, ModuleNames.Clients, client.Pk, userId); DbCommand.Parameters.Clear(); if (client.ClientId == null || client.ClientId <= 0) { insertNewRecord = true; DbCommand.CommandType = CommandType.StoredProcedure; DbCommand.CommandText = "uspInsertClient"; DbCommand.Parameters.Add("@CreatedBy", System.Data.SqlDbType.Int).Value = userId; DbCommand.Parameters.Add("@CreatedDate", System.Data.SqlDbType.DateTime).Value = DateTime.Now; }else { DbCommand.CommandType = CommandType.StoredProcedure; DbCommand.CommandText = "uspUpdateClient"; DbCommand.Parameters.Add("@ClientID", System.Data.SqlDbType.Int).Value = client.ClientId; DbCommand.Parameters.Add("@ModifiedBy", System.Data.SqlDbType.Int).Value = userId; DbCommand.Parameters.Add("@ModifiedDate", System.Data.SqlDbType.DateTime).Value = DateTime.Now; } DbCommand.Parameters.Add("@ClientName", System.Data.SqlDbType.Text, 100).Value = client.ClientName != null ? client.ClientName : SqlString.Null; DbCommand.Parameters.Add("@AccountingId", System.Data.SqlDbType.Text, 100).Value = client.AccountingId != null ? client.AccountingId : SqlString.Null; DbCommand.Parameters.Add("@TermId", System.Data.SqlDbType.Int).Value = client.Term.TermId != null ? client.Term.TermId : (int?)SqlInt32.Null; DbCommand.Parameters.Add("@CreditCheckYN", System.Data.SqlDbType.Bit).Value = client.CreditCheckYN != null ? client.CreditCheckYN : SqlBoolean.Null; DbCommand.Parameters.Add("@CreditHoldYN", System.Data.SqlDbType.Bit).Value = client.CreditHoldYN != null ? client.CreditHoldYN : SqlBoolean.Null; DbCommand.Parameters.Add("@WebClientYN", System.Data.SqlDbType.Bit).Value = client.WebClientYN != null ? client.WebClientYN : SqlBoolean.Null; DbCommand.Parameters.Add("@GMPYN", System.Data.SqlDbType.Bit).Value = client.GMPYN != null ? client.GMPYN : SqlBoolean.Null; DbCommand.Parameters.Add("@BillingAddress", System.Data.SqlDbType.Text, 100).Value = client.BillingAddress != null ? client.BillingAddress : SqlString.Null; DbCommand.Parameters.Add("@BillingCity", System.Data.SqlDbType.Text, 100).Value = client.BillingCity != null ? client.BillingCity : SqlString.Null; if (client.BillingState != null && client.BillingState.StateId != null) DbCommand.Parameters.Add("@BillingStateId", System.Data.SqlDbType.Int).Value = client.BillingState.StateId; DbCommand.Parameters.Add("@BillingZip", System.Data.SqlDbType.Text, 10).Value = client.BillingZip != null ? client.BillingZip : SqlString.Null; if (client.BillingCountry != null && client.BillingCountry.CountryId != null) DbCommand.Parameters.Add("@BillingCountryId", System.Data.SqlDbType.Int).Value = client.BillingCountry.CountryId; DbCommand.Parameters.Add("@SameAsBillingYN", System.Data.SqlDbType.Bit).Value = client.SameAsBillingYN != null ? client.SameAsBillingYN : SqlBoolean.Null; DbCommand.Parameters.Add("@ShippingAddress", System.Data.SqlDbType.Text, 100).Value = client.ShippingAddress != null ? client.ShippingAddress : SqlString.Null; DbCommand.Parameters.Add("@ShippingCity", System.Data.SqlDbType.Text, 100).Value = client.ShippingCity != null ? client.ShippingCity : SqlString.Null; if (client.ShippingState != null && client.ShippingState.StateId != null) DbCommand.Parameters.Add("@ShippingStateId", System.Data.SqlDbType.Int).Value = client.ShippingState.StateId; DbCommand.Parameters.Add("@ShippingZip", System.Data.SqlDbType.Text, 10).Value = client.ShippingZip != null ? client.ShippingZip : SqlString.Null; if (client.ShippingCountry != null && client.ShippingCountry.CountryId != null) DbCommand.Parameters.Add("@ShippingCountryId", System.Data.SqlDbType.Int).Value = client.ShippingCountry.CountryId; if (client.ClientId > 0) returnValue = DbConnection.ExecuteCommand(DbCommand); else { // returnValue = Primary Key Id returnValue = (int)DbConnection.ExecuteScalar(DbCommand); client.ClientId = returnValue; } } // Save Contacts using (ClientDAO contactDao = new ClientDAO()) contactDao.SaveContacts(ref dbConnection, ref dbCommand, ref client, userId); // Save Pricing this.SaveClientPricing(ref dbConnection, ref dbCommand, ref client, userId); // Save Complaints this.SaveClientComplaints(ref dbConnection, ref dbCommand, ref client, userId); // Save Notes this.SaveClientNotes(ref dbConnection, ref dbCommand, client, userId); // Save Documents this.SaveClientDocuments(ref dbConnection, ref dbCommand, client, userId); // Accounting Interface //if (insertNewRecord && Vars.AccountingSettings.InterfaceId > 0) { // client = new ClientInterface().ClientAdd(client); // if (!string.IsNullOrWhiteSpace(client.AccountingId)) { // sql = @" // UPDATE customers // SET accountingid = @AccountingId // WHERE id = @ID // "; // DbCommand.Parameters.Clear(); // DbCommand.CommandText = sql; // DbCommand.Parameters.Add("@ID", System.Data.SqlDbType.Int).Value = client.ClientId; // DbCommand.Parameters.Add("@AccountingId", System.Data.SqlDbType.Text, 100).Value = client.AccountingId ?? string.Empty; // DbConnection.ExecuteCommand(DbCommand); // } //} // Release Lock using (SystemDAO systemDao = new SystemDAO()) { systemDao.ReleaseLock(ref dbConnection, ref dbCommand, (int)ModelNamesEnum.Client, client.ClientId.ToString(), userToken); } }catch { if (DbConnection.IsConnected() && DbConnection.IsTransaction()) DbConnection.Rollback(); throw; } } }else { throw new Exception("Unable to Connect"); } } return returnValue; }catch { throw; } }
public Client GetClient(ref MsSqlPersistence dbConnection, ref SqlCommand dbCommand, int? id) { try { Client result = new Client(); dbCommand.Parameters.Clear(); dbCommand.CommandType = CommandType.StoredProcedure; dbCommand.CommandText = "uspGetClient"; dbCommand.Parameters.Add("@ClientId", System.Data.SqlDbType.Int).Value = id; DataTable returnDT = dbConnection.ExecuteQuery(dbCommand); if (returnDT.Rows.Count == 1) { DataRow row = returnDT.Rows[0]; result.ClientId = Convert.ToInt32(row["ClientID"]); result.AccountingId = row["AccountingID"].ToString(); result.ClientName = row["ClientName"].ToString(); result.TermId = row["TermID"] != DBNull.Value ? (int)row["TermID"] : -1; if (result.TermId != null && result.TermId != -1) result.Term = new Term() { TermId = (int)row["TermID"], TermName = row["TermName"].ToString() }; result.WebClientYN = row["WebClientYN"] != DBNull.Value ? Convert.ToBoolean(row["WebClientYN"]) : false; result.CreditCheckYN = row["CreditCheckYN"] != DBNull.Value ? Convert.ToBoolean(row["CreditCheckYN"]) : false; result.CreditHoldYN = row["CreditHoldYN"] != DBNull.Value ? Convert.ToBoolean(row["CreditHoldYN"]) : false; result.GMPYN = row["GMPYN"] != DBNull.Value ? Convert.ToBoolean(row["GMPYN"]) : false; result.BillingAddress = row["BillingAddress"].ToString(); result.BillingCity = row["BillingCity"].ToString(); result.BillingStateId = row["BillingStateID"] != DBNull.Value ? (int)row["BillingStateID"] : -1; if (result.BillingStateId != null && result.BillingStateId != -1) result.BillingState = new State() { StateId = (int)row["BillingStateID"], StateName = row["BillingStateName"].ToString() }; result.BillingZip = row["BillingZip"].ToString(); result.BillingCountryId = row["BillingCountryID"] != DBNull.Value ? (int)row["BillingCountryID"] : -1; if (result.BillingCountryId != null && result.BillingCountryId != -1) result.BillingCountry = new Country() { CountryId = (int)row["BillingCountryID"], CountryName = row["BillingCountryName"].ToString() }; result.SameAsBillingYN = row["SameAsBillingYN"] != DBNull.Value ? Convert.ToBoolean(row["SameAsBillingYN"]) : false; result.ShippingAddress = row["ShippingAddress"].ToString(); result.ShippingCity = row["ShippingCity"].ToString(); result.ShippingStateId = row["ShippingStateID"] != DBNull.Value ? (int)row["ShippingStateID"] : -1; if (result.ShippingStateId != null && result.ShippingStateId != -1) result.ShippingState = new State() { StateId = (int)row["ShippingStateID"], StateName = row["ShippingStateName"].ToString() }; result.ShippingZip = row["ShippingZip"].ToString(); result.ShippingCountryId = row["ShippingCountryID"] != DBNull.Value ? (int)row["ShippingCountryID"] : -1; if (result.ShippingCountryId != null && result.ShippingCountryId != -1) result.ShippingCountry = new Country() { CountryId = (int)row["ShippingCountryID"], CountryName = row["ShippingCountryName"].ToString() }; result.CreatedUser = row["CreatedUser"].ToString(); result.CreatedBy = row["CreatedBy"] != DBNull.Value ? (int)row["CreatedBy"] : -1; result.CreatedDate = row["CreatedDate"] != DBNull.Value ? (DateTime)row["CreatedDate"] : (DateTime)SqlDateTime.Null; result.ModifiedBy = row["ModifiedBy"] != DBNull.Value ? (int)row["ModifiedBy"] : -1; result.ModifiedUser = row["ModifiedUser"].ToString(); result.ModifiedDate = row["ModifiedDate"] != DBNull.Value ? (DateTime)row["ModifiedDate"] : (DateTime)SqlDateTime.Null; row = null; } returnDT = null; return result; }catch { throw; } }
public int DoSaveClient(Client customer, Identification identification) { logger.Log(LogLevel.Trace, AppLib.GetCaller(logger)); //Validate Customer Object if (!customer.ValidateModel()) throw new FaultException<ServiceFault>(new ServiceFault(customer.CurrentErrors), new FaultReason(SysVars.InvalidFormat)); using (ClientDAO dao = new ClientDAO()) { return dao.SaveClient(customer, identification.Token, identification.UserId); } }
public IAsyncResult BeginSaveClient(Client customer, Identification identification, AsyncCallback callback, object state) { logger.Log(LogLevel.Trace, AppLib.GetCaller(logger)); identification.UserId = AppLib.VerifyToken(identification.Token); if (identification.UserId <= 0) { throw new FaultException<ServiceFault>(new ServiceFault("Invalid Authentication", "Authorization"), new FaultReason("Unauthorized")); } var task = Task<int>.Factory.StartNew(process => DoSaveClient(customer, identification), state); return task.ContinueWith(res => callback(task)); }
private Client ClientMapFrom(IAcctCustomer acctCustomer, Client client) { client.AccountingId = ((AcctCustomer)acctCustomer).ListId; return client; }
public Client ClientAdd(Client client) { return ClientMapFrom(new CustomerService().CustomerAdd(ClientMapTo(client)), client); }