示例#1
0
        void cb_SelectedIndexChanged(object sender, EventArgs e)
        {
            ComboBox     cmb = (ComboBox)sender;
            comboBoxItem cbi = (comboBoxItem)cmb.SelectedItem;

            ((TextBox)cmb.Tag).Text = cbi.value;
        }
示例#2
0
文件: Add.cs 项目: paradoxUA/webtest
        private void fillOwners(bool showAll, int idUser = -1)
        {
            // добавить карту можно только пользователю, не имеющему карты
            IEnumerable <users> users;

            if (showAll)
            {
                users = (from u in admin.model.getUsers()
                         where u.id == idUser ||
                         u.DiscountCards.Count == 0
                         select u).OrderBy(m => m.nickname);
            }
            else
            {
                users = admin.model.getUsers().Where(m => m.DiscountCards.Count == 0).OrderBy(m => m.nickname);
            }

            owner_comboBox1.Items.Clear();

            foreach (users item in users)
            {
                string name = item.name + " " + item.surname + " [" + item.nickname + "]";
                ci = new comboBoxItem(name, item.id);
                owner_comboBox1.Items.Add(ci);
            }
        }
示例#3
0
        private void fillDiscountCardTypies()
        {
            IEnumerable <DiscountCardGroup> cardGroups = admin.model.getCardsTypies().Where(m => m.IsDeleted != true);

            cardGroup_comboBox1.Items.Clear();
            foreach (DiscountCardGroup item in cardGroups)
            {
                ci = new comboBoxItem(item.PercentOfDiscount.ToString(), item.Id);
                cardGroup_comboBox1.Items.Add(ci);
            }
        }
示例#4
0
        private void fillTracks()
        {
            List <Hashtable> Tracks = admin.model.GetAllTracks();

            for (int i = 0; i < Tracks.Count; i++)
            {
                ci = new comboBoxItem(Convert.ToString(Tracks[i]["name"]),
                                      Convert.ToInt32(Tracks[i]["id"]));

                tracks_comboBox.Items.Add(ci);
            }
        }
示例#5
0
        bool IsHalfModesEnabled = false; // разрешены ли заезды на половину времени заезда

        public CashOperations(int ID, RaceClass R, AdminControl ad, double sale = 0)
        {
            InitializeComponent();
            admin = ad;

            discountCard = null;

            PilotID = ID;
            User    = admin.model.GetPilot(PilotID);

            int idDefaultRaceMode = Convert.ToInt32(admin.Settings["default_race_mode_id"]);

            Race = R;
            int idGroup = Convert.ToInt32(User["gr"]);

            Sum = Convert.ToDouble(admin.GetPrice(admin.GetWeekDayNumber(R.Date),
                                                  Convert.ToInt32(R.Hour), idDefaultRaceMode, idGroup));//  R.RaceSum;


            //       ci = new comboBoxItem(null, -1);
            //       ci.selectComboBoxValueById(userSelectedMode_comboBox1, idDefaultRaceMode);
            // userSelectedMode_comboBox1.SelectedIndex = 0;

            labelSmooth1.Text           = "Полная стоимость билета - " + Sum.ToString() + " грн";
            cashFromPilot_textBox3.Text = priceForCurrentRace_textBox5.Text = Sum.ToString();
            certificateDiscount         = sale;

            LoadData();


            InSale      = labelSmooth5.Visible = userSelectedMode_comboBox1.Visible = Convert.ToBoolean(admin.Settings["racesale"] ?? false);
            sale_onelap = Convert.ToInt32(admin.Settings["sale_onelap"] ?? 0);
            sale_half   = Convert.ToInt32(admin.Settings["sale_half"] ?? 0);

            IsHalfModesEnabled = priceForHalfMode_label.Visible = halfModes_comboBox.Visible = Convert.ToBoolean(admin.Settings["halfModesEnabled"] ?? false);

            #region заполним список режимов заезда

            List <Hashtable> data = admin.model.GetAllRaceModes(" and is_deleted <> 1 ");
            halfModes_comboBox.Items.Clear();
            for (int i = 0; i < data.Count; i++)
            {
                comboBoxItem someItem =
                    new comboBoxItem(Convert.ToString(data[i]["name"]),
                                     Convert.ToInt32(data[i]["id"]));

                halfModes_comboBox.Items.Add(someItem);
            }

            ci.selectComboBoxValueById(halfModes_comboBox, idDefaultRaceMode);

            #endregion
        }
