Exemplo n.º 1
0
        public void refreshZhurnal()
        {
            listViewZhurnal.Items.Clear();
            queueZhurnal.Clear();

            try
            {
                mainWin.m_dbConnector.Lock();
                MySqlConnection conn = mainWin.m_dbConnector.getMySqlConnection();

                string           sql       = String.Format("SELECT id, cast(`zhurnal`.`date` as char) AS `Data`,`zhurnal`.`FiO` AS `FiO`,`zhurnal`.`N_kvit_nach` AS `KvN`,`zhurnal`.`N_kvit_koniec` AS`Rdbnfywbb`,`zhurnal`.`N_ekskursii` AS `N`,((`zhurnal`.`N_kvit_koniec` - `zhurnal`.`N_kvit_nach`) + 1) AS`KolCzel`,`ekskursii`.`stoimost` AS `Cena`,(`ekskursii`.`stoimost` * ((`zhurnal`.`N_kvit_koniec` -`zhurnal`.`N_kvit_nach`) + 1)) AS `Stoimost`,`zhurnal`.`zakazczik` AS `Zakaz` from (`zhurnal` join `ekskursii` on((`zhurnal`.`N_ekskursii` = `ekskursii`.`N_ekskursii`))) where ((`zhurnal`.`date` >= '{0}') and (`zhurnal`.`date` <= '{1}')) UNION ALL SELECT id, cast(`plategki`.`date` as char) AS`Data`,`plategki`.`FiO` AS `FiO`,`plategki`.`N_platezhki` AS `KvN`,`plategki`.`N_platezhki` AS`KvK`,`plategki`.`N_ekskursii` AS `N`,`plategki`.`Kol_czel` AS `KolCzel`,`ekskursii`.`stoimost` AS`Cena`,(`ekskursii`.`stoimost` * `plategki`.`Kol_czel`) AS `Stoimost`,`plategki`.`zakazczik` AS `Zakaz` FROM (`plategki` join `ekskursii` on((`plategki`.`N_ekskursii` = `ekskursii`.`N_ekskursii`))) WHERE ((`plategki`.`date` >= '{0}') and (`plategki`.`date` <= '{1}'))  order by `Data`", DateTime.Parse(dateTimePicker1.Text).Year + "-" + DateTime.Parse(dateTimePicker1.Text).Month + "-" + DateTime.Parse(dateTimePicker1.Text).Day, DateTime.Parse(dateTimePicker2.Text).Year + "-" + DateTime.Parse(dateTimePicker2.Text).Month + "-" + DateTime.Parse(dateTimePicker2.Text).Day);
                MySqlDataAdapter myAdapter = new MySqlDataAdapter();
                myAdapter.SelectCommand = new MySqlCommand(sql, conn);
                DataSet dataSet = new DataSet();
                myAdapter.Fill(dataSet);
                DataTable dataTable = dataSet.Tables[0];

                listViewZhurnal.Items.Clear();
                queueZhurnal.Clear();
                _Zhurnal t = new _Zhurnal();

                foreach (DataRow dataRow in dataTable.Rows)
                {
                    ListViewItem item1 = new ListViewItem(dataRow["id"].ToString().Trim());
                    t.id = dataRow["id"].ToString().Trim();
                    item1.SubItems.Add(dataRow["Data"].ToString().Trim());
                    t.date = dataRow["Data"].ToString().Trim();
                    item1.SubItems.Add(dataRow["FiO"].ToString().Trim());
                    t.fio = dataRow["FiO"].ToString().Trim();
                    item1.SubItems.Add(dataRow["N"].ToString().Trim());
                    t.numer = dataRow["N"].ToString().Trim();
                    item1.SubItems.Add(dataRow["KvN"].ToString().Trim());
                    t.kvn = dataRow["KvN"].ToString().Trim();
                    item1.SubItems.Add(dataRow["Rdbnfywbb"].ToString().Trim());
                    t.kvk = dataRow["Rdbnfywbb"].ToString().Trim();
                    item1.SubItems.Add(dataRow["KolCzel"].ToString().Trim());
                    t.kolczel = dataRow["KolCzel"].ToString().Trim();
                    item1.SubItems.Add(dataRow["Cena"].ToString().Trim());
                    t.cena = dataRow["Cena"].ToString().Trim();
                    item1.SubItems.Add(dataRow["Stoimost"].ToString().Trim());
                    t.stoimost = dataRow["Stoimost"].ToString().Trim();
                    item1.SubItems.Add(dataRow["Zakaz"].ToString().Trim());
                    t.zakaz = dataRow["Zakaz"].ToString().Trim();


                    listViewZhurnal.Items.Add(item1);
                    listViewZhurnal.Items[listViewZhurnal.Items.Count - 1].Tag = dataRow["id"].ToString();
                    queueZhurnal.Enqueue(t);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                mainWin.m_dbConnector.Unlock();
            }
        }
Exemplo n.º 2
0
        private void buttonFilter_Click(object sender, EventArgs e)
        {
            listViewZhurnal.Items.Clear();
            queueZhurnal.Clear();

            try
            {
                mainWin.m_dbConnector.Lock();
                MySqlConnection conn = mainWin.m_dbConnector.getMySqlConnection();

                string sql = string.Format("SELECT id, cast(`zhurnal`.`date` as char) AS `Data`,`zhurnal`.`FiO` AS `FiO`,`zhurnal`.`N_kvit_nach` AS `KvN`,`zhurnal`.`N_kvit_koniec` AS`Rdbnfywbb`,`zhurnal`.`N_ekskursii` AS `N`,((`zhurnal`.`N_kvit_koniec` - `zhurnal`.`N_kvit_nach`) + 1) AS`KolCzel`,`ekskursii`.`stoimost` AS `Cena`,(`ekskursii`.`stoimost` * ((`zhurnal`.`N_kvit_koniec` -`zhurnal`.`N_kvit_nach`) + 1)) AS `Stoimost`,`zhurnal`.`zakazczik` AS `Zakaz` from (`zhurnal` join `ekskursii` on((`zhurnal`.`N_ekskursii` = `ekskursii`.`N_ekskursii`))) WHERE ((`zhurnal`.`date` >= '{0}') and (`zhurnal`.`date` <= '{1}')) UNION SELECT id, cast(`plategki`.`date` as char) AS`Data`,`plategki`.`FiO` AS `FiO`,`plategki`.`N_platezhki` AS `KvN`,`plategki`.`N_platezhki` AS`KvK`,`plategki`.`N_ekskursii` AS `N`,`plategki`.`Kol_czel` AS `KolCzel`,`ekskursii`.`stoimost` AS`Cena`,(`ekskursii`.`stoimost` * `plategki`.`Kol_czel`) AS `Stoimost`,`plategki`.`zakazczik` AS `Zakaz` FROM (`plategki` join `ekskursii` on((`plategki`.`N_ekskursii` = `ekskursii`.`N_ekskursii`))) WHERE ((`plategki`.`date` >= '{0}') and (`plategki`.`date` <= '{1}')) union select '' AS `id`,'{1}' AS `Data`,'' AS `FiO`,count(0) AS `KvN`,'Кол-во человек' AS `KvK`,'Кол-во экскурсий' AS `N`,sum(((`zhurnal`.`N_kvit_koniec` - `zhurnal`.`N_kvit_nach`) + 1)) AS `KolCzel`,'Стоимость' AS `Cena`,sum((`ekskursii`.`stoimost` * ((`zhurnal`.`N_kvit_koniec` - `zhurnal`.`N_kvit_nach`) + 1))) AS `Stoimost`,'' AS `Zakaz` from (`zhurnal` join `ekskursii` on((`zhurnal`.`N_ekskursii` = `ekskursii`.`N_ekskursii`))) where ((`zhurnal`.`date` >= '{0}') and (`zhurnal`.`date` <= '{1}')) union all select '' AS `id`,'{1}' AS `Data`,'' AS `FiO`,count(0) AS `KvN`,'Кол-во человек б/н' AS `KvK`,'Кол-во экскурсий б/н' AS `N`,sum(`plategki`.`Kol_czel`) AS `KolCzel`,'Стоимость б/н' AS `Cena`,sum((`ekskursii`.`stoimost` * (`plategki`.`Kol_czel`))) AS `Stoimost`,'' AS `Zakaz` from (`plategki` join `ekskursii` on((`plategki`.`N_ekskursii` = `ekskursii`.`N_ekskursii`))) where ((`plategki`.`date` >= '{0}') and (`plategki`.`date` <= '{1}'))", DateTime.Parse(dateTimePicker1.Text).Year + "-" + DateTime.Parse(dateTimePicker1.Text).Month + "-" + DateTime.Parse(dateTimePicker1.Text).Day, DateTime.Parse(dateTimePicker2.Text).Year + "-" + DateTime.Parse(dateTimePicker2.Text).Month + "-" + DateTime.Parse(dateTimePicker2.Text).Day);
                //DateTime.Parse(dateTimePicker1.Text).Year + "-" + DateTime.Parse(dateTimePicker1.Text).Month + "-" + DateTime.Parse(dateTimePicker1.Text).Day, DateTime.Parse(dateTimePicker2.Text).Year + "-" + DateTime.Parse(dateTimePicker2.Text).Month + "-" + DateTime.Parse(dateTimePicker2.Text).Day);
                MySqlDataAdapter myAdapter = new MySqlDataAdapter();
                myAdapter.SelectCommand = new MySqlCommand(sql, conn);
                DataSet dataSet = new DataSet();
                myAdapter.Fill(dataSet);
                DataTable dataTable = dataSet.Tables[0];

                listViewZhurnal.Items.Clear();
                queueZhurnal.Clear();
                _Zhurnal x = new _Zhurnal();

                foreach (DataRow dataRow in dataTable.Rows)
                {
                    ListViewItem item1 = new ListViewItem(dataRow["id"].ToString().Trim());
                    x.id = dataRow["id"].ToString().Trim();
                    item1.SubItems.Add(dataRow["Data"].ToString().Trim());
                    x.date = dataRow["Data"].ToString().Trim();
                    item1.SubItems.Add(dataRow["FiO"].ToString().Trim());
                    x.fio = dataRow["FiO"].ToString().Trim();
                    item1.SubItems.Add(dataRow["N"].ToString().Trim());
                    x.numer = dataRow["N"].ToString().Trim();
                    item1.SubItems.Add(dataRow["KvN"].ToString().Trim());
                    x.kvn = dataRow["KvN"].ToString().Trim();
                    item1.SubItems.Add(dataRow["Rdbnfywbb"].ToString().Trim());
                    x.kvk = dataRow["Rdbnfywbb"].ToString().Trim();
                    item1.SubItems.Add(dataRow["KolCzel"].ToString().Trim());
                    x.kolczel = dataRow["KolCzel"].ToString().Trim();
                    item1.SubItems.Add(dataRow["Cena"].ToString().Trim());
                    x.cena = dataRow["Cena"].ToString().Trim();
                    item1.SubItems.Add(dataRow["Stoimost"].ToString().Trim());
                    x.stoimost = dataRow["Stoimost"].ToString().Trim();
                    item1.SubItems.Add(dataRow["Zakaz"].ToString().Trim());
                    x.zakaz = dataRow["Zakaz"].ToString().Trim();


                    listViewZhurnal.Items.Add(item1);
                    listViewZhurnal.Items[listViewZhurnal.Items.Count - 1].Tag = dataRow["id"].ToString();
                    queueZhurnal.Enqueue(x);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                mainWin.m_dbConnector.Unlock();
            }

            buttonApply.Enabled  = true;
            buttonDelete.Enabled = false;

            textBoxKvN.Text             = "";
            textBoxKvN.Enabled          = false;
            textBoxKvK.Text             = "";
            textBoxKvK.Enabled          = false;
            textBoxKolCzel.Text         = "";
            textBoxKolCzel.Enabled      = false;
            dateTimePickerDate.Enabled  = false;
            comboBoxEkskursija.Enabled  = false;
            comboBoxEkskursovod.Enabled = false;
            comboBoxZakazczik.Enabled   = false;
        }
Exemplo n.º 3
0
        private void listViewZhurnal_SelectedIndexChanged(object sender, EventArgs e)
        {
            buttonApply.Enabled  = true;
            buttonDelete.Enabled = true;

            comboBoxEkskursovod.SelectedIndex = -1;
            comboBoxEkskursovod.Enabled       = true;
            comboBoxEkskursija.SelectedIndex  = -1;
            comboBoxEkskursija.Enabled        = true;
            comboBoxZakazczik.SelectedIndex   = -1;
            comboBoxZakazczik.Enabled         = true;
            textBoxKvN.Text            = "";
            textBoxKvN.Enabled         = true;
            textBoxKvK.Text            = "";
            textBoxKvK.Enabled         = true;
            textBoxKolCzel.Text        = "";
            textBoxKolCzel.Enabled     = true;
            dateTimePickerDate.Enabled = true;

            bNew = false;

            if (listViewZhurnal.FocusedItem == null)
            {
                return;
            }

            int k = queueZhurnal.Count;

            for (int i = 0; i < k; i++)
            {
                m_zhurnal = (_Zhurnal)queueZhurnal.Dequeue();
                if (m_zhurnal.id.ToString() == (string)listViewZhurnal.Items[listViewZhurnal.FocusedItem.Index].Tag)
                {
                    comboBoxEkskursija.Text  = m_ekskursii.id;
                    comboBoxEkskursovod.Text = m_zhurnal.fio;
                    comboBoxZakazczik.Text   = m_zhurnal.zakaz;
                    textBoxKvN.Text          = m_zhurnal.kvn;
                    textBoxKvK.Text          = m_zhurnal.kvk;
                    textBoxKolCzel.Text      = m_zhurnal.kolczel;
                    dateTimePickerDate.Value = DateTime.Parse(m_zhurnal.date);
                    //фигня для comboboxов
                    _Ekskursii c;
                    int        k2 = queueEkskursii.Count;
                    for (int i2 = 0; i2 < k2; i2++)
                    {
                        c = (_Ekskursii)queueEkskursii.Dequeue();
                        if (c.id.ToString() == m_zhurnal.numer.ToString())
                        {
                            for (int iii = 0; iii < comboBoxEkskursija.Items.Count; iii++)
                            {
                                if (((_Ekskursii)comboBoxEkskursija.Items[iii]).id == c.id)
                                {
                                    comboBoxEkskursija.SelectedIndex = iii;
                                    m_ekskursii = c;
                                    break;
                                }
                            }
                        }
                        ;
                        queueEkskursii.Enqueue(c);
                    }

                    _Zakazczik d;
                    k2 = queueZakazczik.Count;
                    for (int i2 = 0; i2 < k2; i2++)
                    {
                        d = (_Zakazczik)queueZakazczik.Dequeue();
                        if (d.id.ToString() == m_zhurnal.zakaz.ToString())
                        {
                            for (int iii = 0; iii < comboBoxZakazczik.Items.Count; iii++)
                            {
                                if (((_Zakazczik)comboBoxZakazczik.Items[iii]).id == d.id)
                                {
                                    comboBoxZakazczik.SelectedIndex = iii;
                                    m_zakazczik = d;
                                    break;
                                }
                            }
                        }
                        ;
                        queueZakazczik.Enqueue(d);
                    }

                    _Ekskursovody a;
                    k2 = queueEkskursovod.Count;
                    for (int i2 = 0; i2 < k2; i2++)
                    {
                        a = (_Ekskursovody)queueEkskursovod.Dequeue();
                        if (a.name.ToString() == m_zhurnal.fio.ToString())
                        {
                            for (int iii = 0; iii < comboBoxEkskursovod.Items.Count; iii++)
                            {
                                if (((_Ekskursovody)comboBoxEkskursovod.Items[iii]).id == a.id)
                                {
                                    comboBoxEkskursovod.SelectedIndex = iii;
                                    m_ekskursovody = a;
                                    break;
                                }
                            }
                        }
                        ;

                        queueEkskursovod.Enqueue(a);
                    }

                    queueZhurnal.Enqueue(m_zhurnal);
                    break;
                }
                ;


                queueZhurnal.Enqueue(m_zhurnal);
            }
        }
Exemplo n.º 4
0
        private void listViewZhurnal_SelectedIndexChanged(object sender, EventArgs e)
        {
            buttonApply.Enabled = true;
            buttonDelete.Enabled = true;

            comboBoxEkskursovod.SelectedIndex = -1;
            comboBoxEkskursovod.Enabled = true;
            comboBoxEkskursija.SelectedIndex = -1;
            comboBoxEkskursija.Enabled = true;
            comboBoxZakazczik.SelectedIndex = -1;
            comboBoxZakazczik.Enabled = true;
            textBoxKvN.Text = "";
            textBoxKvN.Enabled = true;
            textBoxKvK.Text = "";
            textBoxKvK.Enabled = true;
            textBoxKolCzel.Text = "";
            textBoxKolCzel.Enabled = true;
            dateTimePickerDate.Enabled = true;

            bNew = false;

            if (listViewZhurnal.FocusedItem == null)
                return;

            int k = queueZhurnal.Count;
            for (int i = 0; i < k; i++)
            {
                m_zhurnal = (_Zhurnal)queueZhurnal.Dequeue();
                if (m_zhurnal.id.ToString() == (string)listViewZhurnal.Items[listViewZhurnal.FocusedItem.Index].Tag)
                {
                    comboBoxEkskursija.Text = m_ekskursii.id;
                    comboBoxEkskursovod.Text = m_zhurnal.fio;
                    comboBoxZakazczik.Text = m_zhurnal.zakaz;
                    textBoxKvN.Text = m_zhurnal.kvn;
                    textBoxKvK.Text = m_zhurnal.kvk;
                    textBoxKolCzel.Text = m_zhurnal.kolczel;
                    dateTimePickerDate.Value = DateTime.Parse(m_zhurnal.date);
                    //фигня для comboboxов
                    _Ekskursii c;
                    int k2 = queueEkskursii.Count;
                    for (int i2 = 0; i2 < k2; i2++)
                    {
                        c = (_Ekskursii)queueEkskursii.Dequeue();
                        if (c.id.ToString() == m_zhurnal.numer.ToString())
                        {
                             for (int iii = 0; iii < comboBoxEkskursija.Items.Count; iii++)
                            {
                                if (((_Ekskursii)comboBoxEkskursija.Items[iii]).id == c.id)
                                {
                                    comboBoxEkskursija.SelectedIndex = iii;
                                    m_ekskursii = c;
                                    break;
                                }
                            }
                        };
                        queueEkskursii.Enqueue(c);
                    }

                    _Zakazczik d;
                    k2 = queueZakazczik.Count;
                    for (int i2 = 0; i2 < k2; i2++)
                    {
                        d = (_Zakazczik)queueZakazczik.Dequeue();
                        if (d.id.ToString() == m_zhurnal.zakaz.ToString())
                        {
                            for (int iii = 0; iii < comboBoxZakazczik.Items.Count; iii++)
                            {
                                if (((_Zakazczik)comboBoxZakazczik.Items[iii]).id == d.id)
                                {
                                    comboBoxZakazczik.SelectedIndex = iii;
                                    m_zakazczik = d;
                                    break;
                                }
                            }
                        };
                        queueZakazczik.Enqueue(d);
                    }

                    _Ekskursovody a;
                    k2 = queueEkskursovod.Count;
                    for (int i2 = 0; i2 < k2; i2++)
                    {
                        a = (_Ekskursovody)queueEkskursovod.Dequeue();
                        if (a.name.ToString() == m_zhurnal.fio.ToString())
                        {

                            for (int iii = 0; iii < comboBoxEkskursovod.Items.Count; iii++)
                            {
                                if (((_Ekskursovody)comboBoxEkskursovod.Items[iii]).id == a.id)
                                {
                                    comboBoxEkskursovod.SelectedIndex = iii;
                                    m_ekskursovody = a;
                                    break;
                                }
                            }
                        };

                            queueEkskursovod.Enqueue(a);
                        }

                        queueZhurnal.Enqueue(m_zhurnal);
                        break;

                    };

                queueZhurnal.Enqueue(m_zhurnal);
                }
        }
Exemplo n.º 5
0
        private void buttonFilter_Click(object sender, EventArgs e)
        {
            listViewZhurnal.Items.Clear();
            queueZhurnal.Clear();

            try
            {
                mainWin.m_dbConnector.Lock();
                MySqlConnection conn = mainWin.m_dbConnector.getMySqlConnection();

                string sql = string.Format("SELECT id, cast(`zhurnal`.`date` as char) AS `Data`,`zhurnal`.`FiO` AS `FiO`,`zhurnal`.`N_kvit_nach` AS `KvN`,`zhurnal`.`N_kvit_koniec` AS`Rdbnfywbb`,`zhurnal`.`N_ekskursii` AS `N`,((`zhurnal`.`N_kvit_koniec` - `zhurnal`.`N_kvit_nach`) + 1) AS`KolCzel`,`ekskursii`.`stoimost` AS `Cena`,(`ekskursii`.`stoimost` * ((`zhurnal`.`N_kvit_koniec` -`zhurnal`.`N_kvit_nach`) + 1)) AS `Stoimost`,`zhurnal`.`zakazczik` AS `Zakaz` from (`zhurnal` join `ekskursii` on((`zhurnal`.`N_ekskursii` = `ekskursii`.`N_ekskursii`))) WHERE ((`zhurnal`.`date` >= '{0}') and (`zhurnal`.`date` <= '{1}')) UNION SELECT id, cast(`plategki`.`date` as char) AS`Data`,`plategki`.`FiO` AS `FiO`,`plategki`.`N_platezhki` AS `KvN`,`plategki`.`N_platezhki` AS`KvK`,`plategki`.`N_ekskursii` AS `N`,`plategki`.`Kol_czel` AS `KolCzel`,`ekskursii`.`stoimost` AS`Cena`,(`ekskursii`.`stoimost` * `plategki`.`Kol_czel`) AS `Stoimost`,`plategki`.`zakazczik` AS `Zakaz` FROM (`plategki` join `ekskursii` on((`plategki`.`N_ekskursii` = `ekskursii`.`N_ekskursii`))) WHERE ((`plategki`.`date` >= '{0}') and (`plategki`.`date` <= '{1}')) union select '' AS `id`,'{1}' AS `Data`,'' AS `FiO`,count(0) AS `KvN`,'Кол-во человек' AS `KvK`,'Кол-во экскурсий' AS `N`,sum(((`zhurnal`.`N_kvit_koniec` - `zhurnal`.`N_kvit_nach`) + 1)) AS `KolCzel`,'Стоимость' AS `Cena`,sum((`ekskursii`.`stoimost` * ((`zhurnal`.`N_kvit_koniec` - `zhurnal`.`N_kvit_nach`) + 1))) AS `Stoimost`,'' AS `Zakaz` from (`zhurnal` join `ekskursii` on((`zhurnal`.`N_ekskursii` = `ekskursii`.`N_ekskursii`))) where ((`zhurnal`.`date` >= '{0}') and (`zhurnal`.`date` <= '{1}')) union all select '' AS `id`,'{1}' AS `Data`,'' AS `FiO`,count(0) AS `KvN`,'Кол-во человек б/н' AS `KvK`,'Кол-во экскурсий б/н' AS `N`,sum(`plategki`.`Kol_czel`) AS `KolCzel`,'Стоимость б/н' AS `Cena`,sum((`ekskursii`.`stoimost` * (`plategki`.`Kol_czel`))) AS `Stoimost`,'' AS `Zakaz` from (`plategki` join `ekskursii` on((`plategki`.`N_ekskursii` = `ekskursii`.`N_ekskursii`))) where ((`plategki`.`date` >= '{0}') and (`plategki`.`date` <= '{1}'))", DateTime.Parse(dateTimePicker1.Text).Year + "-" + DateTime.Parse(dateTimePicker1.Text).Month + "-" + DateTime.Parse(dateTimePicker1.Text).Day, DateTime.Parse(dateTimePicker2.Text).Year + "-" + DateTime.Parse(dateTimePicker2.Text).Month + "-" + DateTime.Parse(dateTimePicker2.Text).Day);
                    //DateTime.Parse(dateTimePicker1.Text).Year + "-" + DateTime.Parse(dateTimePicker1.Text).Month + "-" + DateTime.Parse(dateTimePicker1.Text).Day, DateTime.Parse(dateTimePicker2.Text).Year + "-" + DateTime.Parse(dateTimePicker2.Text).Month + "-" + DateTime.Parse(dateTimePicker2.Text).Day);
                MySqlDataAdapter myAdapter = new MySqlDataAdapter();
                myAdapter.SelectCommand = new MySqlCommand(sql, conn);
                DataSet dataSet = new DataSet();
                myAdapter.Fill(dataSet);
                DataTable dataTable = dataSet.Tables[0];

                listViewZhurnal.Items.Clear();
                queueZhurnal.Clear();
                _Zhurnal x = new _Zhurnal();

              foreach (DataRow dataRow in dataTable.Rows)
                {
                    ListViewItem item1 = new ListViewItem(dataRow["id"].ToString().Trim());
                    x.id = dataRow["id"].ToString().Trim();
                    item1.SubItems.Add(dataRow["Data"].ToString().Trim());
                    x.date = dataRow["Data"].ToString().Trim();
                    item1.SubItems.Add(dataRow["FiO"].ToString().Trim());
                    x.fio = dataRow["FiO"].ToString().Trim();
                    item1.SubItems.Add(dataRow["N"].ToString().Trim());
                    x.numer = dataRow["N"].ToString().Trim();
                    item1.SubItems.Add(dataRow["KvN"].ToString().Trim());
                    x.kvn = dataRow["KvN"].ToString().Trim();
                    item1.SubItems.Add(dataRow["Rdbnfywbb"].ToString().Trim());
                    x.kvk = dataRow["Rdbnfywbb"].ToString().Trim();
                    item1.SubItems.Add(dataRow["KolCzel"].ToString().Trim());
                    x.kolczel = dataRow["KolCzel"].ToString().Trim();
                    item1.SubItems.Add(dataRow["Cena"].ToString().Trim());
                    x.cena = dataRow["Cena"].ToString().Trim();
                    item1.SubItems.Add(dataRow["Stoimost"].ToString().Trim());
                    x.stoimost = dataRow["Stoimost"].ToString().Trim();
                    item1.SubItems.Add(dataRow["Zakaz"].ToString().Trim());
                    x.zakaz = dataRow["Zakaz"].ToString().Trim();

                    listViewZhurnal.Items.Add(item1);
                    listViewZhurnal.Items[listViewZhurnal.Items.Count - 1].Tag = dataRow["id"].ToString();
                    queueZhurnal.Enqueue(x);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                mainWin.m_dbConnector.Unlock();
            }

            buttonApply.Enabled = true;
            buttonDelete.Enabled = false;

            textBoxKvN.Text = "";
            textBoxKvN.Enabled = false;
            textBoxKvK.Text = "";
            textBoxKvK.Enabled = false;
            textBoxKolCzel.Text = "";
            textBoxKolCzel.Enabled = false;
            dateTimePickerDate.Enabled = false;
            comboBoxEkskursija.Enabled = false;
            comboBoxEkskursovod.Enabled = false;
            comboBoxZakazczik.Enabled = false;
        }
Exemplo n.º 6
0
        public void refreshZhurnal()
        {
            listViewZhurnal.Items.Clear();
            queueZhurnal.Clear();

            try
            {
                mainWin.m_dbConnector.Lock();
                MySqlConnection conn = mainWin.m_dbConnector.getMySqlConnection();

                string sql = String.Format("SELECT id, cast(`zhurnal`.`date` as char) AS `Data`,`zhurnal`.`FiO` AS `FiO`,`zhurnal`.`N_kvit_nach` AS `KvN`,`zhurnal`.`N_kvit_koniec` AS`Rdbnfywbb`,`zhurnal`.`N_ekskursii` AS `N`,((`zhurnal`.`N_kvit_koniec` - `zhurnal`.`N_kvit_nach`) + 1) AS`KolCzel`,`ekskursii`.`stoimost` AS `Cena`,(`ekskursii`.`stoimost` * ((`zhurnal`.`N_kvit_koniec` -`zhurnal`.`N_kvit_nach`) + 1)) AS `Stoimost`,`zhurnal`.`zakazczik` AS `Zakaz` from (`zhurnal` join `ekskursii` on((`zhurnal`.`N_ekskursii` = `ekskursii`.`N_ekskursii`))) where ((`zhurnal`.`date` >= '{0}') and (`zhurnal`.`date` <= '{1}')) UNION ALL SELECT id, cast(`plategki`.`date` as char) AS`Data`,`plategki`.`FiO` AS `FiO`,`plategki`.`N_platezhki` AS `KvN`,`plategki`.`N_platezhki` AS`KvK`,`plategki`.`N_ekskursii` AS `N`,`plategki`.`Kol_czel` AS `KolCzel`,`ekskursii`.`stoimost` AS`Cena`,(`ekskursii`.`stoimost` * `plategki`.`Kol_czel`) AS `Stoimost`,`plategki`.`zakazczik` AS `Zakaz` FROM (`plategki` join `ekskursii` on((`plategki`.`N_ekskursii` = `ekskursii`.`N_ekskursii`))) WHERE ((`plategki`.`date` >= '{0}') and (`plategki`.`date` <= '{1}'))  order by `Data`", DateTime.Parse(dateTimePicker1.Text).Year + "-" + DateTime.Parse(dateTimePicker1.Text).Month + "-" + DateTime.Parse(dateTimePicker1.Text).Day, DateTime.Parse(dateTimePicker2.Text).Year + "-" + DateTime.Parse(dateTimePicker2.Text).Month + "-" + DateTime.Parse(dateTimePicker2.Text).Day);
                MySqlDataAdapter myAdapter = new MySqlDataAdapter();
                myAdapter.SelectCommand = new MySqlCommand(sql, conn);
                DataSet dataSet = new DataSet();
                myAdapter.Fill(dataSet);
                DataTable dataTable = dataSet.Tables[0];

                listViewZhurnal.Items.Clear();
                queueZhurnal.Clear();
                _Zhurnal t = new _Zhurnal();

              foreach (DataRow dataRow in dataTable.Rows)
                {
                    ListViewItem item1 = new ListViewItem(dataRow["id"].ToString().Trim());
                    t.id = dataRow["id"].ToString().Trim();
                    item1.SubItems.Add(dataRow["Data"].ToString().Trim());
                    t.date = dataRow["Data"].ToString().Trim();
                    item1.SubItems.Add(dataRow["FiO"].ToString().Trim());
                    t.fio = dataRow["FiO"].ToString().Trim();
                    item1.SubItems.Add(dataRow["N"].ToString().Trim());
                    t.numer = dataRow["N"].ToString().Trim();
                    item1.SubItems.Add(dataRow["KvN"].ToString().Trim());
                    t.kvn = dataRow["KvN"].ToString().Trim();
                    item1.SubItems.Add(dataRow["Rdbnfywbb"].ToString().Trim());
                    t.kvk = dataRow["Rdbnfywbb"].ToString().Trim();
                    item1.SubItems.Add(dataRow["KolCzel"].ToString().Trim());
                    t.kolczel = dataRow["KolCzel"].ToString().Trim();
                    item1.SubItems.Add(dataRow["Cena"].ToString().Trim());
                    t.cena = dataRow["Cena"].ToString().Trim();
                    item1.SubItems.Add(dataRow["Stoimost"].ToString().Trim());
                    t.stoimost = dataRow["Stoimost"].ToString().Trim();
                    item1.SubItems.Add(dataRow["Zakaz"].ToString().Trim());
                    t.zakaz = dataRow["Zakaz"].ToString().Trim();

                    listViewZhurnal.Items.Add(item1);
                    listViewZhurnal.Items[listViewZhurnal.Items.Count - 1].Tag = dataRow["id"].ToString();
                    queueZhurnal.Enqueue(t);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                mainWin.m_dbConnector.Unlock();
            }
        }