Exemplo n.º 1
0
        void makeRequest(int id)
        {
            dataGridView1.Rows.Clear();
            String sql = "SELECT * FROM product_status_changes WHERE unit_id = " + id.ToString();

            DataTable dt = SQLCustom.SQL_Request(Form1.connection, sql);

            if (dt != null)
            {
                if (dt.Rows.Count != 0)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        dataGridView1.Rows.Add(dr["change_id"],
                                               dr["change_name"],
                                               dr["description"],
                                               String.Format("{0:yyyy-MM-dd}", dr["$date"]));
                    }
                    dataGridView1.Rows[dataGridView1.Rows.Count - 1].Selected = true;
                    dataGridView1.CurrentCell = dataGridView1[1, dataGridView1.Rows.Count - 1];
                }
            }
            else
            {
                MessageBox.Show("Ошибка БД!");
            }
        }
Exemplo n.º 2
0
        void makeRequest(int id)
        {
            dataGridView1.Rows.Clear();

            String sql = "SELECT * FROM `failures` WHERE `unit_id` = " + id.ToString();

            DataTable dt = SQLCustom.SQL_Request(Form1.connection, sql);

            if (dt != null)
            {
                if (dt.Rows.Count != 0)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        dataGridView1.Rows.Add(dr["failure_id"],
                                               String.Format("{0:yyyy-MM-dd}", dr["time_stamp"]),
                                               dr["failure_name"],
                                               dr["description"],
                                               dr["document"],
                                               dr["failure_type"]);
                    }
                    dataGridView1.Rows[dataGridView1.Rows.Count - 1].Selected = true;
                    dataGridView1.CurrentCell = dataGridView1[1, dataGridView1.Rows.Count - 1];
                }
            }
            else
            {
                MessageBox.Show("Ошибка работы с БД!");
            }
        }
Exemplo n.º 3
0
        private void Button2_Click_1(object sender, EventArgs e)
        {
            if (textBox2.Text == "" && (textBox3.Text == "" || textBox4.Text == "" || comboBox1.SelectedIndex == -1) && textBox1.Text == "")
            {
                MessageBox.Show("Заполните поля!", "Предупреждение");
                return;
            }

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                if (row.Cells["place_name"].Value.ToString().Equals(textBox2.Text) &&
                    row.Cells["la_number"].Value.ToString().Equals(textBox3.Text) &&
                    row.Cells["ad_number"].Value.ToString().Equals(textBox4.Text) &&
                    row.Cells["ad_side"].Value.ToString().Equals(comboBox1.Text) &&
                    row.Cells["stand_name"].Value.ToString().Equals(textBox1.Text))
                {
                    MessageBox.Show("Такая запись уже существует");
                    return;
                }
            }

            String sql = "BEGIN;";

            sql += String.Format("INSERT INTO `exploit_place` " +
                                 "(unit_id, place_name, la_number, ad_side, ad_number, stand_name)" +
                                 " VALUES ({0},' {1}', '{2}', '{3}', '{4}', '{5}'); ",
                                 m_id.ToString(),
                                 textBox2.Text,
                                 textBox3.Text,
                                 comboBox1.Text,
                                 textBox4.Text,
                                 textBox1.Text);

            sql += string.Format("UPDATE unit_info SET last_update = '{0}' " +
                                 "WHERE unit_id = {1};", DateTime.Today.ToString("yyyy-MM-dd"), m_id);

            sql += "COMMIT;";

            DataTable dt = SQLCustom.SQL_Request(Form1.connection, sql);

            if (dt.ToString() != "")
            {
                MessageBox.Show("Ошибка записи в БД", "Ошибка");
            }
            else
            {
                MessageBox.Show("Запись успешно добавлена в БД");

                sql = string.Format("INSERT INTO journal_log " +
                                    "(date_time, user, operation, num_code) " +
                                    "VALUES('{0}', '{1}', '{2}', '{3}')",
                                    DateTime.Now.ToString("yyyy-MM-dd HH:mm"), Form1.userName,
                                    "Добавление ЭО", m_parent.m_numCode);

                dt = SQLCustom.SQL_Request(Form1.connection, sql);

                makeRequest(m_id);
                m_parent.makeRequest(m_id);
            }
        }
