示例#1
0
        private void buttonAddDiscount_Click(object sender, EventArgs e)
        {
            DateTime start = DateTime.Parse(dateTimePickerStartDate.Value.ToString("yyyy.MMMM.dd") + " " + dateTimePickerStartTime.Value.ToString("HH:mm"));
            DateTime end = DateTime.Parse(dateTimePickerEndDate.Value.ToString("yyyy.MMMM.dd") + " " + dateTimePickerEndTime.Value.ToString("HH:mm"));
            string auditory = comboBoxAuditory.Text;
            MessageBox.Show(start.ToString());
            MessageBox.Show(end.ToString());
            string name = textBoxDiscountName.Text;
            string playstations = textBoxPlaystations.Text;
            double discountSize = (double)numericUpDownDiscountSize.Value;

            if (!string.IsNullOrEmpty(name) &&
                checkedListBoxTimeZones.SelectedItem != null &&
                start < end &&
                !string.IsNullOrEmpty(auditory) &&
                TypeOfBonusSelected())
            {
                Table<discounts_t> discountsT = db.GetTable<discounts_t>();
                discounts_t disc = new discounts_t();
                disc.discount_reason = name;
                disc.startDate = start;
                disc.endDate = end;
                disc.discount_playstation_ids = textBoxPlaystations.Text;
                disc.discount_auditory = auditory;
                disc.discount_timezones = TimeZonesMerger();
                if (radioButtonBonusType.Checked)
                {
                    if (checkBoxRequiredHours.Checked)
                    {
                        TimeSpan RequiredTimeToBuy = new TimeSpan(0,int.Parse(numericUpDownRequiredPaidHours.Text), int.Parse(numericUpDownRequiredPaidMinutes.Text), 0);

                        disc.required_hours_for_bonus = RequiredTimeToBuy;
                    }
                    else
                    {
                        disc.required_hours_for_bonus = new TimeSpan(0,0,0,0,0);
                    }

                    if (checkBoxRequiredItem.Checked)
                    {
                        disc.required_item_to_buy = comboBoxRequiredItem.Text;
                        disc.number_of_required_items = int.Parse(numericUpDownRequiredNumberOfItem.Text);
                    }
                    else
                    {
                        disc.required_item_to_buy = "";
                        disc.number_of_required_items = 0;
                    }

                    if (checkBoxBonusHours.Checked)
                    {
                        TimeSpan BonusTime = TimeSpan.Parse(numericUpDownBonusHours.Text + ":" + numericUpDownBonusMinutes.Text);
                        disc.bonus_hours = BonusTime;
                    }
                    else
                    {
                        disc.bonus_hours = new TimeSpan(0, 0, 0, 0, 0);
                    }

                    if (checkBoxBonusItem.Checked)
                    {
                        disc.bonus_item = comboBoxBonusItem.Text;
                        disc.number_of_bonus_item = int.Parse(numericUpDownNumberOfBonusItem.Text);
                    }
                    else
                    {
                        disc.bonus_item = "";
                        disc.number_of_bonus_item = 0;
                    }

                    if (checkBoxPriceDiscount.Checked)
                    {
                        disc.price_discount = double.Parse(numericUpDownPriceDiscount.Text);
                    }
                    else
                    {
                        disc.price_discount = 0.00;
                    }
                    disc.discountSize = 0;
                }
                else if (radioButtonPercentage.Checked)
                {
                    disc.discountSize = (float)discountSize;

                    disc.bonus_hours = new TimeSpan(0,0,0,0,0);
                    disc.bonus_item = "";
                    disc.number_of_bonus_item = 0;
                    disc.number_of_required_items = 0;
                    disc.price_discount = 0;
                    disc.required_hours_for_bonus = new TimeSpan(0,0,0,0,0);
                    disc.required_item_to_buy = "";
                }
                else
                {
                    MessageBox.Show("Please select one of discount types.");
                }
                try
                {
                    discountsT.InsertOnSubmit(disc);
                    db.SubmitChanges();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
                UpdateAddDiscountForm();
            }
        }
示例#2
0
 partial void Updatediscounts_t(discounts_t instance);
示例#3
0
 partial void Deletediscounts_t(discounts_t instance);
示例#4
0
 partial void Insertdiscounts_t(discounts_t instance);