Beispiel #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string name = tabControl1.SelectedTab.Text;
            connection con = new connection();
            switch (name)
            {
                case "Сотрудник":
                    con.update("Сотрудник", "[Фамилия] = '" + F.Text
                        + "', [Имя] ='" + I.Text + "', [Отчество] ='" + O.Text
                        + "', [Дата рождения] ='" + BirthDate.Text + "', [Адрес] ='" + Adress.Text
                        + "', [Телефон] ='" + PhoneStaff.Text + "', [E-mail] ='" + emailstaff.Text
                         + "', [Образование] ='" + Education.Text + "', [Должность] ='" + Occupation.Text + "'", "[ID сотрудника] = " + ID_s);
                    break;
                case "Покупатели":
                    con.update("Покупатели", "[Фамилия] = '" + FP.Text
                        + "', [Имя] ='" + IP.Text + "', [Отчество] ='" + OP.Text
                        + "', [Мобильный телефон] ='" + PhoneP.Text + "', [Город] ='" + CityP.Text
                        + "', [Адрес] ='" + AdressP.Text + "'", "[ID покупателя] = " + ID_p);
                    break;
                case "Товары":
                    con.update("Товары", "[Наименование] = '" + ChtoG.Text
                        + "', [Название] ='" + NameG.Text + "', [Описание] ='" + CommentG.Text
                        + "', [Цена] =" + PriceG.Text  + "", "[ID Товара] = " + ID_g);
                    break;
                case "Услуги":

                    con.update("Услуги", "[Наименование услуги] = '" + NameS.Text
                        +  "', [Описание] ='" + CommentS.Text
                        + "', [Цена] =" + PriceS.Text + "", "[ID Услуги] = " + ID_u);
                    break;
                case "Заказы":
                    string IDP, IDS;
                    IDS = con.select1String("[ID сотрудника]", "Сотрудник", "Фамилия LIKE '" + cbS.Text + "'");
                    IDP = con.select1String("[ID покупателя]", "Покупатели", "Фамилия LIKE '" + cbP.Text + "'");
                    con.update("Заказы", "[Дата заказа] = '" + DateN.Text
                        + "', [id Сотрудника] =" + IDS + ", [id Покупателя] =" + IDP
                        + ", [Отметка об исполнении] =" + CheckBox.Text + ", [Предоплата] =" + Preorder.Text+ "", "[ID Заказа] = " + ID_N);
                    break;

                case "Заказанные товары":
                    string[] wordsG = cbG.Text.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

                    con.update("[Заказанные товары]", "[ID заказа] = " + cbIDN.Text
                        + ", [ID товара] =" + wordsG[0] + ", [Количество] =" + CountPG.Text
                        + ", [Цена] =" + PricePG.Text + ", [Общая стоимость] =" + TotalPricsPG.Text + "", "[ID ЗТ] = " + ID_NG);
                    break;
                case "Заказанные услуги":
                    string[] wordsU = cbU.Text.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                    con.update("[Заказанные услуги]", "[ID заказа] = " + cbIDNU.Text
                       + ", [ID услуги] =" + wordsU[0] + ", [Количество] =" + CountNS.Text
                       + ", [Цена] =" + PriceNS.Text + ", [Общая стоимость] =" + TotalPriceNS.Text + "", "[ID ЗУ] = " + ID_NU);
                    break;
            }

            con.Close();
            ClearAll();
            UpdateAll();
        }