Exemplo n.º 4
0
        //delete button 1
        private void button3_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show(
                "Вы действительно хотите удалить эту запись?",
                "Предупреждение", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.No)
            {
                return;
            }

            string sql = string.Format("DELETE FROM unit_names " +
                                       "WHERE name = '{0}';", listView1.Items[m_type].Text);

            DataTable dt = SQLCustom.SQL_Request(m_connection, sql);

            if (dt.ToString() != "")
            {
                MessageBox.Show("Ошибка удаления");
            }
            else
            {
                m_parent.initTree();
                getDataFromTree();
                listView2.Items.Clear();
                listView3.Items.Clear();
                MessageBox.Show("Удаление выполнено успешно");
            }
        }
Exemplo n.º 5
0
        void makeRequest(int id)
        {
            String sql = "SELECT * FROM software WHERE unit_id = " + id.ToString();

            DataTable dt = SQLCustom.SQL_Request(Form1.connection, sql);

            if (dt != null)
            {
                if (dt.Rows.Count != 0)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        dataGridView1.Rows.Add(dr["sw_id"],
                                               String.Format("{0:yyyy-MM-dd}", dr["implem_date"]),
                                               dr["dev_goal"],
                                               dr["sw_version"],
                                               String.Format("{0:yyyy-MM-dd}", dr["cancell_date"]));
                    }
                    dataGridView1.ClearSelection();
                    dataGridView1.Rows[dataGridView1.Rows.Count - 1].Selected = true;
                    isCancellDateChanged = false;
                }
            }
            else
            {
                MessageBox.Show("Ошибка работы с БД!");
            }
        }
Exemplo n.º 6
0
        private void Button2_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show(
                "Вы уверены, что хотите удалить выбранную запись?",
                "Предупреждение", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.No)
            {
                return;
            }

            String sql = "BEGIN;";

            sql += "DELETE FROM `performed_works` WHERE `performed_work_id` = '" +
                   dataGridView1.SelectedRows[0].Cells[0].Value.ToString() + "';";

            sql += string.Format("UPDATE unit_info SET last_update = '{0}' " +
                                 "WHERE unit_id = {1};", DateTime.Today.ToString("yyyy-MM-dd"), _id);

            sql += "COMMIT;";

            DataTable dt = SQLCustom.SQL_Request(Form1.connection, sql);

            sql = string.Format("INSERT INTO journal_log " +
                                "(date_time, user, operation, num_code) " +
                                "VALUES('{0}', '{1}', '{2}', '{3}')",
                                DateTime.Now.ToString("yyyy-MM-dd HH:mm"), Form1.userName,
                                "Удаление работы", m_parent.m_numCode);

            dt = SQLCustom.SQL_Request(Form1.connection, sql);

            makeRequest(_id);
        }
Exemplo n.º 7
0
        void makeRequest(int id)
        {
            dataGridView1.Rows.Clear();
            String sql = "SELECT * FROM performed_works WHERE unit_id = " + id.ToString();

            DataTable dt = SQLCustom.SQL_Request(Form1.connection, sql);

            if (dt != null)
            {
                if (dt.Rows.Count != 0)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        dataGridView1.Rows.Add(dr["performed_work_id"],
                                               dr["name"],
                                               dr["document"],
                                               dr["description"],
                                               dr["work_type"],
                                               String.Format("{0:yyyy-MM-dd}", dr["start_date"]),
                                               String.Format("{0:yyyy-MM-dd}", dr["finish_date"]));
                    }

                    isCancellDateChanged = false;
                    dataGridView1.ClearSelection();
                    dataGridView1.Rows[dataGridView1.Rows.Count - 1].Selected = true;
                    dataGridView1.CurrentCell        = dataGridView1[1, dataGridView1.Rows.Count - 1];
                    dataGridView1.Columns[0].Visible = false;
                }
            }
            else
            {
                MessageBox.Show("Ошибка БД!");
            }
        }
Exemplo n.º 8
0
        void makeRequest(int id)
        {
            dataGridView1.Rows.Clear();

            String sql = "SELECT * FROM `exploit_place` WHERE `unit_id` = " + id.ToString();

            DataTable dt = SQLCustom.SQL_Request(Form1.connection, sql);

            if (dt != null)
            {
                if (dt.Rows.Count != 0)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        dataGridView1.Rows.Add(dr["place_id"],
                                               dr["place_name"],
                                               dr["la_number"],
                                               dr["ad_number"],
                                               dr["ad_side"],
                                               dr["stand_name"]);
                    }
                    dataGridView1.CurrentCell        = dataGridView1[1, dataGridView1.Rows.Count - 1];
                    dataGridView1.Columns[0].Visible = false;
                }
            }
            else
            {
                MessageBox.Show("Ошибка работы с БД!");
            }
        }
