Ejemplo n.º 1
0
 private void UpdateTable()
 {
     dgvFaculties.Rows.Clear();
     foreach (object[] v in _DB_Connection.Select(DB_Table.FACULTIES))
     {
         dgvFaculties.Rows.Add(v);
     }
 }
Ejemplo n.º 2
0
 private void UpdateTable()
 {
     dgvTargetOrganizations.Rows.Clear();
     foreach (object[] v in _DB_Connection.Select(DB_Table.TARGET_ORGANIZATIONS, "id", "name"))
     {
         dgvTargetOrganizations.Rows.Add(v);
     }
     dgvTargetOrganizations.Sort(dgvTargetOrganizations_Name, System.ComponentModel.ListSortDirection.Ascending);
 }
Ejemplo n.º 3
0
 private void UpdateTable()
 {
     dgvAchievements.Rows.Clear();
     foreach (var record in _DB_Connection.Select(DB_Table.INSTITUTION_ACHIEVEMENTS, new string[] { "id", "name", "category_dict_id",
                                                                                                    "category_id", "value" }, new List <Tuple <string, Relation, object> >
     {
         new Tuple <string, Relation, object>("campaign_id", Relation.EQUAL, _LoadedCampaign)
     }))
     {
         dgvAchievements.Rows.Add(record[0], record[1], record[4], _DB_Helper.GetDictionaryItemName((FIS_Dictionary)record[2], (uint)record[3]), record[3]);
     }
 }
Ejemplo n.º 4
0
        public MADIOlymps(DB_Connector connection, Forms.ApplicationEdit.MODoc olympData)
        {
            InitializeComponent();

            _DB_Connection = connection;
            _DB_Helper     = new DB_Helper(_DB_Connection);

            List <string> olympsNames = new List <string>();

            foreach (object[] olymp in _DB_Connection.Select(DB_Table.DICTIONARY_19_ITEMS, new string[] { "olympic_name" }, new System.Collections.Generic.List <Tuple <string, Relation, object> >
            {
                new Tuple <string, Relation, object>("year", Relation.GREATER_EQUAL, DateTime.Now.Year - 1)
            }))
            {
                olympsNames.Add(olymp[0].ToString());
            }
            foreach (string name in olympsNames.Distinct())
            {
                cbOlympName.Items.Add(name);
            }

            if (olympData.olympName != null && olympData.olympName != "")
            {
                cbOlympName.Text    = olympData.olympName;
                OlympName           = olympData.olympName;
                tbOrganization.Text = olympData.olypmOrg;
                OlympOrg            = olympData.olypmOrg;
                dtpDate.Value       = olympData.olympDate;
                OlympDate           = olympData.olympDate;
            }
        }
Ejemplo n.º 5
0
Archivo: Olymps.cs Proyecto: SahsaB/pk
        public Olymps(DB_Connector connection, ApplicationEdit parent)
        {
            InitializeComponent();

            _DB_Connection = connection;
            _DB_Helper     = new DB_Helper(_DB_Connection);
            _Parent        = parent;

            cbDiplomaType.Items.AddRange(_DB_Helper.GetDictionaryItems(FIS_Dictionary.DIPLOMA_TYPE).Values.ToArray());
            cbClass.SelectedItem = "10";
            cbDiscipline.Items.AddRange(_DB_Helper.GetDictionaryItems(FIS_Dictionary.SUBJECTS).Values.ToArray());
            cbCountry.Items.AddRange(_DB_Helper.GetDictionaryItems(FIS_Dictionary.COUNTRY).Values.ToArray());

            Forms.ApplicationEdit.ODoc loadedDocument = _Parent.OlympicDoc;

            if ((loadedDocument.olympType != null) && (loadedDocument.olympType != ""))
            {
                cbOlympType.SelectedItem = loadedDocument.olympType;
                tbDocNumber.Text         = loadedDocument.olympDocNumber.ToString();

                if ((loadedDocument.diplomaType != null) && (loadedDocument.diplomaType != ""))
                {
                    cbDiplomaType.SelectedItem = loadedDocument.diplomaType;
                }

                if (loadedDocument.olympID != 0)
                {
                    tbOlympID.Text            = loadedDocument.olympID.ToString();
                    cbOlympName.SelectedIndex = cbOlympName.FindString(_DB_Connection.Select(DB_Table.DICTIONARY_19_ITEMS, new string[] { "olympic_name" }, new System.Collections.Generic.List <Tuple <string, Relation, object> >
                    {
                        new Tuple <string, Relation, object>("olympic_id", Relation.EQUAL, loadedDocument.olympID)
                    })[0][0].ToString());
                    cbOlympProfile.SelectedIndex = cbOlympProfile.FindString(loadedDocument.olympProfile);
                }
                else
                {
                    if (loadedDocument.olympName != null)
                    {
                        cbOlympName.Text = loadedDocument.olympName;
                    }
                    cbOlympProfile.SelectedItem = loadedDocument.olympProfile;
                }

                if (loadedDocument.olympClass != 0)
                {
                    cbClass.SelectedItem = loadedDocument.olympClass.ToString();
                }

                if ((loadedDocument.olympDist != null) && (loadedDocument.olympDist != ""))
                {
                    cbDiscipline.SelectedItem = loadedDocument.olympDist;
                }

                if ((loadedDocument.country != null) && (loadedDocument.country != ""))
                {
                    cbCountry.SelectedItem = loadedDocument.country;
                }
            }
        }
