private void button3_Click(object sender, EventArgs e) { if (fam != "") { Form5.idClient = idClient; Form5.famClient = fam; string skidka; if (label16.Text.Length == 3) { skidka = label16.Text[0] + label16.Text[1].ToString(); } else { skidka = label16.Text[0].ToString(); } Form5.skidka = int.Parse(skidka); if (System.Windows.Forms.Application.OpenForms["Form5"] != null) { (System.Windows.Forms.Application.OpenForms["Form5"] as Form5).OpenBascket(); } } else { Messege mes = new Messege(Messege.messegeType.error, $"Вы не выделили покупателя"); mes.ShowDialog(); } }
private void button2_Click_1(object sender, EventArgs e) { if (textBox2.Text == "") { textBox2.Text = " "; } bool filledTextBox = panel1.Controls.OfType <TextBox>().All(textBox => textBox.Text != ""); bool filledComboBox = panel1.Controls.OfType <ComboBox>().All(comboBox => comboBox.Text != ""); if (filledTextBox && filledComboBox) { if (id != -1) { Update(); Messege mesc = new Messege(Messege.messegeType.done, $"Клиент успешно изменён!"); mesc.ShowDialog(); } else { insert(); Messege mes = new Messege(Messege.messegeType.done, $"Клиент успешно добавлен!"); mes.ShowDialog(); } Close(); } else { timer1.Enabled = true; Messege mes = new Messege(Messege.messegeType.error, $"Не все поля заполнены"); mes.ShowDialog(); } }
private void button5_Click(object sender, EventArgs e) { if (GetIdPhone() != -1) { if (System.Windows.Forms.Application.OpenForms["Form5"] != null) { //myList.Contains(myString) if (!(System.Windows.Forms.Application.OpenForms["Form5"] as Form5).idPhonesForCompere.Contains(GetIdPhone())) { (System.Windows.Forms.Application.OpenForms["Form5"] as Form5).idPhonesForCompere.Add(GetIdPhone()); button5.Enabled = false; } else { Messege mes = new Messege(Messege.messegeType.error, $" !"); mes.ShowDialog(); } } } else { Messege mes = new Messege(Messege.messegeType.error, $"Вы не выбрали телефон который хотите изменить!"); mes.ShowDialog(); } }
private void button5_Click(object sender, EventArgs e) { bool isFind = false; bool isHea = false; for (int i = 0; i < Numers.Count; i++) { if (Numers[i].Enabled && Numers[i].Value != 0) { int id = idFleshMems[i][ColorComboBoxes[i].SelectedIndex]; int fleshMem = int.Parse(Buttons[i].Text.Replace(" ГБ", "")); int count = int.Parse(Numers[i].Value.ToString()); int MaxCount = int.Parse(LabelsCount[i].Text); double prise = double.Parse(LabelsPrise[i].Text); string model = label2.Text; string color = ColorComboBoxes[i].Text; for (int j = 0; j < Form5.bascet.Count; j++) { if (Form5.bascet[j].fleshMem == fleshMem && Form5.bascet[j].color == color && Form5.bascet[j].idPhone == idPhone) { Form5.bascet[j].count += count; isHea = true; } } if (!isHea) { Form5.bascet.Add(new Bascet(id, count, prise, model, pictureBox1.Image, color, fleshMem, MaxCount, idPhone)); } isFind = true; string query = $"SELECT idColor FROM Colors WHERE color = '{color}'"; OleDbCommand command = new OleDbCommand(query, Form5.myConnection); string idColor = command.ExecuteScalar().ToString(); query = $"SELECT idFleshMam FROM FleshMem WHERE FleshMamari = {fleshMem}"; command = new OleDbCommand(query, Form5.myConnection); string idFlesh = command.ExecuteScalar().ToString(); query = $"UPDATE Stock SET colech = {int.Parse(LabelsCount[i].Text) - Numers[i].Value} WHERE idPhone = {idPhone} AND idFleshMem = {idFlesh} AND idColor = {idColor}"; command = new OleDbCommand(query, Form5.myConnection); command.ExecuteNonQuery(); } } if (isFind) { if (System.Windows.Forms.Application.OpenForms["Form5"] != null) { (System.Windows.Forms.Application.OpenForms["Form5"] as Form5).OpenBascket(); } } else { Messege mes = new Messege(Messege.messegeType.error, $"Вы не выбрали размер Флэш-памяти или не указали её количество"); mes.ShowDialog(); } }
private void button1_Click(object sender, EventArgs e) { if (Form5.famClient != "") { int idOdrer = DBmanager.GetId("Orders", "idOrder"); string data = DateTime.Now.ToString(); string query = $"INSERT INTO Orders (idClient,data,idOrder,skidka) VALUES ({Form5.idClient},'{DateTime.Now}',{idOdrer},{Form5.skidka})"; OleDbCommand command = new OleDbCommand(query, Form5.myConnection); command.ExecuteNonQuery(); for (int i = 0; i < Form5.bascet.Count; i++) { query = $"SELECT idColor FROM Colors WHERE color = '{Form5.bascet[i].color}'"; command = new OleDbCommand(query, Form5.myConnection); int idColor = int.Parse(command.ExecuteScalar().ToString()); query = $"SELECT idStock FROM Stock WHERE idPhone = {Form5.bascet[i].idPhone} AND idFleshMem = {Form5.bascet[i].idFleshMem} AND idColor = {idColor}"; command = new OleDbCommand(query, Form5.myConnection); int idStock = int.Parse(command.ExecuteScalar().ToString()); //int idStock = query = $"INSERT INTO Histori (idOrder,idStock,colech,price) VALUES ({idOdrer},{idStock},{Form5.bascet[i].count},{summa})"; command = new OleDbCommand(query, Form5.myConnection); command.ExecuteNonQuery(); } if (checkBox1.Checked) { Export(idOdrer, data); Messege mes = new Messege(Messege.messegeType.done, "Готово"); mes.ShowDialog(); DeleteBas(); if (System.Windows.Forms.Application.OpenForms["Form5"] != null) { (System.Windows.Forms.Application.OpenForms["Form5"] as Form5).OpenPhones(); } Form5.famClient = null; Form5.skidka = 0; } else { DeleteBas(); if (System.Windows.Forms.Application.OpenForms["Form5"] != null) { (System.Windows.Forms.Application.OpenForms["Form5"] as Form5).OpenPhones(); } Form5.famClient = null; Form5.skidka = 0; Messege mes = new Messege(Messege.messegeType.done, "Готово"); mes.ShowDialog(); } } else { Messege mes = new Messege(Messege.messegeType.error, "Для оформления заказа необходимо выбрать покупателя"); mes.ShowDialog(); } }
private void button4_Click(object sender, EventArgs e) { if (bascet.Count > 0) { OpenBascket(); } else { Messege mes = new Messege(Messege.messegeType.error, $"Ваша корзина пуста. Добавте телефон чтобы оформить заказ"); mes.ShowDialog(); } }
private void button8_Click_1(object sender, EventArgs e) { if (idPhonesForCompere.Count != 0) { OpenCompere(); } else { Messege mes = new Messege(Messege.messegeType.error, $"Сравнивать нечего. Добавте телефоны чтобы начать сравнение"); mes.ShowDialog(); } }
private void button3_Click(object sender, EventArgs e) { if (GetIdPhone() != -1) { if (System.Windows.Forms.Application.OpenForms["Form5"] != null) { (System.Windows.Forms.Application.OpenForms["Form5"] as Form5).OpenAbaut(GetIdPhone()); } } else { Messege mes = new Messege(Messege.messegeType.error, $"Вы не выбрали телефон!"); mes.ShowDialog(); } }
private void button4_Click(object sender, EventArgs e) { if (GetIdPhone() != -1) { if (System.Windows.Forms.Application.OpenForms["Form5"] != null) { //(System.Windows.Forms.Application.OpenForms["Form5"] as Form5).OpenCheng(); (System.Windows.Forms.Application.OpenForms["Form5"] as Form5).OpenCheng(GetIdPhone()); } } else { Messege mes = new Messege(Messege.messegeType.error, $"Вы не выбрали телефон который хотите изменить!"); mes.ShowDialog(); } }
private void button3_Click(object sender, EventArgs e) { Order order = orders.Find(item => item.count > 0); if (order != null) { Insert(); Messege mes = new Messege(Messege.messegeType.done, "Готово"); mes.ShowDialog(); Close(); } else { Messege mes = new Messege(Messege.messegeType.error, "Для оформления заказа необходимо заказать хотя бы один телефонт."); mes.ShowDialog(); } }
private void button2_Click(object sender, EventArgs e) { Messege mes = new Messege(Messege.messegeType.warning, $"Вы действительно хотите удалить заказ №{activOrder}?"); mes.ShowDialog(); if (mes.isAssept) { //string query = $"DELETE FROM Phons WHERE idPhone={GetIdPhone()}"; string query = $"DELETE FROM OrderData WHERE idOrderBuy = {activOrder}"; OleDbCommand command = new OleDbCommand(query, Form5.myConnection); command.ExecuteNonQuery(); LoadData(); } }
private void button2_Click(object sender, EventArgs e) { if (!CheckErrors()) { UserControl3.MemComboBoxes = MemComboBoxes; UserControl3.ColorComboBoxes = ColorComboBoxes; UserControl3.NumericUpDowns = NumericUpDowns; UserControl3.TextBoxes = TextBoxes; Close(); } else { Messege mes = new Messege(Messege.messegeType.error, $"Не все поля заполнены"); mes.ShowDialog(); } }
private void button3_Click(object sender, EventArgs e) { string query = $"SELECT COUNT(b.idPhone) FROM Phons b WHERE b.idProc = {idCor}"; OleDbCommand command = new OleDbCommand(query, Form5.myConnection); int count = int.Parse(command.ExecuteScalar().ToString()); int j = 0; if (idPhone != -1) { j = 1; } if (count == j) { Messege mes = new Messege(Messege.messegeType.warning, $"Вы действительно хотите удалить процессор {textBox12.Text}?"); mes.ShowDialog(); if (mes.isAssept) { if (idPhone != -1) { query = $"UPDATE Phons SET idProc = {1} WHERE idPhone = {idPhone}"; command = new OleDbCommand(query, Form5.myConnection); command.ExecuteNonQuery(); } query = $"DELETE FROM Cors WHERE idProc = {idCor}"; command = new OleDbCommand(query, Form5.myConnection); command.ExecuteNonQuery(); isDalate = true; Close(); } } else { Messege mes = new Messege(Messege.messegeType.error, $"Данный процессор задействован в другом телефоне!"); mes.ShowDialog(); } }
private void button2_Click(object sender, EventArgs e) { if (fam != "") { Messege mes = new Messege(Messege.messegeType.warning, $"Вы действительно хотите удалить клиента? Вся информация связанная с ним будет удалена!"); mes.ShowDialog(); if (mes.isAssept) { string query = $"DELETE FROM Clients WHERE idClient = {idClient}"; OleDbCommand command = new OleDbCommand(query, Form5.myConnection); command.ExecuteNonQuery(); LoadData(); } } else { Messege mes = new Messege(Messege.messegeType.error, $"Вы не выделили покупателя которого хотите удалить"); mes.ShowDialog(); } }
private void button2_Click(object sender, EventArgs e) { bool filledTextBox = panel1.Controls.OfType <TextBox>().All(textBox => textBox.Text != ""); bool filledComboBox = panel1.Controls.OfType <ComboBox>().All(comboBox => comboBox.Text != ""); if (filledTextBox && filledComboBox) { Messege mes = new Messege(Messege.messegeType.warning, $"Вы действительно хотите изменить процессор {textBox12.Text}?"); mes.ShowDialog(); if (mes.isAssept) { UpdateForm(); Close(); } } else { timer1.Enabled = true; Messege mes = new Messege(Messege.messegeType.error, $"Не все поля заполнены"); mes.ShowDialog(); } }
private void button2_Click(object sender, EventArgs e) { if (id != -1) { Messege mes = new Messege(Messege.messegeType.warning, $"Вы хотите удалинть из корзины {Form5.bascet[id - 1].model} ?"); mes.ShowDialog(); if (mes.isAssept) { //string query = $"UPDATE Colors SET colech = {Form5.bascet[id - 1].Maxcount} WHERE " + //$"idFleshMem = {Form5.bascet[id - 1].idFleshMem} AND color = '{Form5.bascet[id - 1].color}'"; string query = $"SELECT idColor FROM Colors WHERE color = '{Form5.bascet[id - 1].color}'"; OleDbCommand command = new OleDbCommand(query, Form5.myConnection); string idColor = command.ExecuteScalar().ToString(); query = $"UPDATE Stock SET colech = {Form5.bascet[id - 1].Maxcount} WHERE idPhone = {Form5.bascet[id - 1].idPhone} AND idFleshMem = {Form5.bascet[id - 1].idFleshMem} AND idColor = {idColor}"; command = new OleDbCommand(query, Form5.myConnection); command.ExecuteNonQuery(); Form5.bascet.RemoveAt(id - 1); if (Form5.bascet.Count == 0) { if (System.Windows.Forms.Application.OpenForms["Form5"] != null) { (System.Windows.Forms.Application.OpenForms["Form5"] as Form5).OpenPhones(); } } LoadData(Form5.bascet); id = -1; } } else { Messege mes = new Messege(Messege.messegeType.error, $"Вы не выбрали телефон который хотите удалить из корзины!"); mes.ShowDialog(); } }
private void button2_Click(object sender, EventArgs e) { if (GetIdPhone() != -1) { Messege mes = new Messege(Messege.messegeType.warning, $"Вы действительно хотите удалить {ActivModel}?"); mes.ShowDialog(); if (mes.isAssept) { //string query = $"DELETE FROM Phons WHERE idPhone={GetIdPhone()}"; string query = $"UPDATE Phons SET сharged = TRUE WHERE idPhone={GetIdPhone()}"; OleDbCommand command = new OleDbCommand(query, Form5.myConnection); command.ExecuteNonQuery(); LoadData(); } } else { Messege mes = new Messege(Messege.messegeType.error, $"Вы не выбрали телефон который хотите удалить!"); mes.ShowDialog(); } }
private void button5_Click(object sender, EventArgs e) { string query; OleDbCommand command; //if (Operation.update == oper) //{ // query = $"DELETE FROM Stock WHERE idPhone={idPhone}"; // command = new OleDbCommand(query, Form5.myConnection); // command.ExecuteNonQuery(); //} bool filledTextBox = this.Controls.OfType <TextBox>().All(textBox => textBox.Text != ""); bool filledComboBox = this.Controls.OfType <ComboBox>().All(comboBox => comboBox.Text != ""); //Task.Run(() => { while (true) CheckErrors(); }); //DestroiAllErPoints(); if (!filledComboBox || !filledTextBox) { Messege mes = new Messege(Messege.messegeType.error, $"Не все поля заполнены"); mes.ShowDialog(); timer1.Enabled = true; } else if (!CheckModel("Phons", textBox2.Text) && oper == Operation.insert) { CreatErrorPoint(textBox2); error = true; Messege mes = new Messege(Messege.messegeType.error, $"Телефон с моделью {textBox2.Text} уже зарегистрирован"); mes.ShowDialog(); } else { data = comboBox14.Text; model = textBox2.Text; os = comboBox1.Text; //scrinSize = double.Parse(textBox8.Text); razScrin = comboBox16.Text; ram = int.Parse(comboBox4.Text); //mamori = int.Parse(comboBox5.Text); fSim = comboBox6.Text; cSim = int.Parse(comboBox7.Text); batari = int.Parse(textBox19.Text); compani = comboBox13.Text; if (comboBox2.Text == "Новый") { proc = textBox12.Text; speed = int.Parse(textBox11.Text); countCors = int.Parse(comboBox8.Text); razProс = int.Parse(comboBox9.Text); sGPU = int.Parse(textBox16.Text); GAccelModl = comboBox15.Text; idCors = DBmanager.GetId("Cors", "idProc"); query = $"INSERT INTO Cors (idProc,model,speed,nCors,razProc,sGPU,GAccelModl) VALUES ({idCors},'{proc}',{speed},{countCors},{razProс},{sGPU},'{GAccelModl}')"; command = new OleDbCommand(query, Form5.myConnection); command.ExecuteNonQuery(); } if (oper == Operation.insert) { idPhone = DBmanager.GetId("Phons", "idPhone"); } idProcInPhone = idCors; hDis = comboBox10.Text; mDis = comboBox11.Text.Replace(",", "."); List <int> idFlethMam = new List <int>(); texScren = comboBox12.Text; soatnoshStor = comboBox3.Text; //inStock =int.Parse(textBox4.Text); image = pictureBox1.Image; if (oper == Operation.insert) { query = $"INSERT INTO Phons (idPhone, model, data, os, ram, sizeSc, fsim,Csim, hDesign, mDesign, scrin, sizeBat," + $" componi, idProc, texScren, soatnoshStor, cam) VALUES ({idPhone}, '{model}', {data}, '{os}', {ram}, {textBox8.Text.Replace(",",".")}," + $" '{fSim}', {cSim}, '{hDis}', '{mDis}', '{razScrin}', {batari}, '{compani}', {idCors}, '{texScren}', '{soatnoshStor}', {textBox1.Text})"; } else { query = $"UPDATE Phons SET idPhone={idPhone}, model='{model}', data={data}, os='{os}', ram={ram}, sizeSc={textBox8.Text.Replace(",", ".")}, fsim='{fSim}',Csim={cSim}, hDesign='{hDis}', mDesign='{mDis}', scrin='{razScrin}', sizeBat={batari}," + $" componi='{compani}', idProc={idCors}, texScren='{texScren}', soatnoshStor='{soatnoshStor}', cam={textBox1.Text} WHERE idPhone={idPhone}"; } //else // query = $"UPDATE Phons SET idPhone={idPhone}, model={model}, data={data}, os={os}, ram={ram}, sizeSc={textBox8.Text}, fsim={fSim},Csim={cSim}, hDesign={hDis}, mDesign={mDis}, scrin={razScrin}, sizeBat={batari}, componi={compani}, idProc={idCors}, texScren={texScren}, soatnoshStor={soatnoshStor}, minPrise={strMinPrise}"; command = new OleDbCommand(query, Form5.myConnection); command.ExecuteNonQuery(); DBmanager.SetImage(image, idPhone); int idFleshMam = 0; int idColor = 0; List <int> idStocs = new List <int>(); for (int i = 0; i < MemComboBoxes.Count; i++) { while (true) { query = $"SELECT idFleshMam FROM FleshMem WHERE FleshMamari = {MemComboBoxes[i].Text}"; command = new OleDbCommand(query, Form5.myConnection); try { idFleshMam = int.Parse(command.ExecuteScalar().ToString()); break; } catch (Exception) { query = $"INSERT INTO FleshMem (FleshMamari) VALUES ({MemComboBoxes[i].Text})"; command = new OleDbCommand(query, Form5.myConnection); command.ExecuteNonQuery(); } } while (true) { query = $"SELECT idColor FROM Colors WHERE color = '{ColorComboBoxes[i].Text}'"; command = new OleDbCommand(query, Form5.myConnection); try { idColor = int.Parse(command.ExecuteScalar().ToString()); break; } catch (Exception) { //query = $"INSERT INTO FleshMem (FleshMamari) VALUES ({MemComboBoxes[i].Text})"; query = $"INSERT INTO Colors (color) VALUES ('{ColorComboBoxes[i].Text}')"; command = new OleDbCommand(query, Form5.myConnection); command.ExecuteNonQuery(); } } if (oper == Operation.insert) { int idStoock = DBmanager.GetId("Stock", "idStock"); query = $"INSERT INTO Stock (idStock,idPhone,idFleshMem,idColor,colech,prise) VALUES ({idStoock},{idPhone},{idFleshMam},{idColor},{NumericUpDowns[i].Value},{TextBoxes[i].Text.Replace(",",".")})"; command = new OleDbCommand(query, Form5.myConnection); command.ExecuteNonQuery(); } else { try { query = $"UPDATE Stock SET idPhone = {idPhone},idFleshMem = {idFleshMam},idColor = {idColor},colech = {NumericUpDowns[i].Value}, prise = {TextBoxes[i].Text.Replace(",", ".")} WHERE idStock = {Form6.idStocks[i]}"; command = new OleDbCommand(query, Form5.myConnection); command.ExecuteNonQuery(); } catch (Exception) { int idStock = -1; idStock = DBmanager.GetId("Stock", "idStock"); query = $"INSERT INTO Stock (idStock,idPhone,idFleshMem,idColor,colech,prise) VALUES ({idStock},{idPhone},{idFleshMam},{idColor},{NumericUpDowns[i].Value},{TextBoxes[i].Text.Replace(",", ".")})"; command = new OleDbCommand(query, Form5.myConnection); command.ExecuteNonQuery(); //idStocs.Add(idStock); } } for (int t = 0; t < Form6.idDeleteStocks.Count; t++) { query = $"UPDATE Stock SET chatged = TRUE WHERE idStock = {Form6.idDeleteStocks[t]}"; command = new OleDbCommand(query, Form5.myConnection); command.ExecuteNonQuery(); } } if (oper == Operation.update) { Messege mes = new Messege(Messege.messegeType.done, $"Характеристики {textBox2.Text} успешно изменены."); mes.ShowDialog(); if (System.Windows.Forms.Application.OpenForms["Form5"] != null) { (System.Windows.Forms.Application.OpenForms["Form5"] as Form5).OpenPhones(); } } else { Messege mes = new Messege(Messege.messegeType.done, $"Телефон {textBox2.Text} успешно добавлен."); mes.ShowDialog(); if (System.Windows.Forms.Application.OpenForms["Form5"] != null) { (System.Windows.Forms.Application.OpenForms["Form5"] as Form5).OpenPhones(); } } } }