Exemplo n.º 9
0
        private void button1_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show(
                "Вы уверены, что хотите удалить выбранную запись?",
                "Предупреждение", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.No)
            {
                return;
            }

            string sql = string.Format("DELETE FROM journal_log WHERE record_id = '{0}' ;",
                                       dataGridView1.SelectedRows[0].Cells[0].Value.ToString());

            DataTable dt = SQLCustom.SQL_Request(Form1.connection, sql);

            if (dt.ToString() != "")
            {
                MessageBox.Show("Ошибка БД!");
            }
            else
            {
                MessageBox.Show("Запись успешно удалена");
                dataGridView1.Rows.Clear();
                makeRequest();
            }
        }
Exemplo n.º 10
0
        public void makeRequest()
        {
            String sql = "SELECT * FROM journal_log";

            DataTable dt = SQLCustom.SQL_Request(Form1.connection, sql);

            if (dt.Rows.Count > 0)
            {
                if (dt.Rows.Count >= 100000)
                {
                    MessageBox.Show("Достигнут лимит записей. Импортиртуйте" +
                                    " данные и очистите журнал", "Предупреждение");
                }

                foreach (DataRow row in dt.Rows)
                {
                    dataGridView1.Rows.Add(row["record_id"],
                                           String.Format("{0:yyyy-MM-dd HH:mm}", row["date_time"]),
                                           row["user"],
                                           row["operation"],
                                           row["num_code"],
                                           row["property"],
                                           row["old_value"],
                                           row["new_value"]);
                }
                dataGridView1.FirstDisplayedScrollingRowIndex = dataGridView1.RowCount - 1;

                dataGridView1.ClearSelection();
            }
        }
Exemplo n.º 11
0
        //add button 2
        private void button4_Click(object sender, EventArgs e)
        {
            if (textBox2.Text == "")
            {
                MessageBox.Show("Заполните поле");
                return;
            }

            string sql = string.Format("INSERT INTO variant_names " +
                                       "(name_id, variant_name) " +
                                       "SELECT unit_names.name_id, '{0}' FROM unit_names " +
                                       "WHERE name = '{1}';", textBox2.Text, textBox1.Text);

            DataTable dt = SQLCustom.SQL_Request(m_connection, sql);

            if (dt.ToString() != "")
            {
                MessageBox.Show("Ошибка записи в БД");
            }
            else
            {
                m_parent.initTree();
                getDataFromTree();
                listView1.Items[m_type].Selected = true;
                listView3.Items.Clear();
                MessageBox.Show("Запись успешно добавлена");
            }
        }
Exemplo n.º 12
0
        void makeRequest(int id)
        {
            String sql = string.Format("SELECT * FROM unit_dispatches WHERE unit_id = {0} order by dispatch_id", id);

            DataTable dt = SQLCustom.SQL_Request(Form1.connection, sql);

            if (dt != null)
            {
                if (dt.Rows.Count != 0)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        dataGridView1.Rows.Add(dr["dispatch_id"],
                                               string.Format("{0:yyyy-MM-dd}", dr["date_getting"]),
                                               string.Format("{0:yyyy-MM-dd}", dr["date_sending"]),
                                               dr["invoice"]);
                    }
                    dataGridView1.ClearSelection();
                    dataGridView1.Rows[dataGridView1.Rows.Count - 1].Selected = true;
                }
            }
            else
            {
                MessageBox.Show("Ошибка работы с БД!");
            }
        }