示例#6
0
        private void fillDiscountCards(int idPilot = -1)
        {
            cards_comboBox2.Items.Clear();

            ci = new comboBoxItem("[нет]",
                                  -1);

            cards_comboBox2.Items.Add(ci);
            cards_comboBox2.SelectedIndex = 0;

            IEnumerable <model.DiscountCard> cards;

            // режим редактирования
            if (idPilot > -1)
            {
                // получить все неназначенные и свою
                cards = (from ca in admin.model.getAllDiscountCards()
                         where
                         ca.owner == null || ca.idOwner == idPilot
                         select ca).OrderBy(m
                                            => m.Number);
            }
            else
            {
                // получить все неназначенные
                cards = admin.model.getAllDiscountCards().Where(m =>
                                                                m.owner == null).OrderBy(m => m.Number);
            }


            for (int i = 0; i < cards.Count(); i++)
            {
                ci = new comboBoxItem(cards.ElementAt(i).Number,
                                      cards.ElementAt(i).Id);

                cards_comboBox2.Items.Add(ci);
            }

            if (idPilot != -1)
            {
                model.DiscountCard userCard =
                    (from ca in admin.model.getAllDiscountCards()
                     where ca.idOwner == idPilot
                     select ca).Take(1).SingleOrDefault();

                if (userCard != null)
                {
                    ci.selectComboBoxValueById(cards_comboBox2, userCard.Id);
                }
            }
        }
示例#7
0
        // заполним список режимов заезда
        private void fillRaceModes()
        {
            defaultRaceMode_comboBox6.Items.Clear();

            List <Hashtable> data = parent.admin.model.GetAllRaceModes(" and is_deleted <> 1 ");

            for (int i = 0; i < data.Count; i++)
            {
                comboBoxItem someItem =
                    new comboBoxItem(Convert.ToString(data[i]["name"]),
                                     Convert.ToInt32(data[i]["id"]));

                defaultRaceMode_comboBox6.Items.Add(someItem);
            }
        }
示例#8
0
        private void fillRaceModes()
        {
            List <Hashtable> data = parent.admin.model.GetAllRaceModes(" and is_deleted <> 1 ");

            for (int i = 0; i < data.Count; i++)
            {
                comboBoxItem someItem =
                    new comboBoxItem(Convert.ToString(data[i]["name"]),
                                     Convert.ToInt32(data[i]["id"]));

                raceMode_comboBox1.Items.Add(someItem);
            }

            comboBoxItem ci = new comboBoxItem("", -1);

            ci.selectComboBoxValueById(raceMode_comboBox1, Convert.ToInt32(parent.admin.Settings["default_race_mode_id"]));
        }
