Example #1
0
 private void button1_Click(object sender, EventArgs e)//Добавление нового документа
 {
     if (textBox1.Text != string.Empty)
     {
         SQLiteConnection conn = DBUtils.GetDBConnection();
         SQLiteCommand    cmd  = new SQLiteCommand();
         conn.Open();
         cmd.Connection  = conn;
         cmd.CommandText = "INSERT INTO docs ('ykaz', 'opis','id_isp','srok_control','nomer_doc','podrazdelenie','status') values ('" +
                           textBox1.Text + "' , '" +
                           richTextBox1.Text + "',(SELECT _id FROM worker WHERE isp_name='" + comboBox1.SelectedItem.ToString() + "'),'" + dateTimePicker1.Value.ToString("dd-MMMM-yyyy") + "','" + textBox2.Text + "','" + textBox3.Text + "','" + comboBox2.SelectedItem.ToString() + "')";
         cmd.ExecuteNonQuery();
         conn.Close();
         ResetAll();
         MessageBox.Show("Новый документ создан", "УСПЕХ", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else
     {
         MessageBox.Show("Заполните поля", "ОШИБКА", MessageBoxButtons.OK, MessageBoxIcon.Stop);
     }
 }
Example #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            //MessageBox.Show(worker.SelectedItem.ToString());
            if (statusDoc.SelectedIndex > -1 && worker.SelectedIndex > -1)
            {
                SQLiteConnection conn = DBUtils.GetDBConnection();
                SQLiteCommand    cmd  = new SQLiteCommand();
                conn.Open();
                cmd.Connection  = conn;
                cmd.CommandText = "UPDATE docs SET ykaz='" + raspor.Text + "',opis='" + little_opis.Text + "',id_isp=(SELECT _id FROM worker WHERE isp_name='" + worker.SelectedItem.ToString() + "'),srok_control='" + dateTimePicker1.Value.ToString("dd-MMMM-yyyy") + "',nomer_doc='" + number_doc.Text + "',podrazdelenie='" + podrazdelText.Text + "',status='" + statusDoc.SelectedItem.ToString() + "' WHERE _id='" + Convert.ToInt32(poryadokText.Text) + "'";

                cmd.ExecuteNonQuery();
                //conn.Close();

                MessageBox.Show("Данные упешно обновлены", "УСПЕХ", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("Проверьте поля ответственное лицо или статус документа", "ОШБКА", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #3
0
        private void button2_Click(object sender, EventArgs e)
        {
            SQLiteConnection conn = DBUtils.GetDBConnection();
            SQLiteCommand    cmd  = new SQLiteCommand();

            DialogResult result = MessageBox.Show("Удаление приведет к потере всех данных, точно удалить?", "Проверка действия", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                cmd.Connection = conn;
                conn.Open();
                cmd.CommandText = "DELETE FROM docs";
                cmd.ExecuteNonQuery();
                cmd.CommandText = "DELETE FROM sqlite_sequence WHERE name='docs'";
                cmd.ExecuteNonQuery();
                conn.Close();

                MessageBox.Show("База данных полностью очищена", "УСПЕХ", MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
            else
            {
                MessageBox.Show("Вы отменили действие на удаление", "УСПЕХ", MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
        }
Example #4
0
        private void StartExport_Click(object sender, EventArgs e)
        {
            System.IO.StreamWriter fileWriter = new StreamWriter(pathSaveXcel.Text + @"\" + fileName.Text + ".xls", false, Encoding.GetEncoding(1251));
            SQLiteConnection       conn       = DBUtils.GetDBConnection();
            SQLiteCommand          cmd        = new SQLiteCommand();

            cmd.CommandText = @"SELECT _id,ykaz,opis,(SELECT isp_name FROM worker WHERE id_isp=_id),srok_control,nomer_doc,podrazdelenie,status FROM docs";
            cmd.Connection  = conn;
            conn.Open();
            SQLiteDataReader dr = cmd.ExecuteReader();

            while (dr.Read())
            {
                string dataFromGrid = "";
                // dataFromGrid = dr.GetValue(0).ToString() + "@" + reader.GetValue(1).ToString() + "@" + reader.GetString(2) + "@" + reader.GetValue(3) + "@" + reader.GetValue(4) + "@" + reader.GetValue(6) + "@" + reader.GetValue(7) + "@" + reader.GetValue(9) + "@" + reader.GetValue(10) + "@";

                dataFromGrid = dr.GetValue(0).ToString() + "@" + dr.GetValue(1).ToString() + "@" + dr.GetValue(2).ToString() + "@" + dr.GetValue(3).ToString() + "@" + dr.GetValue(4).ToString() + "@" + dr.GetValue(5).ToString() + "@" + dr.GetValue(6).ToString() + "@" + dr.GetValue(7).ToString();
                fileWriter.WriteLine(dataFromGrid);
            }
            fileWriter.Flush();
            fileWriter.Close();
            conn.Close();
            MessageBox.Show("Экспорт успешно завершен файл с именем '" + fileName.Text + "' создан", "УСПЕХ", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Example #5
0
        public void View_Load()
        {
            SQLiteConnection conn = DBUtils.GetDBConnection();

            conn.Open();
            SQLiteCommand cmd    = new SQLiteCommand();
            DataTable     dTable = new DataTable();
            String        sqlQuery;

            cmd.Connection = conn;
            sqlQuery       = "SELECT docs._id,ykaz,opis,isp_name,srok_control,nomer_doc,podrazdelenie,status  FROM docs,worker WHERE docs.id_isp=worker._id and status='В работе'";
            SQLiteDataAdapter adapter = new SQLiteDataAdapter(sqlQuery, conn);

            adapter.Fill(dTable);
            if (dTable.Rows.Count > 0)
            {
                dataGridView1.Rows.Clear();

                for (int i = 0; i < dTable.Rows.Count; i++)
                {
                    dataGridView1.Rows.Add(dTable.Rows[i].ItemArray);
                }
                conn.Close();

                foreach (DataGridViewRow row in dataGridView1.Rows)                                  //цикл
                {
                    int days  = (DateTime.Parse(row.Cells[4].Value.ToString()) - DateTime.Now).Days; //дней осталось
                    int month = (DateTime.Parse(row.Cells[4].Value.ToString())).Month - DateTime.Now.Month;

                    if (days == 0 & month == 0)
                    {
                        for (int i = 0; i < dataGridView1.ColumnCount; i++)
                        {
                            row.Cells[i].Style.BackColor = System.Drawing.Color.LightGreen; //красим зеленым
                        }

                        MessageBox.Show("Порядковый номер=> " + row.Cells[0].Value.ToString() + "   " + "Суть документа=> " + row.Cells[2].Value.ToString() + "", "ДОКУМЕНТ ОЖИДАЕТ РЕШЕНИЯ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }

                    if (days < -1 & month < 0)
                    {
                        for (int i = 0; i < dataGridView1.ColumnCount; i++)
                        {
                            row.Cells[i].Style.BackColor = System.Drawing.Color.Red; //красим красным
                        }
                        MessageBox.Show("Порядковый номер=> " + row.Cells[0].Value.ToString() + "   " + "Суть документа=> " + row.Cells[2].Value.ToString() + "", "ДОКУМЕНТ ПРОСРОЧЕН", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    if (days < 0 & month == 0)
                    {
                        for (int i = 0; i < dataGridView1.ColumnCount; i++)
                        {
                            row.Cells[i].Style.BackColor = System.Drawing.Color.Red; //красим красным
                        }
                        MessageBox.Show("Порядковый номер=> " + row.Cells[0].Value.ToString() + "   " + "Суть документа=> " + row.Cells[2].Value.ToString() + "", "ДОКУМЕНТ ПРОСРОЧЕН", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }

            else
            {
                MessageBox.Show("База данных пустая");
            }
        }