Exemplo n.º 13
0
        private void button1_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show(
                "Вы уверены, что хотите удалить выбранную запись?",
                "Предупреждение", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.No)
            {
                return;
            }

            String    sql = "";
            DataTable dt;

            sql = "BEGIN;";

            sql += String.Format("DELETE FROM software WHERE sw_id = '{0}';",
                                 dataGridView1.SelectedRows[0].Cells[0].Value.ToString());

            sql += string.Format("UPDATE unit_info SET last_update = '{0}' " +
                                 "WHERE unit_id = {1};", DateTime.Today.ToString("yyyy-MM-dd"), m_id);

            sql += "COMMIT;";

            dt = SQLCustom.SQL_Request(Form1.connection, sql);

            if (dt.ToString() != "")
            {
                MessageBox.Show("Ошибка БД!");
            }
            else
            {
                if (dataGridView1.SelectedRows[0].Index > 1)
                {
                    sql = string.Format("UPDATE software SET cancell_date = NULL " +
                                        "WHERE sw_id = '{0}'",
                                        dataGridView1.Rows[dataGridView1.SelectedRows[0].Index - 1].
                                        Cells[0].Value.ToString());

                    dt = SQLCustom.SQL_Request(Form1.connection, sql);
                }

                sql = string.Format("INSERT INTO journal_log " +
                                    "(date_time, user, operation, num_code) " +
                                    "VALUES('{0}', '{1}', '{2}', '{3}')",
                                    DateTime.Now.ToString("yyyy-MM-dd HH:mm"), Form1.userName,
                                    "Удаление ПО", m_parent.m_numCode);

                dt = SQLCustom.SQL_Request(Form1.connection, sql);

                dataGridView1.Rows.Clear();
                makeRequest(m_id);
                m_parent.makeRequest(m_id);
                m_parent.generalDataUpdated();

                MessageBox.Show("Запись успешно удалена");
            }
        }
Exemplo n.º 14
0
        //delete button 3
        private void button9_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show(
                "Вы действительно хотите удалить эту запись?",
                "Предупреждение", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.No)
            {
                return;
            }

            string sql = string.Format("SELECT variant_id FROM variant_names " +
                                       "WHERE variant_name = '{0}' AND " +
                                       "name_id IN (SELECT name_id FROM unit_names WHERE name = '{1}')",
                                       listView2.Items[m_variant].Text,
                                       listView1.Items[m_type].Text);

            DataTable dt = SQLCustom.SQL_Request(m_connection, sql);

            if (dt.Rows.Count > 0)
            {
                m_variantId = Convert.ToInt32(dt.Rows[0][0]);
            }
            else
            {
                MessageBox.Show("error");
                return;
            }

            sql = string.Format("DELETE FROM software_names " +
                                "WHERE software_name = '{0}' and variant_id = {1}",
                                listView3.Items[m_software].Text,
                                m_variantId);

            dt = SQLCustom.SQL_Request(m_connection, sql);

            if (dt.ToString() != "")
            {
                MessageBox.Show("Ошибка удаления");
            }
            else
            {
                m_parent.initTree();
                getDataFromTree();

                if (listView2.Items[m_variant].Selected == true)
                {
                    listView2.Items[m_variant].Selected = false;
                }
                else
                {
                    listView2.Items[m_variant].Selected = true;
                }

                MessageBox.Show("Удаление выполнено успешно");
            }
        }
Exemplo n.º 15
0
        private void setTitle(int id)
        {
            string sql = "SELECT product_code, unit_num FROM unit_info WHERE unit_id = "
                         + id.ToString();
            DataTable dt = SQLCustom.SQL_Request(Form1.connection, sql);

            label9.Text = dt.Rows[0][0].ToString();
            unitNum     = dt.Rows[0][1].ToString();
        }
Exemplo n.º 16
0
        //update button 3
        private void button8_Click(object sender, EventArgs e)
        {
            if (textBox3.Text == "")
            {
                MessageBox.Show("Заполните поле");
                return;
            }

            string sql = string.Format("SELECT variant_id FROM variant_names " +
                                       "WHERE variant_name = '{0}' AND " +
                                       "name_id IN (SELECT name_id FROM unit_names WHERE name = '{1}')",
                                       listView2.Items[m_variant].Text,
                                       listView1.Items[m_type].Text);

            DataTable dt = SQLCustom.SQL_Request(m_connection, sql);

            if (dt.Rows.Count > 0)
            {
                m_variantId = Convert.ToInt32(dt.Rows[0][0]);
            }
            else
            {
                MessageBox.Show("error");
                return;
            }

            sql = string.Format("UPDATE software_names SET " +
                                "software_name = '{0}' " +
                                "WHERE software_name = '{1}' and variant_id = {2}",
                                textBox3.Text,
                                listView3.Items[m_software].Text,
                                m_variantId);

            dt = SQLCustom.SQL_Request(m_connection, sql);

            if (dt.ToString() != "")
            {
                MessageBox.Show("Ошибка записи в БД");
            }
            else
            {
                m_parent.initTree();
                getDataFromTree();

                if (listView2.Items[m_variant].Selected == true)
                {
                    listView2.Items[m_variant].Selected = false;
                }
                else
                {
                    listView2.Items[m_variant].Selected = true;
                }

                MessageBox.Show("Запись успешно обновлена");
            }
        }
