示例#1
0
        public double GetInvoiceTotal(PurchaseMethod purchaseMethod, Province province)
        {
            var total = 0.0;

            if (purchaseMethod == PurchaseMethod.InStore)
            {
                double taxRate = 1;
                if (province == Province.Quebec)
                {
                    taxRate = 1.5;
                }
                else if (province == Province.Ontario)
                {
                    taxRate = 1.2;
                }

                total += _products.Sum(p => p.Price * (p.Taxable ? taxRate : 1));
            }
            else if (purchaseMethod == PurchaseMethod.Online)
            {
                total += _products.Sum(p => p.Price);
            }

            return(total);
        }
示例#2
0
        public List <PurchaseMethod> GetPurchaseMethods()
        {
            List <PurchaseMethod> methods = new List <PurchaseMethod>();

            using (var cn = new SqlConnection("Server=localhost;Database=GuildCars;User Id=sa;Password=sqlserver;"))
            {
                SqlCommand cmd = new SqlCommand("DisplayPurchaseTypes", cn);
                cmd.CommandType = CommandType.StoredProcedure;

                cn.Open();

                using (SqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        PurchaseMethod currentRow = new PurchaseMethod();

                        currentRow.PurchaseMethodId = (int)dr["PurchaseMethodId"];
                        currentRow.PurchaseType     = dr["PurchaseType"].ToString();

                        methods.Add(currentRow);
                    }
                }
            }

            return(methods);
        }
示例#3
0
 private void statusesDataGrid_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex >= 0)
     {
         StartLoading();
         var            dg     = (DataGridView)sender;
         var            itemID = dg.Rows[e.RowIndex].Cells["id"].Value.ToString();
         PurchaseMethod method = Program.dataManager.GetPurchaseMethod(itemID);
         ShowMethod(method);
         FinishLoading();
     }
 }
示例#4
0
        private void ShowMethod(PurchaseMethod method)
        {
            MethodEditForm form = new MethodEditForm(method);

            Hide();
            var result = form.ShowDialog();

            Show();
            if (result == DialogResult.OK)
            {
                ReloadTable();
            }
        }
示例#5
0
        private void ReloadStages()
        {
            //изменить этапы в зависимости от выбранного способа определения поставщика
            stageID.Items.Clear();

            ComboBoxItem   selectedItem = purchaseMethodID.SelectedItem as ComboBoxItem;
            PurchaseMethod method       = CCatalog.purchaseMethods[(int)selectedItem.Value];

            foreach (var st in method.purchaseStages)
            {
                ComboBoxItem item = new ComboBoxItem();
                item.Text  = st.Value;
                item.Value = st.Key;

                stageID.Items.Add(item);
            }
        }
示例#6
0
        public MethodEditForm(PurchaseMethod _method)
        {
            StartLoading();
            InitializeComponent();
            InitializeAuraForm();

            creator = new CommandStringCreator("Methods", _method.id.ToString());

            method = _method;
            if (method.id < 1)
            {
                method.isActual = 1;
            }

            FillFields();
            FillStages();


            FinishLoading();
        }
        private void ConfirmButton_Click(object sender, EventArgs e)
        {
            // wipe last attempt
            this.HideFormError();

            // do data checks here.
            if (!this.InputsAreValid())
            {
                return;
            }

            // if data checks pass assign all values to expense and pass back dialog ok result.
            string           name;
            HashSet <string> places = new HashSet <string>(), tags = new HashSet <string>(), keywords = new HashSet <string>();
            DateTime         maxDate = DateTime.MaxValue, minDate = DateTime.MinValue;
            float            maxValue = float.MaxValue, minValue = float.MinValue;
            PurchaseMethod   p = null;

            name = this.filterNameInputTextBox.Text;

            if (this.lowerBoundDateTimePicker.Enabled)
            {
                minDate = this.lowerBoundDateTimePicker.Value;
            }

            if (this.upperBoundDateTimePicker.Enabled)
            {
                maxDate = this.upperBoundDateTimePicker.Value;
            }

            if (this.lowerBoundAmountInputTextBox.Enabled)
            {
                minValue = float.Parse(this.lowerBoundAmountInputTextBox.Text);
            }

            if (this.upperBoundAmountInputTextBox.Enabled)
            {
                maxValue = float.Parse(this.upperBoundAmountInputTextBox.Text);
            }

            if (this.placesInputTextBox.Enabled)
            {
                places = new HashSet <string>(from string place in this.placesInputTextBox.Text.Split(',') select place.Trim());
            }

            if (this.tagsInputTextBox.Enabled)
            {
                tags = new HashSet <string>(from string tag in this.tagsInputTextBox.Text.Split(',') select tag.Trim());
            }

            if (this.notesInputTextBox.Enabled)
            {
                keywords = new HashSet <string>(from string keyword in this.notesInputTextBox.Text.Split(',') select keyword.Trim());
            }

            if (this.purchaseMethodSelectComboBox.Enabled)
            {
                switch ((EPurchaseMethodIndex)this.purchaseMethodSelectComboBox.SelectedIndex)
                {
                case EPurchaseMethodIndex.CASH:
                    p = new Cash(
                        this.currencyInputComboBox.Text);
                    break;

                case EPurchaseMethodIndex.CARD:
                    p = new Card(
                        this.cardTypeInputComboBox.SelectedIndex == 0 ? true : false,
                        this.providerInputTextBox.Text.Trim(),
                        int.Parse(this.cardNumberMaskedTextBox.Text),
                        this.cardNameInputTextBox.Text.Trim());
                    break;

                case EPurchaseMethodIndex.DIRECT_DEPOSIT:
                    p = new DirectDeposit(
                        this.accountTypeInputComboBox.SelectedIndex == 0 ? true : false,
                        this.bankNameInputTextBox.Text.Trim(),
                        int.Parse(this.accountNumberInputMaskedTextBox.Text),
                        this.accountNameInputTextBox.Text.Trim());
                    break;

                default:
                    Console.WriteLine("Error: unhandled purchase method passed");
                    throw new InvalidEnumArgumentException("Error: unhandled purchase method passed");
                }
            }
            else
            {
                p = null;
            }

            if (this.ExpenseFilter == null)
            {
                this.ExpenseFilter = new ExpenseFilter(
                    name,
                    maxValue,
                    minValue,
                    maxDate,
                    minDate,
                    places,
                    tags,
                    keywords,
                    p);
            }
            else
            {
                this.ExpenseFilter.MinValue = minValue;
                this.ExpenseFilter.MaxValue = maxValue;
                this.ExpenseFilter.MinDate  = minDate;
                this.ExpenseFilter.MaxDate  = maxDate;
                this.ExpenseFilter.Place    = places;
                this.ExpenseFilter.Tag      = tags;
                this.ExpenseFilter.Keywords = keywords;
                this.ExpenseFilter.Method   = p;
            }

            // Set the ok result and close the form.
            this.DialogResult = DialogResult.OK;
            this.Close();
        }