Ejemplo n.º 1
0
        //после выбора мастера отображается услуга и время
        private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
        {
            comboBox1.Items.Clear();
            comboBox4.Items.Clear();
            mests.Clear();
            string zapros = "";

            global.conn.Open();
            zapros = "select mesto1,mesto2,mesto3,mesto4 from Grafik, Master where Grafik.Master_ID = Master.Master_ID and Grafik._date = '" + comboBox2.Text + "' and Familia = '" + comboBox3.Text + "'";
            SqlCommand    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);
            }
            for (int i = 0; i < mests.Count; i++)
            {
                if (!mests[i].mest1)
                {
                    comboBox1.Items.Add("9:00-11:00");
                }
                if (!mests[i].mest2)
                {
                    comboBox1.Items.Add("11:00-13:00");
                }
                if (!mests[i].mest3)
                {
                    comboBox1.Items.Add("14:00-16:00");
                }
                if (!mests[i].mest4)
                {
                    comboBox1.Items.Add("16:00-18:00");
                }
            }
            reader.Close();
            zapros = "select Nazvanie from Master, Master_Spec, Specializaciya where Master_Spec.Master_ID = Master.Master_ID and Master_Spec.Specializaciya_ID = Specializaciya.Specializaciya_ID and Familia = '" + comboBox3.Text + "'";
            cmd    = new SqlCommand(zapros, global.conn);
            reader = cmd.ExecuteReader();

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

            while (reader.Read())
            {
                usl.Add((string)reader[0]);
            }
            for (int i = 0; i < usl.Count; i++)
            {
                comboBox4.Items.Add(usl[i]);
            }
            reader.Close();
            global.conn.Close();
        }
Ejemplo n.º 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("Заказ выполнен и не может быть изменен!");
                }
            }
        }