示例#1
0
        internal static string CreateNewCustomer(CustomerDetails soldTo)
        {
            string customerID = string.Empty;
            try
            {
                SqlParameter pAddress = new SqlParameter();
                pAddress.ParameterName = "Address";
                pAddress.Value = soldTo.Address ?? string.Empty;

                SqlParameter pFirstName = new SqlParameter();
                pFirstName.ParameterName = "FirstName";
                pFirstName.Value = soldTo.FirstName ?? string.Empty;

                SqlParameter pLastName = new SqlParameter();
                pLastName.ParameterName = "LastName";
                pLastName.Value = soldTo.LastName ?? string.Empty;

                SqlParameter pPhone = new SqlParameter();
                pPhone.ParameterName = "Phone";
                pPhone.Value = soldTo.Phone ?? string.Empty;

                SqlParameter pFax = new SqlParameter();
                pFax.ParameterName = "Fax";
                pFax.Value = soldTo.Fax ?? string.Empty;

                SqlParameter pEmail = new SqlParameter();
                pEmail.ParameterName = "Email";
                pEmail.Value = soldTo.Email ?? string.Empty;

                SqlParameter pMisc = new SqlParameter();
                pMisc.ParameterName = "Misc";
                pMisc.Value = soldTo.Misc ?? string.Empty;

                var result = SQLHelper.ExecuteStoredProcedure(StoredProcedures.CreateNewCustomer, pAddress, pFirstName, pLastName, pPhone, pFax, pEmail, pMisc);
                if (result == null || result.Tables == null || result.Tables.Count == 0)
                {
                    return customerID;
                }
                customerID = result.Tables[0].Rows[0][0].ToString();

            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }
            return customerID;
        }
        private void btnSaveCustomer_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                int index = isNew ? 2 : 1;
                //CustomerSmartDataEntity newCustomer = dgCustomerList.Items[dgCustomerList.Items.Count - index] as CustomerSmartDataEntity;
                CustomerSmartDataEntity newCustomer = dgCustomerList.Items[dgCustomerList.SelectedIndex] as CustomerSmartDataEntity;
                if (newCustomer == null)
                {
                    Helper.ShowErrorMessageBox("Error during saving new customer.");
                    return;
                }
                CustomerDetails customer = new CustomerDetails();
                customer.FirstName = newCustomer.FirstName;
                customer.LastName = newCustomer.LastName;
                customer.Address = newCustomer.Address;
                customer.Phone = newCustomer.Phone;
                customer.Email = newCustomer.Email;
                customer.Fax = newCustomer.Fax;
                customer.Misc = newCustomer.Misc;
                customer.Fax = newCustomer.Fax;

                if (isNew == true)
                {
                    BusinessLogic.CreateNewCustomer(customer);
                }
                else if (isEdit == true)
                {
                    BusinessLogic.UpdateCustomer(customer, newCustomer.ID);
                }

                if (isNew)
                {
                    Helper.ShowInformationMessageBox("New customer saved successfully!");
                }
                else if (isEdit)
                {
                    Helper.ShowInformationMessageBox("Customer information updated successfully!");
                }

                FillCustomerDetails();
                dgCustomerList.CanUserAddRows = false;

                UpdateStatus(false);

                isEdit = false;
                isNew = false;
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }
        }
示例#3
0
 private void SetSoldToDetails(CustomerDetails soldTo)
 {
     txtSoldToFirstName.Text = soldTo.FirstName;
     txtSoldToLastName.Text = soldTo.LastName;
     txtSoldToAddress.Text = soldTo.Address;
     txtSoldToPhone.Text = soldTo.Phone;
     txtSoldToFax.Text = soldTo.Fax;
     txtSoldToEmail.Text = soldTo.Email;
     txtSoldToMisc.Text = soldTo.Misc;
 }
