/// <summary> /// Get all Dinerware Customer /// </summary> /// <returns></returns> public List <DWCustomer> GetAllDinerwareCustomer(string lastSyncCustomers) { var dwCus = new List <DWCustomer>(); DateTime lastSyncTime = new DateTime(); using (SqlConnection conn = new SqlConnection(DATABASE_CONNECTION_STR)) { SqlCommand cmd = new SqlCommand(); string cmdStr = string.Empty; if (!string.IsNullOrEmpty(lastSyncCustomers)) { DateTime.TryParse(lastSyncCustomers, out lastSyncTime); cmdStr = string.Format("SELECT [cust_id],[cust_fname],[cust_edited],[cust_lname],[cust_phone],[cust_email],[cust_dob],[cust_active],[cust_fullname],[cust_phone_prefix],[cust_phone_last_four],[cust_phone_last_seven],[cust_membership_id],[cust_membership_cardinfo],[cust_callerID],[g_customers_id] FROM [{0}].[dbo].[Customers] where cust_edited > @cust_edited", DATABASENAME); cmd.CommandText = cmdStr; cmd.Parameters.AddWithValue("@cust_edited", lastSyncTime); } else { cmdStr = string.Format("SELECT [cust_id],[cust_fname],[cust_edited],[cust_lname],[cust_phone],[cust_email],[cust_dob],[cust_active],[cust_fullname],[cust_phone_prefix],[cust_phone_last_four],[cust_phone_last_seven],[cust_membership_id],[cust_membership_cardinfo],[cust_callerID],[g_customers_id] FROM [{0}].[dbo].[Customers]", DATABASENAME); cmd.CommandText = cmdStr; } cmd.Connection = conn; conn.Open(); using (SqlDataReader oReader = cmd.ExecuteReader()) { while (oReader.Read()) { var customer = new DWCustomer { cust_id = Convert.ToInt32(oReader["cust_id"].ToString()), cust_fname = oReader["cust_fname"].ToString(), cust_lname = oReader["cust_lname"].ToString(), cust_phone = oReader["cust_phone"].ToString(), cust_email = oReader["cust_email"].ToString(), cust_dob = oReader["cust_dob"].ToString(), cust_active = oReader["cust_active"].ToString(), cust_fullname = oReader["cust_fullname"].ToString(), cust_phone_prefix = oReader["cust_phone_prefix"].ToString(), cust_phone_last_four = oReader["cust_phone_last_four"].ToString(), cust_phone_last_seven = oReader["cust_phone_last_seven"].ToString(), cust_membership_id = oReader["cust_membership_id"].ToString(), cust_membership_cardinfo = oReader["cust_membership_cardinfo"].ToString(), cust_callerID = oReader["cust_callerID"].ToString(), g_customers_id = oReader["g_customers_id"].ToString(), cust_edited = Convert.ToDateTime(oReader["cust_edited"].ToString()) }; dwCus.Add(customer); } } }; return(dwCus); }
/// <summary> /// Get Dinerware Customer By Id /// </summary> /// <param name="customerId"></param> /// <returns></returns> public DWCustomer GetDinerwareCustomerById(Int32 customerId) { DWCustomer customer = null; using (SqlConnection conn = new SqlConnection(DATABASE_CONNECTION_STR)) { SqlCommand cmd = new SqlCommand(); string cmdStr = string.Format("SELECT [cust_id],[cust_fname],[cust_edited],[cust_lname],[cust_phone],[cust_email],[cust_dob],[cust_active],[cust_fullname],[cust_phone_prefix],[cust_phone_last_four],[cust_phone_last_seven],[cust_membership_id],[cust_membership_cardinfo],[cust_callerID],[g_customers_id] FROM [{0}].[dbo].[Customers] where cust_id = @cust_id", DATABASENAME); cmd.CommandText = cmdStr; cmd.Parameters.AddWithValue("@cust_id", customerId); cmd.Connection = conn; conn.Open(); using (SqlDataReader oReader = cmd.ExecuteReader()) { while (oReader.Read()) { customer = new DWCustomer { cust_id = Convert.ToInt32(oReader["cust_id"].ToString()), cust_fname = oReader["cust_fname"].ToString(), cust_lname = oReader["cust_lname"].ToString(), cust_phone = oReader["cust_phone"].ToString(), cust_email = oReader["cust_email"].ToString(), cust_dob = oReader["cust_dob"].ToString(), cust_active = oReader["cust_active"].ToString(), cust_fullname = oReader["cust_fullname"].ToString(), cust_phone_prefix = oReader["cust_phone_prefix"].ToString(), cust_phone_last_four = oReader["cust_phone_last_four"].ToString(), cust_phone_last_seven = oReader["cust_phone_last_seven"].ToString(), cust_membership_id = oReader["cust_membership_id"].ToString(), cust_membership_cardinfo = oReader["cust_membership_cardinfo"].ToString(), cust_callerID = oReader["cust_callerID"].ToString(), g_customers_id = oReader["g_customers_id"].ToString(), cust_edited = Convert.ToDateTime(oReader["cust_edited"].ToString()) }; } } }; return(customer); }