Exemplo n.º 17
0
        private void revisionButton_Click(object sender, EventArgs e)
        {
            if (revisionTextBox.Text == "")
            {
                MessageBox.Show("Заполните поле");
                return;
            }

            string sql = string.Format("SELECT software_id FROM software_names " +
                                       "WHERE software_name = '{0}' AND " +


                                       /////////////////////////////////////////////////////////////////////////////////////
                                       "variant_id IN (SELECT variant_id FROM unit_names WHERE name = '{1}')",
                                       listView2.Items[m_variant].Text,
                                       listView1.Items[m_type].Text);

            DataTable dt = SQLCustom.SQL_Request(m_connection, sql);

            if (dt.Rows.Count > 0)
            {
                m_variantId = Convert.ToInt32(dt.Rows[0][0]);
            }
            else
            {
                MessageBox.Show("error");
                return;
            }

            sql = string.Format("INSERT INTO software_names " +
                                "(variant_id, software_name)  VALUES({0}, '{1}')",
                                m_variantId, revisionTextBox.Text);

            dt = SQLCustom.SQL_Request(m_connection, sql);

            if (dt.ToString() != "")
            {
                MessageBox.Show("Ошибка записи в БД");
            }
            else
            {
                m_parent.initTree();
                getDataFromTree();

                if (listView2.Items[m_variant].Selected == true)
                {
                    listView2.Items[m_variant].Selected = false;
                }
                else
                {
                    listView2.Items[m_variant].Selected = true;
                }

                MessageBox.Show("Запись успешно добавлена");
            }
        }
Exemplo n.º 18
0
        void makeRequest(int id)
        {
            String sql = "SELECT unit_info.var_stor_period col_2, " +
                         "varranty_res.period_value col_3, " +
                         "varranty_res.operating_hours col_4, " +
                         "bef_first_repair_res.period_value col_5, " +
                         "bef_first_repair_res.operating_hours col_6, " +
                         "between_repairs_res.period_value col_7, " +
                         "between_repairs_res.operating_hours col_8, " +
                         "assigned_res.period_value col_9, " +
                         "assigned_res.operating_hours col_10, " +
                         "refurbished_res.period_value col_11, " +
                         "refurbished_res.operating_hours col_12, " +
                         "unit_info.comment col_14, " +/////////////////////////////////////////////////////////комментарии
                         "unit_info.remark col_13 " +
                         "FROM unit_info, varranty_res, bef_first_repair_res, " +
                         "between_repairs_res, assigned_res, refurbished_res " +
                         "WHERE unit_info.unit_id = varranty_res.unit_id AND " +
                         "unit_info.unit_id = bef_first_repair_res.unit_id AND " +
                         "unit_info.unit_id = between_repairs_res.unit_id AND " +
                         "unit_info.unit_id = assigned_res.unit_id AND " +
                         "unit_info.unit_id = refurbished_res.unit_id AND " +
                         "unit_info.unit_id = " + id.ToString();

            DataTable dt = SQLCustom.SQL_Request(Form1.connection, sql);

            if (dt.Rows.Count != 0)
            {
                textBox10.Text = dt.Rows[0]["col_2"].ToString();
                textBox9.Text  = dt.Rows[0]["col_3"].ToString();
                textBox8.Text  = dt.Rows[0]["col_4"].ToString();
                textBox2.Text  = dt.Rows[0]["col_5"].ToString();
                textBox1.Text  = dt.Rows[0]["col_6"].ToString();
                textBox4.Text  = dt.Rows[0]["col_7"].ToString();
                textBox3.Text  = dt.Rows[0]["col_8"].ToString();
                textBox6.Text  = dt.Rows[0]["col_9"].ToString();
                textBox5.Text  = dt.Rows[0]["col_10"].ToString();
                textBox11.Text = dt.Rows[0]["col_11"].ToString();
                textBox7.Text  = dt.Rows[0]["col_12"].ToString();
                comments.Text  = dt.Rows[0]["col_14"].ToString();////////////////////////////комментарии
            }

            sql = "SELECT * from contracts WHERE unit_id = " + id;

            dt = SQLCustom.SQL_Request(Form1.connection, sql);

            if (dt.Rows.Count != 0)
            {
                textBox12.Text        = dt.Rows[0]["contract_num"].ToString();
                dateTimePicker1.Value = Convert.ToDateTime(dt.Rows[0]["contract_date"].ToString());
                textBox14.Text        = dt.Rows[0]["associate"].ToString();
                textBox15.Text        = dt.Rows[0]["director_decision"].ToString();
            }
            isContractDataChanged  = false;
            isResourcesDataChanged = false;
        }