示例#4
0
        internal static void GetCustomerDetails(out CustomerDetails soldTo, out CustomerDetails shipTo, string customerID)
        {
            DataSet result = null;
            soldTo = null;
            shipTo = null;
            try
            {
                SqlParameter pCustomerID = new SqlParameter();
                pCustomerID.ParameterName = "CustomerID";
                pCustomerID.Value = customerID;

                result = SQLHelper.ExecuteStoredProcedure(StoredProcedures.GetCustomerDetails, pCustomerID);

                if (result == null || result.Tables == null || result.Tables.Count == 0 || result.Tables[0].Rows.Count == 0)
                {
                    return;
                }
                soldTo = new CustomerDetails();
                soldTo.FirstName = result.Tables[0].Rows[0][ColumnNames.SoldTo_FirstName].ToString();
                soldTo.LastName = result.Tables[0].Rows[0][ColumnNames.SoldTo_LastName].ToString();
                soldTo.Address = result.Tables[0].Rows[0][ColumnNames.SoldTo_Address].ToString();
                soldTo.Email = result.Tables[0].Rows[0][ColumnNames.SoldTo_Email].ToString();
                soldTo.Fax = result.Tables[0].Rows[0][ColumnNames.SoldTo_Fax].ToString();
                soldTo.Phone = result.Tables[0].Rows[0][ColumnNames.SoldTo_Phone].ToString();
                soldTo.Misc = result.Tables[0].Rows[0][ColumnNames.SoldTo_Misc].ToString();

                shipTo = new CustomerDetails();
                shipTo.FirstName = result.Tables[0].Rows[0][ColumnNames.ShipTo_FirstName].ToString();
                shipTo.LastName = result.Tables[0].Rows[0][ColumnNames.ShipTo_LastName].ToString();
                shipTo.Address = result.Tables[0].Rows[0][ColumnNames.ShipTo_Address].ToString();
                shipTo.Email = result.Tables[0].Rows[0][ColumnNames.ShipTo_Email].ToString();
                shipTo.Fax = result.Tables[0].Rows[0][ColumnNames.ShipTo_Fax].ToString();
                shipTo.Phone = result.Tables[0].Rows[0][ColumnNames.ShipTo_Phone].ToString();
                shipTo.Misc = result.Tables[0].Rows[0][ColumnNames.ShipTo_Misc].ToString();
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }
        }
示例#5
0
        private static void InsertShippingDetails(string customerID, string quoteNumber, CustomerDetails shipTo)
        {
            try
            {
                SqlParameter pQuoteNumber = new SqlParameter();
                pQuoteNumber.ParameterName = "QuoteNumber";
                pQuoteNumber.Value = quoteNumber;

                SqlParameter pCustomerID = new SqlParameter();
                pCustomerID.ParameterName = "CustomerID";
                pCustomerID.Value = customerID;

                SqlParameter pAddress = new SqlParameter();
                pAddress.ParameterName = "Address";
                pAddress.Value = shipTo.Address;

                SqlParameter pFirstName = new SqlParameter();
                pFirstName.ParameterName = "FirstName";
                pFirstName.Value = shipTo.FirstName;

                SqlParameter pLastName = new SqlParameter();
                pLastName.ParameterName = "LastName";
                pLastName.Value = shipTo.LastName;

                SqlParameter pPhone = new SqlParameter();
                pPhone.ParameterName = "Phone";
                pPhone.Value = shipTo.Phone;

                SqlParameter pFax = new SqlParameter();
                pFax.ParameterName = "Fax";
                pFax.Value = shipTo.Fax;

                SqlParameter pEmail = new SqlParameter();
                pEmail.ParameterName = "Email";
                pEmail.Value = shipTo.Email;

                SqlParameter pMisc = new SqlParameter();
                pMisc.ParameterName = "Misc";
                pMisc.Value = shipTo.Misc;

                SQLHelper.ExecuteStoredProcedure(StoredProcedures.InsertShippingDetails, pQuoteNumber, pCustomerID, pAddress, pFirstName, pLastName, pPhone, pFax, pEmail, pMisc);

            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }
        }
示例#6
0
        internal static void UpdateCustomer(CustomerDetails soldTo, string customerID)
        {
            try
            {
                SqlParameter pAddress = new SqlParameter();
                pAddress.ParameterName = "Address";
                pAddress.Value = soldTo.Address ?? string.Empty;

                SqlParameter pFirstName = new SqlParameter();
                pFirstName.ParameterName = "FirstName";
                pFirstName.Value = soldTo.FirstName;

                SqlParameter pLastName = new SqlParameter();
                pLastName.ParameterName = "LastName";
                pLastName.Value = soldTo.LastName;

                SqlParameter pPhone = new SqlParameter();
                pPhone.ParameterName = "Phone";
                pPhone.Value = soldTo.Phone ?? string.Empty;

                SqlParameter pFax = new SqlParameter();
                pFax.ParameterName = "Fax";
                pFax.Value = soldTo.Fax ?? string.Empty;

                SqlParameter pEmail = new SqlParameter();
                pEmail.ParameterName = "Email";
                pEmail.Value = soldTo.Email ?? string.Empty;

                SqlParameter pMisc = new SqlParameter();
                pMisc.ParameterName = "Misc";
                pMisc.Value = soldTo.Misc ?? string.Empty;

                SqlParameter pCustomerID = new SqlParameter();
                pCustomerID.ParameterName = "customerID";
                pCustomerID.Value = customerID;

                var result = SQLHelper.ExecuteStoredProcedure(StoredProcedures.UpdateCustomer, pAddress, pFirstName, pLastName, pPhone, pFax, pEmail, pMisc, pCustomerID);
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }
        }