Ejemplo n.º 6
0
        private void btSave_Click(object sender, EventArgs e)
        {
            string[] fields = { "min_math_mark", "min_russian_mark", "min_physics_mark", "min_social_mark", "min_foreign_mark" };
            object[] buf    = _DB_Connection.Select(DB_Table.CONSTANTS, fields)[0];

            Dictionary <string, object> values = new Dictionary <string, object>(fields.Length);

            Dictionary <string, object> where = new Dictionary <string, object>(fields.Length);
            for (byte i = 0; i < fields.Length; ++i)
            {
                values.Add(fields[i], dgvConstants[dgvConstants_Value.Index, i].Value);
                where.Add(fields[i], buf[i]);
            }

            _DB_Connection.Update(DB_Table.CONSTANTS, values, where);
            Close();
        }
Ejemplo n.º 7
0
Archivo: Orders.cs Proyecto: SahsaB/pk
        private void toolStrip_Register_Click(object sender, EventArgs e)
        {
            OrderRegistration form = new OrderRegistration(_DB_Connection, SelectedOrderNumber);

            if (form.ShowDialog() == DialogResult.OK)
            {
                dataGridView.SelectedRows[0].Cells[dataGridView_ProtNumber.Index].Value = _DB_Connection.Select(
                    DB_Table.ORDERS,
                    new string[] { "protocol_number" },
                    new List <Tuple <string, Relation, object> > {
                    new Tuple <string, Relation, object>("number", Relation.EQUAL, SelectedOrderNumber)
                }
                    )[0][0];

                ToggleButtons();
            }
        }
Ejemplo n.º 8
0
        private void UpdateTableAndCombobox()
        {
            dgvCampaigns.Rows.Clear();
            List <object[]> campaigns = _DB_Connection.Select(DB_Table.CAMPAIGNS,
                                                              new string[] { "id", "name", "start_year", "end_year", "status_dict_id", "status_id" });

            foreach (object[] v in campaigns)
            {
                dgvCampaigns.Rows.Add(v[0], v[1], v[2].ToString() + " - " + v[3].ToString(), "", _DB_Helper.GetDictionaryItemName((FIS_Dictionary)v[4], (uint)v[5]));

                foreach (object[] r in _DB_Connection.Select(DB_Table._CAMPAIGNS_HAS_DICTIONARIES_ITEMS, new string[] { "dictionaries_items_item_id" },
                                                             new List <Tuple <string, Relation, object> >
                {
                    new Tuple <string, Relation, object>("dictionaries_items_dictionary_id", Relation.EQUAL, (uint)FIS_Dictionary.EDU_LEVEL),
                    new Tuple <string, Relation, object>("campaigns_id", Relation.EQUAL, dgvCampaigns.Rows[dgvCampaigns.Rows.Count - 1].Cells[0].Value)
                }))
                {
                    string levelName = _DB_Helper.GetDictionaryItemName(FIS_Dictionary.EDU_LEVEL, (uint)r[0]);

                    if (dgvCampaigns.Rows[dgvCampaigns.Rows.Count - 1].Cells[3].Value.ToString() == "")
                    {
                        dgvCampaigns.Rows[dgvCampaigns.Rows.Count - 1].Cells[3].Value = levelName;
                    }
                    else
                    {
                        dgvCampaigns.Rows[dgvCampaigns.Rows.Count - 1].Cells[3].Value = dgvCampaigns.Rows[dgvCampaigns.Rows.Count - 1].Cells[3].Value.ToString() + " - " + levelName;
                    }
                }
            }
            cbCurrentCampaign.ValueMember   = "Value";
            cbCurrentCampaign.DisplayMember = "Display";
            cbCurrentCampaign.DataSource    = campaigns.Select(s => new
            {
                Value   = (uint)s[0],
                Display = s[1].ToString()
            }).ToArray();

            if (Classes.Settings.CurrentCampaignID != 0)
            {
                cbCurrentCampaign.SelectedValue = Classes.Settings.CurrentCampaignID;
            }
            else
            {
                cbCurrentCampaign.SelectedIndex = -1;
            }
        }