Exemplo n.º 19
0
        public void collectUnits()
        {
            dataGridView1.Rows.Clear();
            string sql;

            if (comboBox9.SelectedIndex == -1 || comboBox9.Items[comboBox9.SelectedIndex].ToString() == "Все изделия")
            {
                sql = "SELECT unit_info.*, deviations.deviation_type " +
                      "FROM unit_info " +
                      "LEFT JOIN deviations " +
                      "ON unit_info.unit_id = deviations.unit_id " +
                      "ORDER BY unit_num;";
            }
            else
            {
                sql = string.Format("SELECT unit_info.*, deviations.deviation_type " +
                                    "FROM unit_info " +
                                    "LEFT JOIN deviations " +
                                    "ON unit_info.unit_id = deviations.unit_id " +
                                    "WHERE product_code like '%{0}%' " +
                                    "ORDER BY unit_num;", comboBox9.Items[comboBox9.SelectedIndex].ToString());
            }

            DataTable dt = SQLCustom.SQL_Request(connection, sql);

            if (dt.Rows.Count > 0)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    dataGridView1.Rows.Add(dr["unit_id"],
                                           dr["unit_num"],
                                           dr["notes"],
                                           dr["product_code"],
                                           dr["izmKD"],
                                           dr["equipment"],
                                           String.Format("{0:yyyy-MM-dd}", dr["release_date"]),
                                           Form2.GetFirstSW(Convert.ToInt32(dr["unit_id"].ToString())),
                                           Form2.GetLastSW(Convert.ToInt32(dr["unit_id"].ToString())),
                                           dr["revision"],
                                           dr["deviation_type"],
                                           dr["operating_hours"],
                                           dr["failures_count"],
                                           String.Format("{0:yyyy-MM-dd}", dr["last_update"]));
                }
                setRowNumber(dataGridView1);

                populateDeviationsBox();
                populateSwSortBox();
                populateNotesBox();

                dataGridView1.FirstDisplayedScrollingRowIndex = dataGridView1.RowCount - 1;

                dataGridView1.ClearSelection();
            }
        }
Exemplo n.º 20
0
        private void populateSwSortBox()
        {
            string    sql = "SELECT DISTINCT sw_version from software";
            DataTable dt  = SQLCustom.SQL_Request(Form1.connection, sql);

            comboBox1.Items.Clear();
            foreach (DataRow row in dt.Rows)
            {
                comboBox1.Items.Add(row["sw_version"].ToString());
            }
        }
Exemplo n.º 21
0
        private void Button1_Click(object sender, EventArgs e)
        {
            if ((textBox2.Text.Length < 1) || (comboBox6.Text == "Статус"))
            {
                MessageBox.Show("Заполните все поля!");
                return;
            }

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                if (row.Cells["name"].Value.ToString().Equals(comboBox6.Text) &&
                    row.Cells["description"].Value.ToString().Equals(textBox2.Text))
                {
                    MessageBox.Show("Такая запись уже существует");
                    return;
                }
            }

            String sql = "BEGIN;";

            sql += "INSERT into `product_status_changes` " +
                   "(unit_id, change_name, `$date`, description) VALUES (" +
                   m_id.ToString() + ", '" +
                   comboBox6.Text + "','" +
                   dateTimePicker1.Value.Date.ToString("yyyy-MM-d") + "', '" +
                   textBox2.Text + "');";

            sql += string.Format("UPDATE unit_info SET last_update = '{0}' " +
                                 "WHERE unit_id = {1};", DateTime.Today.ToString("yyyy-MM-dd"), m_id);
            sql += "COMMIT;";

            DataTable dt = SQLCustom.SQL_Request(Form1.connection, sql);

            if (dt.HasErrors)
            {
                MessageBox.Show("Error");
            }
            else
            {
                sql = string.Format("INSERT INTO journal_log " +
                                    "(date_time, user, operation, num_code) " +
                                    "VALUES('{0}', '{1}', '{2}', '{3}')",
                                    DateTime.Now.ToString("yyyy-MM-dd HH:mm"), Form1.userName,
                                    "Добавление статуса", m_parent.m_numCode);

                dt = SQLCustom.SQL_Request(Form1.connection, sql);

                textBox2.Clear();       //HZ zachem, vozmojno potom udaly
                makeRequest(m_id);
                m_parent.makeRequest(m_id);
            }
        }