示例#9
0
        public DayStatistic(AdminControl ad, int page)
        {
            InitializeComponent();


            admin = ad;

            #region pagelister для Журнала заездов

            Pages = new PageLister(pageNumber_toolStripComboBox, firstPage_toolStripButton11, previousPage_toolStripButton12, nextPage_toolStripButton9, lastPage_toolStripButton10);

            Pages.PageSize          = 25;
            Pages.CurrentPageNumber = 1;
            pageSize_toolStripComboBox2.SelectedIndex = pageSize_toolStripComboBox2.Items.IndexOf("25");

            #endregion


            tabControl1.SelectedIndex = page;

            // dateTimePicker1.Value = dateTimePicker2.Value = DateTime.Now.Date;
            ci = new comboBoxItem("", -1);
            tracks_comboBox1.Items.Add(ci);
            List <Hashtable> Tracks = admin.model.GetAllTracks();


            for (int i = 0; i < Tracks.Count; i++)
            {
                ci = new comboBoxItem(Convert.ToString(Tracks[i]["name"]),
                                      Convert.ToInt32(Tracks[i]["id"]));

                tracks_comboBox1.Items.Add(ci);
                // tracks_comboBox1.Items.Add(Tracks[i]["name"]);
            }

            ci.selectComboBoxValueById(tracks_comboBox1,
                                       Convert.ToInt32(ad.Settings["default_track"]));

            //  tracks_comboBox1.SelectedIndex = 0;

            /*
             * ci.selectComboBoxValueById(eventsInRacesJournal_comboBox,
             * Convert.ToInt32(ad.Settings["default_track"]));
             */

            //trackInRacesJournal_comboBox.SelectedIndex = 0;
            switch (page)
            {
            case 0: GetDaySatistic(); break;

            case 1: /*admin.ShowRaceJurnal(Pages, dataGridView1, dateTimePicker2.Value, dateTimePicker5.Value, eventsInRacesJournal_comboBox.SelectedIndex); RaceJurnalCalculate();*/ break;

            case 2: admin.ShowBestResults(top40_dataGridView, ci.getSelectedValue(tracks_comboBox1), top40Record_labelSmooth12, true);  break;

            case 3: GetAllUsersStatistic(); break;

            case 4: GetAllKartStatistic(); break;
            }


            if (!admin.IS_SUPER_ADMIN)
            {
                tabPage5.Parent = tabControl2_del;
                tabPage7.Parent = tabControl2_del;
                tabPage8.Parent = tabControl2_del;
            }
        }