Ejemplo n.º 9
0
Archivo: Main.cs Proyecto: SahsaB/pk
        private void CreateApplication_Click(object sender, EventArgs e)
        {
            if (Classes.Settings.CurrentCampaignID == 0)
            {
                MessageBox.Show("Не выбрана текущая кампания. Перейдите в Главное меню -> Приемная кампания -> Приемные кампании.");
            }
            else
            {
                StopTableAutoUpdating();
                Form form;
                if (_MasterCampaign)
                {
                    form = new ApplicationMagEdit(_DB_Connection, Classes.Settings.CurrentCampaignID, _UserLogin, null);
                }
                else
                {
                    List <object[]> campaidnEduLevels = _DB_Connection.Select(DB_Table._CAMPAIGNS_HAS_DICTIONARIES_ITEMS, new string[] { "dictionaries_items_item_id" },
                                                                              new List <Tuple <string, Relation, object> >
                    {
                        new Tuple <string, Relation, object>("campaigns_id", Relation.EQUAL, Classes.Settings.CurrentCampaignID),
                        new Tuple <string, Relation, object>("dictionaries_items_dictionary_id", Relation.EQUAL, (uint)FIS_Dictionary.EDU_LEVEL)
                    });
                    bool spo = false;
                    foreach (object[] eduLevel in campaidnEduLevels)
                    {
                        if (DB_Helper.EduLevelSPO == _DB_Helper.GetDictionaryItemName(FIS_Dictionary.EDU_LEVEL, (uint)eduLevel[0]))
                        {
                            spo = true;
                        }
                    }
                    if (spo)
                    {
                        form = new ApplicationSPOEdit(_DB_Connection, Classes.Settings.CurrentCampaignID, _UserLogin, null);
                    }
                    else
                    {
                        form = new ApplicationEdit(_DB_Connection, Classes.Settings.CurrentCampaignID, _UserLogin, null);
                    }
                }

                form.ShowDialog();
                UpdateApplicationsTable();
                timer.Start();
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Selects all projects.
        /// </summary>
        /// <param name="conn">The database connection.</param>
        /// <returns>The Riviera project</returns>
        public static IEnumerable <RivieraProject> SelectProjects(DB_Connector conn)
        {
            QueryBuilder qB = new QueryBuilder(TABLENAME, conn);

            qB.AddSelectionColumn();
            String query = qB.GetQuery();

            return(conn.Select <RivieraProject>(query));
        }
Ejemplo n.º 11
0
        private static string SelectByPlaceholder(DB_Connector connection, uint id, string placeholder)
        {
            string[] placeholderAndFunction = placeholder.Split('|');
            string[] placeholderValue       = _PH_Single[placeholderAndFunction[0]].Split('.', ':');

            List <System.Tuple <string, Relation, object> > whereClause;

            if (placeholderValue.Length == 2)
            {
                whereClause = new List <System.Tuple <string, Relation, object> >
                {
                    new System.Tuple <string, Relation, object>("id", Relation.EQUAL, id)
                }
            }
            ;
            else
            {
                whereClause = new List <System.Tuple <string, Relation, object> >();
                string[] equalities = placeholderValue[2].Split(',');
                foreach (string equality in equalities)
                {
                    string[] parts = equality.Split('=');

                    string rightValue;
                    if (parts[1][0] == '@')
                    {
                        rightValue = SelectByPlaceholder(connection, id, parts[1].Substring(1)); //TODO group?
                    }
                    else
                    {
                        rightValue = parts[1];
                    }

                    whereClause.Add(new System.Tuple <string, Relation, object>(parts[0], Relation.EQUAL, rightValue));
                }
            }
            var selectRes = connection.Select(
                (DB_Table)System.Enum.Parse(typeof(DB_Table), placeholderValue[0], true),
                new string[] { placeholderValue[1] },
                whereClause
                );

            if (selectRes.Count != 1)
            {
                throw new System.Exception("По условию Placeholder возвращена не одна строка. Значение: " + placeholder);
            }

            if (placeholderAndFunction.Length == 1)
            {
                return(selectRes[0][0].ToString());
            }
            else
            {
                return(_PH_Functions[placeholderAndFunction[1]](selectRes[0][0]));
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Selects the project.
        /// </summary>
        /// <param name="userId">The user identifier.</param>
        /// <param name="projectName">Name of the project.</param>
        /// <param name="conn">The database connection.</param>
        /// <returns>The Riviera project</returns>
        public static RivieraProject SelectProject(int userId, String projectName, DB_Connector conn)
        {
            QueryBuilder qB = new QueryBuilder(TABLENAME, conn);

            qB.AddSelectionColumn();
            qB.AddEqualCondition(FIELD_USERID, userId, "AND");
            qB.AddEqualCondition(FIELD_NAME, projectName);
            String query = qB.GetQuery();

            return(conn.Select <RivieraProject>(query).FirstOrDefault());
        }
Ejemplo n.º 13
0
        public FaculityDirectionsSelect(DB_Connector connection, string shortName)
        {
            InitializeComponent();

            _DB_Connection    = connection;
            _FacultyShortName = shortName;

            foreach (object[] v in _DB_Connection.Select(DB_Table.DICTIONARY_10_ITEMS, "id", "name", "code"))
            {
                if (v[2].ToString().Substring(3, 2) == "03")
                {
                    dgvDirections_.Rows.Add(v[0], false, v[1], v[2], "Бакалавриат");
                }
                else if (v[2].ToString().Substring(3, 2) == "04")
                {
                    dgvDirections_.Rows.Add(v[0], false, v[1], v[2], "Магистратура");
                }
                else if (v[2].ToString().Substring(3, 2) == "05")
                {
                    dgvDirections_.Rows.Add(v[0], false, v[1], v[2], "Специалитет");
                }
                else if (v[2].ToString().Substring(3, 2) == "02")
                {
                    dgvDirections_.Rows.Add(v[0], false, v[1], v[2], "СПО");
                }
            }

            foreach (object[] v in _DB_Connection.Select(DB_Table.DIRECTIONS,
                                                         "faculty_short_name", "direction_id", "short_name"))
            {
                foreach (DataGridViewRow r in dgvDirections_.Rows)
                {
                    if ((r.Cells[0].Value.ToString() == v[1].ToString()) && (v[0].ToString() == _FacultyShortName))
                    {
                        r.Cells[1].Value = true;
                        r.Cells[5].Value = v[2].ToString();
                    }
                }
            }
            dgvDirections_.Sort(dgvDirections_.Columns[dgvDirections_Code.Index], System.ComponentModel.ListSortDirection.Ascending);
        }
Ejemplo n.º 14
0
        public TargetOrganizationEdit(DB_Connector connection, uint organizationCode)
        {
            InitializeComponent();

            _DB_Connection           = connection;
            _UpdatingCode            = organizationCode;
            rtbOrganizationName.Text = _DB_Connection.Select(DB_Table.TARGET_ORGANIZATIONS, new string[] { "name" },
                                                             new List <Tuple <string, Relation, object> >
            {
                new Tuple <string, Relation, object>("id", Relation.EQUAL, _UpdatingCode)
            })[0][0].ToString();
        }
Ejemplo n.º 15
0
        public OrderRegistration(DB_Connector connection, string number)
        {
            _DB_Connection = connection;

            #region Components
            InitializeComponent();

            tbNumber.Text = (_DB_Connection.Select(DB_Table.ORDERS, "protocol_number").Max(s => s[0] as ushort? != null ? (ushort)s[0] : 1)).ToString();
            #endregion

            _Number = number;
        }
Ejemplo n.º 16
0
        public TargetOrganizationSelect(DB_Connector connection, uint?orgID)
        {
            InitializeComponent();

            _DB_Connection = connection;
            OrganizationID = orgID;

            foreach (object[] v in _DB_Connection.Select(DB_Table.TARGET_ORGANIZATIONS, "id", "name"))
            {
                _All_Items.Add((uint)v[0], v[1].ToString());
                lbSelection.Items.Add(v[1]);
            }
            if (OrganizationID != null)
            {
                tbSearchString.Text = _DB_Connection.Select(DB_Table.TARGET_ORGANIZATIONS, new string[] { "name" }, new List <Tuple <string, Relation, object> >
                {
                    new Tuple <string, Relation, object>("id", Relation.EQUAL, OrganizationID)
                })[0][0].ToString();
            }
            tbSearchString.Select();
        }
Ejemplo n.º 17
0
 public Constants(DB_Connector connection, uint campaignID)
 {
     InitializeComponent();
     _DB_Connection         = connection;
     _DB_Helper             = new DB_Helper(_DB_Connection);
     _CurrCampaignID        = campaignID;
     lbCurrentCampaign.Text = _DB_Connection.Select(DB_Table.CAMPAIGNS, new string[] { "name" }, new List <Tuple <string, Relation, object> >
     {
         new Tuple <string, Relation, object>("id", Relation.EQUAL, _CurrCampaignID)
     })[0][0].ToString();
     UpdateTable();
 }
Ejemplo n.º 18
0
 private void btSave_Click(object sender, EventArgs e)
 {
     if (cbDirections.SelectedIndex == -1)
     {
         MessageBox.Show("Не выбрано направление.");
     }
     else if (cbFaculties.SelectedIndex == -1)
     {
         MessageBox.Show("Не выбран факультет.");
     }
     else if (tbName.Text == "")
     {
         MessageBox.Show("Не указано название профиля.");
     }
     else if (tbShortName.Text == "")
     {
         MessageBox.Show("Не указано сокращенное название профиля.");
     }
     else if (rbMag.Checked && tbKafedra.Text == "")
     {
         MessageBox.Show("Не указана кафедра.");
     }
     else if (_DB_Connection.Select(DB_Table.PROFILES, new string[] { "direction_id" }, new List <Tuple <string, Relation, object> >
     {
         new Tuple <string, Relation, object>("short_name", Relation.EQUAL, tbShortName.Text)
     }).Count > 0)
     {
         MessageBox.Show("Профиль/программа с таким сокращением уже существует.");
     }
     else
     {
         if (rbMag.Checked)
         {
             _DB_Connection.Insert(DB_Table.PROFILES, new Dictionary <string, object> {
                 { "faculty_short_name", cbFaculties.SelectedItem.ToString() },
                 { "direction_id", (cbDirections.SelectedValue as Tuple <uint, string>).Item1 },
                 { "name", tbName.Text + "|" + tbKafedra.Text }, { "short_name", tbShortName.Text }
             });
         }
         else
         {
             _DB_Connection.Insert(DB_Table.PROFILES, new Dictionary <string, object> {
                 { "faculty_short_name", cbFaculties.SelectedItem.ToString() },
                 { "direction_id", (cbDirections.SelectedValue as Tuple <uint, string>).Item1 },
                 { "name", tbName.Text }, { "short_name", tbShortName.Text }
             });
         }
         tbKafedra.Text       = "";
         tbName.Text          = "";
         tbShortName.Text     = "";
         btAddProfile.Enabled = true;
         EnableDisableControls(false);
         UpdateTable();
     }
 }
Ejemplo n.º 19
0
        /// <summary>
        /// Gets the ejecutivo.
        /// </summary>
        /// <param name="credential">The user credential.</param>
        /// <returns>The selected excutive</returns>
        public static int GetEjecutivoId(UserCredential credential, DB_Connector conn)
        {
            QueryBuilder qB = new QueryBuilder(TABLENAME, conn);

            qB.AddSelectionColumn();
            qB.AddEqualCondition(FIELD_ID, credential.Username, "AND");
            qB.AddEqualCondition(FIELD_PASS, credential.Password, "AND");
            qB.AddEqualCondition(FIELD_COMPANY, (int)credential.Company);
            String    query = qB.GetQuery();
            Ejecutivo e     = conn.Select <Ejecutivo>(query).FirstOrDefault();

            return(e != null ? e.Id : -1);
        }
Ejemplo n.º 20
0
        public Authorization()
        {
            #region Components
            InitializeComponent();

            cbLogin.Text = Properties.Settings.Default.Login;

            if (cbLogin.Text != "")
            {
                tbPassword.Select();
            }
            #endregion

            while (true)
            {
                try
                {
                    _DB_Connection = new DB_Connector(Properties.Settings.Default.pk_db_CS, "initial", "1234");
                }
                catch (MySql.Data.MySqlClient.MySqlException ex)
                {
                    if (ex.Number == 1042 && !SharedClasses.Utility.ShowChoiceMessageBox("Подключён ли кабель локальной сети к компьютеру?", "Ошибка подключения"))
                    {
                        MessageBox.Show("Выполните подключение.", "Ошибка подключения", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        continue; //TODO
                    }

                    MessageBox.Show("Обратитесь к администратору. Не закрывайте это сообщение.", "Ошибка подключения", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    MessageBox.Show("Информация об ошибке:\n" + ex.Message, "Ошибка подключения", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    if (SharedClasses.Utility.ShowChoiceMessageBox("Закрыть приложение?", "Действие"))
                    {
                        Load += (s, e) => DialogResult = DialogResult.Abort;
                        break;
                    }

                    continue;
                }

                foreach (var v in _DB_Connection.Select(DB_Table.USERS, "login"))
                {
                    cbLogin.Items.Add(v[0]);
                }

                AssureConstants();

                break;
            }
        }
Ejemplo n.º 21
0
        private void bAuth_Click(object sender, EventArgs e)
        {
            if (cbLogin.Text == "" || tbPassword.Text == "")
            {
                MessageBox.Show("Поля не могут быть пустыми.", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            List <object[]> results = _DB_Connection.Select(
                DB_Table.USERS,
                new string[] { "password", "role" },
                new List <Tuple <string, Relation, object> > {
                new Tuple <string, Relation, object>("login", Relation.EQUAL, cbLogin.Text)
            }
                );

            if (results.Count == 0)
            {
                MessageBox.Show("Логин не найден.", "Ошибка авторизации", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (results[0][0].ToString() == tbPassword.Text)
            {
                UsersRole  = results[0][1].ToString();
                UsersLogin = cbLogin.Text;

                Properties.Settings.Default.Login = cbLogin.Text;
                Properties.Settings.Default.Save();

                DialogResult = DialogResult.OK;
            }
            else
            {
                MessageBox.Show("Неверный пароль.", "Ошибка авторизации", MessageBoxButtons.OK, MessageBoxIcon.Error);
                tbPassword.Clear();
            }
        }
Ejemplo n.º 22
0
Archivo: Users.cs Proyecto: SahsaB/pk
        public Users(DB_Connector connection)
        {
            #region Components
            InitializeComponent();

            dataGridView_Phone.ValueType = typeof(ulong);
            #endregion

            _DB_Connection = connection;

            foreach (object[] row in _DB_Connection.Select(DB_Table.USERS))
            {
                dataGridView.Rows.Add(row);
            }
        }
Ejemplo n.º 23
0
        public ApplicationDocsPrint(DB_Connector connection, uint id)
        {
            InitializeComponent();

            _DB_Connection = connection;
            _ID            = id;

            cbAdmAgreement.Enabled = _DB_Connection.Select(
                DB_Table.APPLICATIONS_ENTRANCES,
                new string[] { "is_agreed_date", "is_disagreed_date" },
                new List <Tuple <string, Relation, object> > {
                new Tuple <string, Relation, object>("application_id", Relation.EQUAL, _ID)
            }
                ).Any(s => s[0] as DateTime? != null && s[1] as DateTime? == null);
            cbAdmAgreement.Checked = cbAdmAgreement.Enabled;
        }
Ejemplo n.º 24
0
        public InstitutionAchievementsEdit(DB_Connector connection)
        {
            InitializeComponent();

            _DB_Connection = connection;
            _DB_Helper     = new DB_Helper(_DB_Connection);

            foreach (var campaign in _DB_Connection.Select(DB_Table.CAMPAIGNS, "name"))
            {
                cbCampaign.Items.Add(campaign[0]);
            }

            cbAchievementType.DataSource    = new BindingSource(_DB_Helper.GetDictionaryItems(FIS_Dictionary.IND_ACH_CATEGORIES), null);
            cbAchievementType.DisplayMember = "Value";
            cbAchievementType.ValueMember   = "Value";
        }
Ejemplo n.º 25
0
        public DirectionSelect(DB_Connector connection, List <string> filters)
        {
            InitializeComponent();

            _DB_Connection = connection;
            _DB_Helper     = new DB_Helper(_DB_Connection);

            foreach (object[] item in _DB_Connection.Select(DB_Table.DIRECTIONS, "direction_id", "faculty_short_name"))
            {
                Tuple <string, string> dirData = _DB_Helper.GetDirectionNameAndCode((uint)item[0]);
                foreach (string v in filters)
                {
                    if (dirData.Item2.Split('.')[1] == v)
                    {
                        dgvDirectionSelection.Rows.Add(item[0], dirData.Item2, dirData.Item1, item[1]);
                    }
                }
            }
        }
Ejemplo n.º 26
0
        public MainForm()
        {
            InitializeComponent();

            //_DB_Connection = new DB_Connector("server = localhost; port = 3306; database = pk_db;"/*Properties.Settings.Default.pk_db_CS*/, "administrator", "adm1234");
            _DB_Connection = new DB_Connector("server = serv-priem; port = 3306; database = pk_db;" /*Properties.Settings.Default.pk_db_CS*/, "administrator", "adm1234");

            _DB_Helper = new DB_Helper(_DB_Connection);
            Dictionary <uint, string> campaigns = new Dictionary <uint, string>();

            foreach (object[] campaign in _DB_Connection.Select(DB_Table.CAMPAIGNS, new string[] { "id", "name" }))
            {
                if (_DB_Helper.GetCampaignType((uint)campaign[0]) == DB_Helper.CampaignType.BACHELOR_SPECIALIST)
                {
                    campaigns.Add((uint)campaign[0], campaign[1].ToString());
                }
            }

            cbCampaigns.DataSource    = campaigns.ToList();
            cbCampaigns.ValueMember   = "Key";
            cbCampaigns.DisplayMember = "Value";
            cbAdress.SelectedIndex    = 0;
            cbAdress.Enabled          = cbPost.Checked;
            cbUnits.SelectedIndex     = 1;
            for (int i = 1; i <= 60; i++)
            {
                cbInterval.Items.Add(i);
            }
            cbInterval.SelectedItem = 15;

            _SubjectsCodes = new Dictionary <uint, string>
            {
                { _DB_Helper.GetDictionaryItemID(FIS_Dictionary.SUBJECTS, DB_Helper.SubjectMath), "Math" },
                { _DB_Helper.GetDictionaryItemID(FIS_Dictionary.SUBJECTS, DB_Helper.SubjectPhis), "Phis" },
                { _DB_Helper.GetDictionaryItemID(FIS_Dictionary.SUBJECTS, DB_Helper.SubjectRus), "Rus" },
                { _DB_Helper.GetDictionaryItemID(FIS_Dictionary.SUBJECTS, DB_Helper.SubjectObsh), "Obsh" },
                { _DB_Helper.GetDictionaryItemID(FIS_Dictionary.SUBJECTS, DB_Helper.SubjectForen), "Foren" }
            };
        }
Ejemplo n.º 27
0
        private void bExport_Click(object sender, EventArgs e)
        {
            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                Cursor.Current = Cursors.WaitCursor;

                var identities = DB_Queries.GetDocuments(
                    _DB_Connection,
                    _DB_Connection.Select(
                        DB_Table.APPLICATIONS,
                        new string[] { "id" },
                        new List <Tuple <string, Relation, object> > {
                    new Tuple <string, Relation, object>("campaign_id", Relation.EQUAL, Classes.Settings.CurrentCampaignID)
                }
                        ).Select(s => (uint)s[0])).Where(s => s.Type == "identity").Join(
                    _DB_Connection.Select(
                        DB_Table.IDENTITY_DOCS_ADDITIONAL_DATA,
                        new string[] { "document_id", "last_name" /*, "first_name", "middle_name"*/ },
                        new List <Tuple <string, Relation, object> >
                {
                    new Tuple <string, Relation, object>("type_id", Relation.EQUAL, _DB_Helper.GetDictionaryItemID(FIS_Dictionary.IDENTITY_DOC_TYPE, DB_Helper.PassportName))
                }),
                    k1 => k1.ID,
                    k2 => k2[0],
                    (s1, s2) => Tuple.Create(s2[1].ToString(), /* s2[2].ToString(), s2[3] as string,*/ s1.Series, s1.Number));

                using (System.IO.StreamWriter writer = new System.IO.StreamWriter(saveFileDialog.FileName, false, System.Text.Encoding.GetEncoding(1251)))
                {
                    foreach (var appl in GetEgeResults().Select(s =>
                                                                Tuple.Create(s.LastName /*, s.FirstName, s.MiddleName*/, s.Series, s.Number)
                                                                ).Concat(identities).Distinct())
                    {
                        //writer.WriteLine(appl.Item1 + "%" + appl.Item2 + "%" + appl.Item3 + "%" + appl.Item4 + "%" + appl.Item5);
                        writer.WriteLine(appl.Item1 + "%%%" + appl.Item2 + "%" + appl.Item3);
                    }
                }

                Cursor.Current = Cursors.Default;
            }
        }
Ejemplo n.º 28
0
        private void bSave_Click(object sender, EventArgs e)
        {
            if (!AssureSave())
            {
                return;
            }

            Cursor.Current = Cursors.WaitCursor;

            Dictionary <string, object> data = new Dictionary <string, object>
            {
                { "subject_dict_id", (uint)FIS_Dictionary.SUBJECTS },
                { "subject_id", _DB_Helper.GetDictionaryItemID(FIS_Dictionary.SUBJECTS, cbSubject.Text) },
                { "date", dtpDate.Value },
                { "reg_start_date", dtpRegStartDate.Value },
                { "reg_end_date", dtpRegEndDate.Value }
            };

            using (MySql.Data.MySqlClient.MySqlTransaction transaction = _DB_Connection.BeginTransaction())
            {
                uint id;
                if (_ID.HasValue)
                {
                    _DB_Connection.Update(DB_Table.EXAMINATIONS, data, new Dictionary <string, object> {
                        { "id", _ID }
                    }, transaction);
                    id = _ID.Value;
                }
                else
                {
                    id = _DB_Connection.Insert(DB_Table.EXAMINATIONS, data, transaction);
                }

                string[]        fields  = { "examination_id", "number", "capacity", "priority" };
                List <object[]> oldList = _DB_Connection.Select(
                    DB_Table.EXAMINATIONS_AUDIENCES,
                    fields,
                    new List <Tuple <string, Relation, object> > {
                    new Tuple <string, Relation, object>("examination_id", Relation.EQUAL, id)
                }
                    );

                List <object[]> newList = new List <object[]>();
                foreach (DataGridViewRow row in dataGridView.Rows)
                {
                    if (!row.IsNewRow)
                    {
                        newList.Add(new object[] { id, row.Cells[0].Value, row.Cells[1].Value, row.Index });
                    }
                }

                _DB_Helper.UpdateData(DB_Table.EXAMINATIONS_AUDIENCES, oldList, newList, fields, new string[] { "examination_id", "number" }, transaction);

                transaction.Commit();
            }

            Cursor.Current = Cursors.Default;

            SharedClasses.Utility.ShowChangesSavedMessage();
            DialogResult = DialogResult.OK;
        }
Ejemplo n.º 29
0
        private void toolStrip_Distribute_Click(object sender, EventArgs e)
        {
            if (DB_Queries.ExaminationHasMarks(_DB_Connection, SelectedExamID))
            {
                MessageBox.Show("В экзамен уже включены абитуриенты. При повторном распределении они не будут удалены.");
            }

            Cursor.Current = Cursors.WaitCursor;

            var applications = _DB_Connection.Select(
                DB_Table.APPLICATIONS,
                new string[] { "id", "registration_time", "entrant_id" },
                new List <Tuple <string, Relation, object> >
            {
                new Tuple <string, Relation, object>("passing_examinations", Relation.EQUAL, true),
                new Tuple <string, Relation, object>("status", Relation.EQUAL, "new")
            }).Where(a => (DateTime)a[1] >= (DateTime)dataGridView.SelectedRows[0].Cells[dataGridView_RegStartDate.Index].Value &&
                     (DateTime)a[1] < (DateTime)dataGridView.SelectedRows[0].Cells[dataGridView_RegEndDate.Index].Value + new TimeSpan(1, 0, 0, 0)
                     ).Select(s => new { ApplID = (uint)s[0], EntrID = (uint)s[2] });

            uint subjectID = _DB_Helper.GetDictionaryItemID(FIS_Dictionary.SUBJECTS, dataGridView.SelectedRows[0].Cells[dataGridView_Subject.Index].Value.ToString());

            IEnumerable <uint> excludedAppls = DB_Queries.GetMarks(
                _DB_Connection,
                applications.Select(s => s.ApplID),
                Classes.Settings.CurrentCampaignID
                ).Where(s =>
                        s.FromExamDate.HasValue &&
                        (s.SubjID == subjectID ||
                         s.Value < _DB_Helper.GetMinMark(s.SubjID)
                        )).Select(s => s.ApplID);

            applications = applications.Where(s => !excludedAppls.Contains(s.ApplID));

            var applsDirections = _DB_Connection.Select(
                DB_Table.APPLICATIONS_ENTRANCES,
                "application_id", "faculty_short_name", "direction_id"
                );

            var subjectDirections = _DB_Connection.Select(
                DB_Table.ENTRANCE_TESTS,
                new string[] { "direction_faculty", "direction_id" },
                new List <Tuple <string, Relation, object> >
            {
                new Tuple <string, Relation, object>("campaign_id", Relation.EQUAL, Classes.Settings.CurrentCampaignID),
                new Tuple <string, Relation, object>("subject_id", Relation.EQUAL, subjectID)
            });

            var applsSubjects = applsDirections.Join(
                subjectDirections,
                k1 => Tuple.Create(k1[1], k1[2]),
                k2 => Tuple.Create(k2[0], k2[1]),
                (s1, s2) => (uint)s1[0]
                ).Distinct();

            applications = applications.Join(
                applsSubjects,
                k1 => k1.ApplID,
                k2 => k2,
                (s1, s2) => s1
                );

            if (applications.Count() == 0)
            {
                MessageBox.Show("Ни один абитуриент не попал в экзамен по условиям фильтрации.", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            var entrantsIDs = _DB_Connection.Select(DB_Table.ENTRANTS, "id").Join(
                applications,
                en => en[0],
                a => a.EntrID,
                (s1, s2) => s2.EntrID
                ).Distinct();//TODO Нужно?

            foreach (object entrID in entrantsIDs)
            {
                _DB_Connection.InsertOnDuplicateUpdate(
                    DB_Table.ENTRANTS_EXAMINATIONS_MARKS,
                    new Dictionary <string, object> {
                    { "entrant_id", entrID }, { "examination_id", SelectedExamID }
                }
                    );
            }

            ToggleButtons();

            Cursor.Current = Cursors.Default;
        }
Ejemplo n.º 30
0
        public ExaminationEdit(DB_Connector connection, uint?id)
        {
            _DB_Connection = connection;
            _ID            = id;

            #region Components
            InitializeComponent();

            dataGridView_Capacity.ValueType = typeof(ushort);

            Tuple <uint, uint> curCampStartEnd = DB_Queries.GetCampaignStartEnd(_DB_Connection, Classes.Settings.CurrentCampaignID);

            dtpDate.MinDate         = new DateTime((int)curCampStartEnd.Item1, 1, 1);
            dtpDate.MaxDate         = new DateTime((int)curCampStartEnd.Item2, 12, 31);
            dtpRegStartDate.MinDate = dtpDate.MinDate;
            dtpRegStartDate.MaxDate = dtpDate.MaxDate;
            dtpRegEndDate.MinDate   = dtpDate.MinDate;
            dtpRegEndDate.MaxDate   = dtpDate.MaxDate;

            foreach (DateTimePicker dtp in Controls.OfType <DateTimePicker>())
            {
                dtp.Tag = _ID.HasValue;
            }

            if (_ID.HasValue)
            {
                dtpRegStartDate.Enabled = !DB_Queries.ExaminationHasMarks(_DB_Connection, _ID.Value);
                dtpRegEndDate.Enabled   = !DB_Queries.ExaminationHasMarks(_DB_Connection, _ID.Value);
            }
            #endregion

            _DB_Helper = new DB_Helper(_DB_Connection);

            Dictionary <uint, string> subjects = _DB_Helper.GetDictionaryItems(FIS_Dictionary.SUBJECTS);

            cbSubject.Items.AddRange(subjects.Values.ToArray());

            if (_ID.HasValue)
            {
                object[] exam = _DB_Connection.Select(DB_Table.EXAMINATIONS,
                                                      new string[] { "subject_id", "date", "reg_start_date", "reg_end_date" },
                                                      new List <Tuple <string, Relation, object> >
                {
                    new Tuple <string, Relation, object>("id", Relation.EQUAL, _ID)
                })[0];

                cbSubject.SelectedItem = subjects[(uint)exam[0]];
                dtpDate.Value          = (DateTime)exam[1];
                dtpRegStartDate.Value  = (DateTime)exam[2];
                dtpRegEndDate.Value    = (DateTime)exam[3];

                foreach (object[] row in _DB_Connection.Select(
                             DB_Table.EXAMINATIONS_AUDIENCES,
                             new string[] { "number", "capacity", "priority" },
                             new List <Tuple <string, Relation, object> >
                {
                    new Tuple <string, Relation, object>("examination_id", Relation.EQUAL, _ID)
                }).OrderBy(s => s[2]))
                {
                    dataGridView.Rows.Add(row[0], row[1]);
                }
            }
        }