Exemplo n.º 22
0
        private void populateNotesBox()
        {
            string sql = "SELECT DISTINCT notes FROM unit_info";

            DataTable result = SQLCustom.SQL_Request(Form1.connection, sql);

            comboBox10.Items.Clear();

            foreach (DataRow row in result.Rows)
            {
                comboBox10.Items.Add(row[0]);
            }
        }
Exemplo n.º 23
0
        public void initTree()
        {
            tree = new Node();

            string          connStr    = "Server=192.168.0.37;Database=element_templates;Uid=element_user;password=lohozavr;";
            MySqlConnection connection = new MySqlConnection(connStr);

            string    sql       = "SELECT * FROM unit_names";
            DataTable unitTable = SQLCustom.SQL_Request(connection, sql);

            sql = "SELECT * FROM variant_names";
            DataTable variantTable = SQLCustom.SQL_Request(connection, sql);

            sql = "SELECT * FROM software_names";
            DataTable softwareTable = SQLCustom.SQL_Request(connection, sql);

            DataRow[] variantRows;
            DataRow[] softwareRows;

            if (unitTable.Rows.Count == 0 || variantTable.Rows.Count == 0 ||
                softwareTable.Rows.Count == 0)
            {
                MessageBox.Show(unitTable.ToString());
                MessageBox.Show(variantTable.ToString());
                MessageBox.Show(softwareTable.ToString());
                return;
            }
            foreach (DataRow unitRow in unitTable.Rows)
            {
                tree.addNode(unitRow["name"].ToString());
                variantRows = variantTable.Select("name_id = " + unitRow["name_id"].ToString());

                foreach (DataRow variantRow in variantRows)
                {
                    tree.getLastChild().
                    addNode(variantRow["variant_name"].ToString());

                    softwareRows = softwareTable.Select("variant_id = " +
                                                        variantRow["variant_id"].ToString());

                    foreach (DataRow softwareRow in softwareRows)
                    {
                        tree.getLastChild().
                        getLastChild().
                        addNode(softwareRow["software_name"].ToString());
                    }
                }
            }
            populateUnitBox();
        }
Exemplo n.º 24
0
        private void Button3_Click_1(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show(
                "Вы уверены, что хотите удалить выбранную запись?",
                "Предупреждение", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.No)
            {
                return;
            }

            if (dataGridView1.SelectedRows.Count == 0)
            {
                MessageBox.Show("Сначала выберите объект!");
                return;
            }

            String sql = "BEGIN;";

            sql += String.Format("DELETE FROM `exploit_place` WHERE place_id = '{0}';",
                                 dataGridView1.SelectedRows[0].Cells[0].Value.ToString());

            sql += string.Format("UPDATE unit_info SET last_update = '{0}' " +
                                 "WHERE unit_id = {1};", DateTime.Today.ToString("yyyy-MM-dd"), m_id);

            sql += "COMMIT;";

            DataTable dt = SQLCustom.SQL_Request(Form1.connection, sql);

            if (dt == null)
            {
                MessageBox.Show("Ошибка работы с БД", "Ошибка");
            }
            else
            {
                MessageBox.Show("Запись успешно удалена из БД");

                sql = string.Format("INSERT INTO journal_log " +
                                    "(date_time, user, operation, num_code) " +
                                    "VALUES('{0}', '{1}', '{2}', '{3}')",
                                    DateTime.Now.ToString("yyyy-MM-dd HH:mm"), Form1.userName,
                                    "Удаление ЭО", m_parent.m_numCode);

                dt = SQLCustom.SQL_Request(Form1.connection, sql);

                makeRequest(m_id);
                m_parent.makeRequest(m_id);
            }
        }