示例#10
0
        // покажем настройки на форме
        private void LoadSettings()
        {
            fillRaceModes();

            // настройки транспондеров
            string path = "transetts.xml";

            if (File.Exists(path))
            {
                DataSet ds = new DataSet();

                ds.ReadXml(path);
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    dataGridView1.Rows.Add(row.ItemArray);
                    if (row.ItemArray[0].ToString().Trim().Length > 0)
                    {
                        comboBox3.Items.Add(row.ItemArray[0]);
                    }
                }
            }

            loadDbList();

            Hashtable sett = parent.admin.model.LoadSettings();

            // Закладка Общие настройки
            numericUpDown4.Value   = Convert.ToInt32(sett["time_start"]);
            numericUpDown5.Value   = Convert.ToInt32(sett["time_end"]);
            checkBox1.Checked      = Convert.ToBoolean(sett["time_wrap"]);
            numericUpDown1.Value   = Convert.ToInt32(sett["wrap_pos"]);
            checkBox8.Checked      = Convert.ToBoolean(sett["show_events"]);
            numericUpDown1.Enabled = checkBox1.Checked;
            checkBox6.Checked      = Convert.ToBoolean(sett["enter_password"]);
            numericUpDown7.Value   = Convert.ToInt32(sett["sertificat_day"]);
            checkBox9.Checked      = Convert.ToBoolean(sett["card_user"]);
            checkBox10.Checked     = Convert.ToBoolean(sett["beep_system"] ?? false);
            checkBox11.Checked     = Convert.ToBoolean(sett["beep_windows"] ?? false);
            showUniqueBestResults_checkBox.Checked = Convert.ToBoolean(sett["uniquebestres"] ?? false);


            // Закладка оборудование
            comboBox1.SelectedIndex = comboBox1.Items.IndexOf(sett["rs232_port"]);
            comboBox3.SelectedIndex = comboBox3.Items.IndexOf(sett["decoder"]);
            comboBox4.SelectedIndex = comboBox4.Items.IndexOf(sett["printer_result"]);
            comboBox5.SelectedIndex = comboBox5.Items.IndexOf(sett["printer_check"]);
            checkBox2.Checked       = Convert.ToBoolean(sett["print_check"]);

            // Закладка Гонка
            checkBox3.Checked = Convert.ToBoolean(sett["stop_on_pause"]);
            checkBox4.Checked = Convert.ToBoolean(sett["start_after_detection"]);
            checkBox5.Checked = Convert.ToBoolean(sett["print_result"]);
            checkBox7.Checked = Convert.ToBoolean(sett["show_zero_lap"]);
            minimumLapTime_numericUpDown2.Value = Convert.ToInt32(sett["noise_time"]);
            numericUpDown3.Value = Convert.ToInt32(sett["track_length"]);
            //numericUpDown6.Value = Convert.ToInt32(sett["race_time"]);

            // время гонки по умолчанию
            // заполнить список с временами гонки

            if (sett["default_race_mode_id"] != null)
            {
                comboBoxItem ci = new comboBoxItem("", -1);
                ci.selectComboBoxValueById(defaultRaceMode_comboBox6, Convert.ToInt32(sett["default_race_mode_id"]));
            }
            // defaultRaceMode_comboBox6.SelectedValue = sett["default_race_mode_id"];


            try
            {
                textBox1.Text = sett["fuel_on_lap"].ToString();
            }
            catch (Exception ex)
            {
            }

            comboBox2.SelectedIndex = comboBox2.Items.IndexOf(parent.admin.model.GetTrackName(sett["default_track"].ToString()));


            if (Convert.ToBoolean(sett["warm_subtract"]) == true)
            {
                checkBox14.Checked = true;
            }
            else
            {
                checkBox14.Checked = false;
            }

            numericUpDown8.Value = Convert.ToInt32(sett["warm_time"] ?? 0);

            // connection string
            Configuration config = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.None);

            connectionString_textBox9.Text = config.AppSettings.Settings["crazykartConnectionString"].Value;

            //Закладка временных скидок
            isTimeDiscountsAvailable_checkBox13.Checked = Convert.ToBoolean(sett["racesale"] ?? false);
            numericUpDown9.Value  = Convert.ToInt32(sett["sale_onelap"] ?? 0);
            numericUpDown10.Value = Convert.ToInt32(sett["sale_half"] ?? 0);

            isHalfModesEnabled_checkBox.Checked = Convert.ToBoolean(sett["halfModesEnabled"] ?? false);

            // Анонсер
            if (sett["images_for_anonser"] != null)
            {
                anonserImagesFolder_textBox9.Text = sett["images_for_anonser"].ToString();
            }
            else
            {
                anonserImagesFolder_textBox9.Text = "";
            }

            if (sett["sponsors_images_for_anonser"] != null)
            {
                sponsorsImagesFolder_textBox9.Text = sett["sponsors_images_for_anonser"].ToString();
            }
            else
            {
                sponsorsImagesFolder_textBox9.Text = "";
            }

            nextRacePilotsTimer_numericUpDown11.Value =
                Convert.ToInt32(sett["anonser_nextRacePilotsTimer"]);                                       // Показывает пилотов следующего рейса

            raceLoadTimer_numericUpDown12.Value      = Convert.ToInt32(sett["anonser_raceLoadTimer"]);      // Показывает загрузку рейса
            bestResultTimer_numericUpDown13.Value    = Convert.ToInt32(sett["anonser_bestResultTimer"]);    // Показывает лучший результат
            currentResultTimer_numericUpDown14.Value = Convert.ToInt32(sett["anonser_currentResultTimer"]); // время по кругам
            anonserImageRotator_numericUpDown2.Value = Convert.ToInt32(sett["anonser_imageRotateTimer"]);   // смена картинки, когда нет заезда

            sponsorsImagesRotator_numericUpDown2.Value = Convert.ToInt32(sett["sponsors_images_rotate_timer"]);
            sponsorsImagesFolder_textBox9.Text         = Convert.ToString(sett["sponsors_images_for_anonser"]);



            List <string> SettFromFile = parent.admin.LoadSettings();

            if (SettFromFile.Count > 0)
            {
                string[] MySQLData = parent.admin.ParseMySQLConfig(SettFromFile[0]);

                textBox2.Text = MySQLData[0];
                textBox3.Text = MySQLData[1];
                textBox4.Text = MySQLData[2];
                textBox5.Text = MySQLData[3];
                textBox6.Text = MySQLData[4];
            }
        }