Beispiel #2
0
        private void buttonEDIT_Click(object sender, EventArgs e)
        {
            btnSave.Visible = true;
            buttonADD.Visible = false;
            buttonEDIT.Visible = false;
            buttonDELETE.Visible = false;
            string name = tabControl1.SelectedTab.Text;
            connection con = new connection();
            SqlDataReader myReader;
            switch (name)
            {
                case "Сотрудник":
                    ID_s = (int) dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[0].Value;
                    myReader = con.select("*", "Сотрудник", "[ID сотрудника] = " + dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[0].Value);
                    while (myReader.Read())
                    {
                        F.Text = myReader[1].ToString();
                        I.Text = myReader[2].ToString();
                        O.Text = myReader[3].ToString();
                        BirthDate.Text = myReader[4].ToString();
                        Adress.Text = myReader[5].ToString();
                        PhoneStaff.Text = myReader[6].ToString();
                        emailstaff.Text = myReader[7].ToString();
                        Education.Text = myReader[8].ToString();
                        Occupation.Text = myReader[9].ToString();
                    }
                    myReader.Close();
                    break;
                case "Покупатели":
                    ID_p = (int)dataGridView2.Rows[dataGridView2.CurrentRow.Index].Cells[0].Value;
                    myReader = con.select("*", "Покупатели", "[ID покупателя] = " + dataGridView2.Rows[dataGridView2.CurrentRow.Index].Cells[0].Value);
                    while (myReader.Read())
                    {
                        FP.Text = myReader[1].ToString();
                        IP.Text = myReader[2].ToString();
                        OP.Text = myReader[3].ToString();
                        PhoneP.Text = myReader[4].ToString();
                        CityP.Text = myReader[5].ToString();
                        AdressP.Text = myReader[6].ToString();
                    }
                    myReader.Close();
                    break;
                case "Товары":
                    ID_g = (int)dataGridView3.Rows[dataGridView3.CurrentRow.Index].Cells[0].Value;
                    myReader = con.select("*", "Товары", "[ID Товара] = " + dataGridView3.Rows[dataGridView3.CurrentRow.Index].Cells[0].Value);
                    while (myReader.Read())
                    {
                        ChtoG.Text = myReader[1].ToString();
                        NameG.Text = myReader[2].ToString();
                        CommentG.Text = myReader[3].ToString();
                        PriceG.Text = myReader[4].ToString();
                    }
                    myReader.Close();
                    break;
                case "Услуги":
                    ID_u = (int)dataGridView4.Rows[dataGridView4.CurrentRow.Index].Cells[0].Value;
                    myReader = con.select("*", "Услуги", "[ID Услуги] = " + dataGridView4.Rows[dataGridView4.CurrentRow.Index].Cells[0].Value);
                    while (myReader.Read())
                    {
                        NameS.Text = myReader[1].ToString();
                        CommentS.Text = myReader[2].ToString();
                        PriceS.Text = myReader[3].ToString();
                    }
                    myReader.Close();
                    break;
                case "Заказы":
                    ID_N = (int)dataGridView5.Rows[dataGridView5.CurrentRow.Index].Cells[0].Value;
                    string IDP = "1", IDS="1";
                    myReader = con.select("*", "Заказы", "[ID Заказа] = " + dataGridView5.Rows[dataGridView5.CurrentRow.Index].Cells[0].Value);
                    while (myReader.Read())
                    {
                        DateN.Text = myReader[1].ToString();
                        IDS = myReader[2].ToString();
                        IDP = myReader[3].ToString();
                        CheckBox.Text = myReader[4].ToString();
                        Preorder.Text = myReader[5].ToString();
                    }
                    cbS.Text=dataGridView1.Rows[Convert.ToInt32(IDS) - 1].Cells[1].Value.ToString();
                    cbP.Text=dataGridView2.Rows[Convert.ToInt32(IDP) - 1].Cells[1].Value.ToString();
                    myReader.Close();
                    break;

                case "Заказанные товары":
                    ID_NG = (int)dataGridView6.Rows[dataGridView6.CurrentRow.Index].Cells[0].Value;
                    string IDG="1";
                    myReader = con.select("*", "[Заказанные товары]", "[ID ЗТ] = " + ID_NG);
                    while (myReader.Read())
                    {
                        cbIDN.Text = myReader[1].ToString();
                        IDG = myReader[2].ToString();
                        CountPG.Text = myReader[3].ToString();
                        PricePG.Text = myReader[4].ToString();
                        TotalPricsPG.Text = myReader[5].ToString();
                    }
                    cbG.Text = dataGridView3.Rows[Convert.ToInt32(IDG) - 1].Cells[0].Value.ToString() + " " + dataGridView3.Rows[Convert.ToInt32(IDG) - 1].Cells[1].Value.ToString() + " " + dataGridView3.Rows[Convert.ToInt32(IDG) - 1].Cells[2].Value.ToString();
                    myReader.Close();
                    break;
                case "Заказанные услуги":
                    ID_NU = (int)dataGridView6.Rows[dataGridView7.CurrentRow.Index].Cells[0].Value;
                    string IDU = "1";
                    myReader = con.select("*", "[Заказанные услуги]", "[ID ЗУ] = " +ID_NU);
                    while (myReader.Read())
                    {
                        cbIDNU.Text = myReader[1].ToString();
                        IDU = myReader[2].ToString();
                        CountNS.Text = myReader[3].ToString();
                        PriceNS.Text = myReader[4].ToString();
                        TotalPriceNS.Text = myReader[5].ToString();
                    }
                    cbU.Text = dataGridView4.Rows[Convert.ToInt32(IDU) - 1].Cells[0].Value.ToString() + " " + dataGridView4.Rows[Convert.ToInt32(IDU) - 1].Cells[1].Value.ToString() + " " + dataGridView4.Rows[Convert.ToInt32(IDU) - 1].Cells[2].Value.ToString();
                    myReader.Close();
                    break;
            }

            con.Close();
        }
Beispiel #3
0
        private void buttonDELETE_Click(object sender, EventArgs e)
        {
            string pole="";
            string id_number="";
            string name = tabControl1.SelectedTab.Text;

            switch (name)
            {
                case "Сотрудник":
                    pole = "ID сотрудника";
                    id_number= dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[0].Value.ToString();
                    break;
                case "Покупатели":
                    pole = "ID покупателя";
                    id_number = dataGridView2.Rows[dataGridView2.CurrentRow.Index].Cells[0].Value.ToString();

                    break;
                case "Товары":
                    pole = "ID товара";
                    id_number = dataGridView3.Rows[dataGridView3.CurrentRow.Index].Cells[0].Value.ToString();
                    break;
                case "Услуги":
                    pole = "ID услуги";
                    id_number = dataGridView4.Rows[dataGridView4.CurrentRow.Index].Cells[0].Value.ToString();
                    break;
                case "Заказы":
                    pole = "ID заказа";
                    id_number = dataGridView5.Rows[dataGridView5.CurrentRow.Index].Cells[0].Value.ToString();
                    break;
                case "Заказанные товары":
                    pole = "ID ЗТ";
                    id_number = dataGridView6.Rows[dataGridView6.CurrentRow.Index].Cells[0].Value.ToString();
                    break;
                case "Заказанные услуги":
                    pole = "ID ЗУ";
                    id_number = dataGridView7.Rows[dataGridView7.CurrentRow.Index].Cells[0].Value.ToString();
                    break;
            }
            connection conDel = new connection();
            conDel.delete("["+name+"]", "["+pole+"]", id_number);
            UpdateAll();
        }