Exemplo n.º 25
0
        private void populateDeviationsBox()
        {
            string sql = "SELECT DISTINCT deviation_type FROM deviations";

            DataTable result = SQLCustom.SQL_Request(Form1.connection, sql);

            comboBox7.Items.Clear();
            comboBox8.Items.Clear();

            foreach (DataRow row in result.Rows)
            {
                comboBox8.Items.Add(row[0]);
                comboBox7.Items.Add(row[0]);
            }
        }
Exemplo n.º 26
0
        public Form3(int id, string title)
        {
            String    sql = "SELECT * FROM `unit_info` WHERE `unit_id` = " + id.ToString();
            DataTable dt  = SQLCustom.SQL_Request(Form1.connection, sql);

            this.Text = dt.Rows[0]["unit_num"].ToString() + "   " + title;
            _id       = id;
            //BackColor = Color.PowderBlue;
            BackColor = Color.LightSteelBlue;

            InitializeComponent();
            setAccessSettings();
            setTitle(id);
            makeRequest(id);
        }
Exemplo n.º 27
0
        private void button1_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;
            string    sql;
            DataTable dt;

            bool isSuccessful = false;

            if (!isResourcesDataChanged)
            {
                MessageBox.Show("Такая запись уже существует");
                Cursor = Cursors.Default;
                return;
            }

            if (textBox1.Text != "" && textBox2.Text != "" &&
                textBox3.Text != "" && textBox4.Text != "" &&
                textBox5.Text != "" && textBox6.Text != "" &&
                textBox7.Text != "" && textBox8.Text != "" &&
                textBox9.Text != "" && textBox10.Text != "" &&
                textBox11.Text != "" && comments.Text != "" && isResourcesDataChanged)
            {
                sql = "SELECT * FROM varranty_res WHERE unit_id = " + _id;

                dt = SQLCustom.SQL_Request(Form1.connection, sql);

                if (dt.Rows.Count > 0)
                {
                    isSuccessful = updateResources();
                }
                else
                {
                    isSuccessful = insertResources();
                }
            }

            if (isSuccessful)
            {
                makeRequest(_id);
                Cursor = Cursors.Default;
                this.Close();
                MessageBox.Show("Данные успешно обновлены");
            }
            else
            {
                MessageBox.Show("Ошибка записи в базу данных!");
            }
        }
Exemplo n.º 28
0
        private void button8_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show(
                "Вы уверены, что хотите удалить всю информацию по данному изделию?",
                "Предупреждение", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                DialogResult dialogResult2 = MessageBox.Show(
                    "Вы точно уверены, что хотите удалить всю информацию по данному изделию?",
                    "Предупреждение", MessageBoxButtons.YesNo);

                if (dialogResult2 == DialogResult.Yes)
                {
                    String sql = "BEGIN;";

                    sql += String.Format("DELETE FROM `unit_info` WHERE unit_id = {0};", _id);

                    sql += string.Format("UPDATE unit_info SET last_update = '{0}' " +
                                         "WHERE unit_id = {1};", DateTime.Today.ToString("yyyy-MM-dd"), _id);

                    sql += "COMMIT;";

                    DataTable dt = SQLCustom.SQL_Request(Form1.connection, sql);

                    if (dt.ToString() != "")
                    {
                        MessageBox.Show("Ошибка удаления");
                    }
                    else
                    {
                        MessageBox.Show("Удаление выполнено успешно");

                        sql = string.Format("INSERT INTO journal_log " +
                                            "(date_time, user, operation, num_code) " +
                                            "VALUES('{0}', '{1}', '{2}', '{3}')",
                                            DateTime.Now.ToString("yyyy-MM-dd HH:mm"),
                                            Form1.userName, "Удаление блока",
                                            textBox1.Text + textBox2.Text);

                        dt = SQLCustom.SQL_Request(Form1.connection, sql);

                        frm1.unitDeleted();
                        this.Close();
                    }
                }
            }
        }
Exemplo n.º 29
0
        private bool isRecordConsists(int id)
        {
            string sql = string.Format("SELECT * FROM unit_dispatches " +
                                       "WHERE unit_id = {0};", id);

            DataTable dt = SQLCustom.SQL_Request(Form1.connection, sql);

            if (dt.Rows.Count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 30
0
        private bool isRecordConsists(string table, string record, string value)
        {
            string sql = string.Format("SELECT * FROM {0} " +
                                       "WHERE {1} = '{2}' ", table, record, value);

            DataTable dt = SQLCustom.SQL_Request(m_connection, sql);

            if (dt.Rows.Count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }