Esempio n. 1
0
        private static void ProcessQuoteHeader(QuoteHeader header, string spName, bool isUpdate = false)
        {
            try
            {
                SqlParameter pQuoteCreatedOn = new SqlParameter();
                pQuoteCreatedOn.ParameterName = "CreatedOn";
                pQuoteCreatedOn.Value = header.QuoteCreatedOn;

                SqlParameter pRequestedShipDate = new SqlParameter();
                pRequestedShipDate.ParameterName = "RequestedShipDate";
                pRequestedShipDate.Value = header.QuoteRequestedOn;

                SqlParameter pCustomerPO = new SqlParameter();
                pCustomerPO.ParameterName = "CustomerPO";
                pCustomerPO.Value = header.CustomerPO;

                SqlParameter pLeadTimeID = new SqlParameter();
                pLeadTimeID.ParameterName = "LeadTimeID";
                pLeadTimeID.Value = header.LeadTimeID;

                SqlParameter pLeadTimeTypeID = new SqlParameter();
                pLeadTimeTypeID.ParameterName = "LeadTimeTypeID";
                pLeadTimeTypeID.Value = header.LeadTimeTypeID;

                SqlParameter pShipToOtherAddress = new SqlParameter();
                pShipToOtherAddress.ParameterName = "ShipToOtherAddress";
                pShipToOtherAddress.Value = header.IsShipToOtherAddress;

                SqlParameter pQuoteNumber = new SqlParameter();
                pQuoteNumber.ParameterName = "QuoteNumber";
                pQuoteNumber.Value = header.QuoteNumber;

                SqlParameter pShippingMethodID = new SqlParameter();
                pShippingMethodID.ParameterName = "ShippingMethodID";
                pShippingMethodID.Value = header.ShippingMethodID;

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

                SqlParameter pOperatorName = new SqlParameter();
                pOperatorName.ParameterName = "OperatorName";
                pOperatorName.Value = header.OperatorName;

                SqlParameter pPaymentModeID = new SqlParameter();
                pPaymentModeID.ParameterName = "PaymentModeID";
                pPaymentModeID.Value = header.PaymentModeID;

                SqlParameter pQuoteStatusID = new SqlParameter();
                pQuoteStatusID.ParameterName = "QuoteStatusID";
                pQuoteStatusID.Value = header.QuoteStatusID;

                if (header.IsNewCustomer && isUpdate == false)
                {
                    string customerID = CreateNewCustomer(header.SoldTo);

                    if (header.IsShipToOtherAddress == true && string.IsNullOrEmpty(customerID) == false)
                    {
                        InsertShippingDetails(customerID, header.QuoteNumber, header.ShipTo);
                    }
                    pCustomerID.Value = int.Parse(customerID);
                }

                SQLHelper.ExecuteStoredProcedure(spName, pQuoteCreatedOn, pRequestedShipDate, pCustomerPO, pLeadTimeID, pLeadTimeTypeID,
                        pShipToOtherAddress, pQuoteNumber, pCustomerID, pShippingMethodID, pOperatorName, pPaymentModeID, pQuoteStatusID);
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }
        }
Esempio n. 2
0
 internal static void SaveQuoteHeader(QuoteHeader header)
 {
     try
     {
         ProcessQuoteHeader(header, StoredProcedures.AddQuoteHeader);
     }
     catch (Exception ex)
     {
         Logger.LogException(ex);
     }
 }
Esempio n. 3
0
 internal static void UpdateQuoteHeader(QuoteHeader header, bool isUpdate)
 {
     ProcessQuoteHeader(header, StoredProcedures.UpdateQuoteHeader, isUpdate);
 }
        private QuoteHeader BuildQuoteHeader(string quoteNumber)
        {
            QuoteHeader header = new QuoteHeader();
            try
            {
                header.QuoteNumber = quoteNumber;
                header.QuoteCreatedOn = dtQuoteCreatedOn.SelectedDate.Value.ToShortDateString();
                header.QuoteRequestedOn = dtQuoteRequestedOn.SelectedDate.Value.ToShortDateString();
                header.CustomerPO = txtCustomerPO.Text;
                header.IsNewCustomer = cbIsNewClient.IsChecked == true;
                header.IsShipToOtherAddress = cbIsShipToSameAddress.IsChecked == true;
                header.ShippingMethodID = cmbShippingMethod.SelectedIndex;
                header.LeadTimeID = cmbLeadTime.SelectedIndex;
                header.LeadTimeTypeID = cmbLeadTimeType.SelectedIndex;

                header.PaymentModeID = int.Parse(cmbPaymentType.SelectedValue.ToString());
                header.QuoteStatusID = int.Parse(cmbQuoteStatus.SelectedValue.ToString());

                if (FirmSettings.IsAdmin)
                {
                    header.OperatorName = cmbOperator.Text;
                }
                else
                {
                    header.OperatorName = txtOperatorName.Text;
                }
                if (cbIsNewClient.IsChecked.Value == false)
                {
                    header.CustomerID = int.Parse(cmbCustomers.SelectedValue.ToString());
                }
                header.SoldTo = new CustomerDetails();
                header.SoldTo.FirstName = txtSoldToFirstName.Text;
                header.SoldTo.LastName = txtSoldToLastName.Text;
                header.SoldTo.Address = txtSoldToAddress.Text;
                header.SoldTo.Phone = txtSoldToPhone.Text;
                header.SoldTo.Email = txtSoldToEmail.Text;
                header.SoldTo.Fax = txtSoldToFax.Text;
                header.SoldTo.Misc = txtSoldToMisc.Text;

                if (cbIsShipToSameAddress.IsChecked == true)
                {
                    header.ShipTo = new CustomerDetails();
                    header.ShipTo.FirstName = txtShiptoFirstName.Text;
                    header.ShipTo.LastName = txtShiptoLastName.Text;
                    header.ShipTo.Address = txtShipToAddress.Text;
                    header.ShipTo.Phone = txtShipToPhone.Text;
                    header.ShipTo.Email = txtShipToEmail.Text;
                    header.ShipTo.Fax = txtShipToFax.Text;
                    header.ShipTo.Misc = txtShipToMisc.Text;
                }
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }
            return header;
        }