예제 #1
0
        private void добавитьМастераToolStripMenuItem_Click(object sender, EventArgs e)
        {
            button2.Visible = false;
            button3.Visible = false;
            button4.Visible = false;
            button5.Visible = false;
            global.dob      = 1;
            DobavMaster frm = new DobavMaster();

            this.Hide();
            frm.Show();
        }
예제 #2
0
        //изменение заказао(1) и мастеров(2)
        private void button3_Click(object sender, EventArgs e)
        {
            button4.Visible = false;
            button5.Visible = false;
            if (menu == 2)//изменение мастеров
            {
                global.dob = 0;
                DobavMaster frm    = new DobavMaster();
                int         RowNum = dataGridView1.CurrentRow.Index;

                global.Master_ID  = (int)dataGridView1[0, RowNum].Value;
                frm.textBox3.Text = dataGridView1[1, RowNum].Value.ToString();
                frm.textBox4.Text = dataGridView1[2, RowNum].Value.ToString();
                frm.textBox5.Text = dataGridView1[3, RowNum].Value.ToString();
                frm.textBox6.Text = dataGridView1[4, RowNum].Value.ToString();
                this.Hide();
                frm.Show();
            }
            else if (menu == 1)//изменение заказов
            {
                int RowNum = dataGridView1.CurrentRow.Index;
                if ((string)dataGridView1[3, RowNum].Value == "Ожидание")
                {
                    string zapros = "";
                    global.conn.Open();
                    SqlCommand cmd = new SqlCommand(zapros, global.conn);
                    //заполнение листа местами
                    zapros = "select mesto1,mesto2,mesto3,mesto4 from Grafik, Master where Grafik.Master_ID = (select Master_ID From Master where Familia='" + dataGridView1[4, RowNum].Value + "') and _date='" + dataGridView1[2, RowNum].Value + "'";
                    cmd    = new SqlCommand(zapros, global.conn);
                    SqlDataReader reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        mesto obj = new mesto();
                        obj.mest1 = (bool)reader[0];
                        obj.mest2 = (bool)reader[1];
                        obj.mest3 = (bool)reader[2];
                        obj.mest4 = (bool)reader[3];
                        mests.Add(obj);
                    }
                    reader.Close();

                    //удаление выделенного заказа
                    zapros = "delete from Zacaz where Master_ID = (select Master_ID From Master where Familia='" + dataGridView1[4, RowNum].Value + "')and Klient='" + dataGridView1[0, RowNum].Value + "' and Mesto='" + dataGridView1[1, RowNum].Value + "' and Data='" + dataGridView1[2, RowNum].Value + "'and Gotovnost=0";
                    cmd    = new SqlCommand(zapros, global.conn);
                    cmd.ExecuteNonQuery();

                    //обновление в графике
                    if ((string)dataGridView1[1, RowNum].Value == "9:00-11:00")
                    {
                        mests[0].mest1 = false;
                    }
                    if ((string)dataGridView1[1, RowNum].Value == "11:00-13:00")
                    {
                        mests[0].mest2 = false;
                    }
                    if ((string)dataGridView1[1, RowNum].Value == "14:00-16:00")
                    {
                        mests[0].mest3 = false;
                    }
                    if ((string)dataGridView1[1, RowNum].Value == "16:00-18:00")
                    {
                        mests[0].mest4 = false;
                    }

                    zapros = "update Grafik set mesto1 = '" + Convert.ToInt32(mests[0].mest1) + "', mesto2 = '" + Convert.ToInt32(mests[0].mest2) + "',    mesto3 = '" + Convert.ToInt32(mests[0].mest3) + "',    mesto4 = '" + Convert.ToInt32(mests[0].mest4) + "' where(select Master_ID from Master where Familia = '" + (string)dataGridView1[4, RowNum].Value + "') = Master_ID and _date = '" + dataGridView1[2, RowNum].Value + "'";
                    cmd    = new SqlCommand(zapros, global.conn);
                    cmd.ExecuteNonQuery();
                    global.conn.Close();
                    zapros = "";
                    NewZakaz frm = new NewZakaz();
                    frm.textBox1.Text = (string)dataGridView1[0, RowNum].Value;
                    dataGridView1.Rows.RemoveAt(dataGridView1.CurrentRow.Index);
                    MessageBox.Show("Заказ отменен, создайте новый заказ!");


                    this.Hide();
                    frm.Show();
                }
                else
                {
                    MessageBox.Show("Заказ выполнен и не может быть изменен!");
                }
            }
        }