示例#11
0
        // Сохранение настроек с формы в БД
        private void button2_Click(object sender, EventArgs e)
        {
            Hashtable sett = new Hashtable();

            InSave = true;
            // Закладка Общие настройки
            sett["time_start"]     = numericUpDown4.Value;
            sett["time_end"]       = numericUpDown5.Value;
            sett["time_wrap"]      = checkBox1.Checked;
            sett["wrap_pos"]       = numericUpDown1.Value;
            sett["show_events"]    = checkBox8.Checked;
            sett["enter_password"] = checkBox6.Checked;
            sett["sertificat_day"] = numericUpDown7.Value;
            sett["card_user"]      = checkBox9.Checked;
            sett["beep_system"]    = checkBox11.Checked;
            sett["beep_windows"]   = checkBox10.Checked;
            sett["uniquebestres"]  = showUniqueBestResults_checkBox.Checked;

            // Закладка оборудование
            if (comboBox1.SelectedIndex == -1)
            {
                sett["rs232_port"] = comboBox1.Items.Count == 0 ? "" : parent.admin.Settings["rs232_port"];
            }
            else
            {
                sett["rs232_port"] = comboBox1.Items[comboBox1.SelectedIndex];
            }
            sett["decoder"] = comboBox3.Items[comboBox3.SelectedIndex];

            sett["printer_check"]  = comboBox5.SelectedIndex >= 0 ? comboBox5.Items[comboBox5.SelectedIndex] : "";
            sett["printer_result"] = comboBox4.SelectedIndex >= 0 ? comboBox4.Items[comboBox4.SelectedIndex] : "";
            sett["print_check"]    = checkBox2.Checked;


            // Закладка Гонка
            sett["stop_on_pause"]         = checkBox3.Checked;
            sett["start_after_detection"] = checkBox4.Checked;
            sett["print_result"]          = checkBox5.Checked;
            sett["show_zero_lap"]         = checkBox7.Checked;
            sett["noise_time"]            = minimumLapTime_numericUpDown2.Value;
            sett["track_length"]          = numericUpDown3.Value;
            sett["fuel_on_lap"]           = textBox1.Text;
            sett["default_track"]         = comboBox2.SelectedIndex >= 0 ? parent.admin.model.GetTrackID(comboBox2.Items[comboBox2.SelectedIndex].ToString()) : 0;
            //  sett["race_time"] = numericUpDown6.Value;

            // время гонки по умолчанию
            comboBoxItem ci = new comboBoxItem("", -1);

            sett["default_race_mode_id"] = ci.getSelectedValue(defaultRaceMode_comboBox6); // defaultRaceMode_comboBox6.SelectedValue;

            sett["warm_subtract"] = checkBox14.Checked;
            sett["warm_time"]     = numericUpDown8.Value;


            // connection string
            // ConfigurationManager.AppSettings.Add("crazykartConnectionString", connectionString_textBox9.Text);//.ConnectionStrings["crazykartConnectionString"].ConnectionString = connectionString_textBox9.Text;
            // Configuration config =
            //     ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
            //  config.AppSettings.Settings.Remove("crazykartConnectionString");
            // config.AppSettings.Settings.Add("crazykartConnectionString", connectionString_textBox9.Text);
            //  ConfigurationManager.ConnectionStrings.Clear();
            Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

            // Properties.Settings.crazykartConnectionString = connectionString_textBox9.Text;
            config.AppSettings.Settings.Remove("crazykartConnectionString");
            config.AppSettings.Settings.Add("crazykartConnectionString", connectionString_textBox9.Text);
            //Save the configuration file.
            config.Save(ConfigurationSaveMode.Modified);
            ConfigurationManager.RefreshSection("appSettings");


            // Save the configuration file.
            //  config.Save(ConfigurationSaveMode.Modified, true);
            // Force a reload of a changed section.
            ConfigurationManager.RefreshSection("appSettings");
            // Settings.Default.crazykartConnectionString = MyNewValue;
            //  Settings.Default.Save();

            //Закладка временных скидок
            sett["racesale"]         = isTimeDiscountsAvailable_checkBox13.Checked;
            sett["halfModesEnabled"] = isHalfModesEnabled_checkBox.Checked;
            sett["sale_onelap"]      = numericUpDown9.Value;
            sett["sale_half"]        = numericUpDown10.Value;

            // анонсер
            sett["anonser_nextRacePilotsTimer"]  = nextRacePilotsTimer_numericUpDown11.Value; // Показывает пилотов следующего рейса
            sett["anonser_raceLoadTimer"]        = raceLoadTimer_numericUpDown12.Value;       // Показывает загрузку рейса
            sett["anonser_bestResultTimer"]      = bestResultTimer_numericUpDown13.Value;     // Показывает лучший результат
            sett["anonser_currentResultTimer"]   = currentResultTimer_numericUpDown14.Value;  // время по кругам
            sett["anonser_imageRotateTimer"]     = anonserImageRotator_numericUpDown2.Value;  // смена картинки, когда нет заезда
            sett["images_for_anonser"]           = anonserImagesFolder_textBox9.Text;
            sett["sponsors_images_for_anonser"]  = sponsorsImagesFolder_textBox9.Text;
            sett["sponsors_images_rotate_timer"] = sponsorsImagesRotator_numericUpDown2.Text;



            parent.admin.model.SaveSettings(sett);
        }
示例#12
0
        private void CalculateSumForPayment()
        {
            comboBoxItem ci      = new comboBoxItem("", -1);
            int          idGroup = Convert.ToInt32(User["gr"]);

            // узнали полную цену для этого времени, с учётом указанного количества кругов
            Sum = Convert.ToDouble(admin.GetPrice(admin.GetWeekDayNumber(Race.Date),
                                                  Convert.ToInt16(Race.Hour),
                                                  ci.getSelectedValue(halfModes_comboBox), idGroup));


            /* есть такие скидки - certificateSale - скидка по сертификату
             *  скидка на группу
             *  и скидка по скидочной карте.
             *  в расчёте должна быть учтена одна, максимальная
             */

            double discountCardDiscount = 0;

            if (discountCard != null && discountCard.IsBlocked == false)
            {
                discountCardDiscount = ((finalSum * (double)((double)discountCard.DiscountCardGroup.PercentOfDiscount / 100)));
            }

            double maximumDiscount = discountCardDiscount;

            if (certificateDiscount > discountCardDiscount)
            {
                maximumDiscount = certificateDiscount;
            }

            if (groupDiscount > maximumDiscount)
            {
                maximumDiscount = groupDiscount;
            }


            /*
             * priceForCurrentRace_textBox5.Text = priceForHalfMode;
             * cashFromPilot_textBox3.Text = priceForHalfMode;
             * finalSum = Convert.ToInt16(priceForHalfMode);
             */


            finalSum = (Math.Round(Sum - (Sum * (maximumDiscount / 100)), 2));

            /*
             * if (InSale && userSelectedMode_comboBox1.SelectedIndex > 0)
             * {
             *
             *  switch (userSelectedMode_comboBox1.SelectedIndex)
             *  {
             *      case 1:
             *          if (sale_onelap > 0)
             *          {
             *              finalSum = (finalSum * (double)((double)sale_onelap / 100));
             *          }
             *          break;
             *      case 2: if (sale_half > 0)
             *          {
             *              finalSum = (finalSum * (double)((double)sale_half / 100));
             *          }
             *          break;
             *  }
             *
             * }
             */



            //    if (Sale != 0)
            //     {
            finalSum = SimpleRound(finalSum);     // округлить до 5 грн вверх
            //     }

            if (finalSum < 0)
            {
                finalSum = 0;
            }

            priceForCurrentRace_textBox5.Text = cashFromPilot_textBox3.Text = finalSum.ToString();

            radioButton1.Enabled = UserCash >= finalSum;

            refreshRestMoney();
        }