private void LoadDataUpdate() { ImageList imageList = new ImageList(); imageList.ImageSize = new Size(80, 100); listView1.Items.Clear(); string query = $"SELECT a.model, d.color, f.FleshMamari,a.idPhone,c.colech,a.componi,c.idStock,i.colech FROM Phons a ,Stock c , Colors d, FleshMem f,OrderBuy i WHERE" + ////(SELECT a.FleshMamari FROM FleshMem a1,Stock b1 WHERE b1.idFleshMem = a1.idFleshMam) $" a.сharged = FALSE AND c.idPhone = a.idPhone AND c.idColor = d.idColor AND f.idFleshMam = c.idFleshMem AND c.idStock = i.idStock AND i.idOrderBuy = {id}"; //AND a.idPhone=b.idPhone OleDbCommand command = new OleDbCommand(query, Form5.myConnection); OleDbDataReader reader = command.ExecuteReader(); int i = 0; idStock.Clear(); List <int> coleches = new List <int>(); while (reader.Read()) { idStock.Add(int.Parse(reader[6].ToString())); ListViewItem listViewItem; Order order = orders.Find(item => item.idStoock == int.Parse(reader[6].ToString())); if (order == null) { orders.Add(new Order(int.Parse(reader[6].ToString()), reader[5].ToString() + " " + reader[0].ToString() + " " + reader[2].ToString(), reader[1].ToString())); orders[orders.Count - 1].count = int.Parse(reader[7].ToString()); listViewItem = new ListViewItem(new string[] { $"{i + 1}", reader[5].ToString() + " " + reader[0].ToString() + " " + reader[2].ToString() + " ГБ", reader[1].ToString(), reader[4].ToString(), $"{orders[orders.Count - 1].count}" }); System.Drawing.Color color = System.Drawing.Color.FromArgb(29, 31, 35); listViewItem.UseItemStyleForSubItems = false; listViewItem.SubItems[4].BackColor = color; } else { listViewItem = new ListViewItem(new string[] { $"{i + 1}", reader[5].ToString() + " " + reader[0].ToString() + " " + reader[2].ToString() + " ГБ", reader[1].ToString(), reader[4].ToString(), order.count.ToString() }); if (order.count != 0) { System.Drawing.Color color = System.Drawing.Color.FromArgb(54, 54, 54); listViewItem.UseItemStyleForSubItems = false; listViewItem.SubItems[4].BackColor = color; } } coleches.Add(int.Parse(reader[4].ToString())); listView1.Items.Add(listViewItem); imageList.Images.Add(DBmanager.GetImage(int.Parse(reader[3].ToString()))); listView1.SmallImageList = imageList; listViewItem.ImageIndex = i; i++; } max = coleches.Max(); numericUpDown1.Value = max; }
void LoadInfo(int id) { comboBox2.SelectedIndex = 0; string query = $"SELECT model, data, os, ram, sizeSc, fsim,Csim, hDesign, mDesign, scrin, sizeBat," + $" componi, idProc, texScren, soatnoshStor, cam FROM Phons WHERE idPhone={id}"; OleDbCommand command = new OleDbCommand(query, Form5.myConnection); OleDbDataReader reader = command.ExecuteReader(); reader.Read(); textBox2.Text = reader[0].ToString(); //Модель comboBox14.SelectedIndex = CombSetValue(comboBox14, reader[1].ToString()); //Data comboBox1.SelectedIndex = CombSetValue(comboBox1, reader[2].ToString()); //Os comboBox4.SelectedIndex = CombSetValue(comboBox4, reader[3].ToString()); //Ram textBox8.Text = reader[4].ToString(); comboBox6.SelectedIndex = CombSetValue(comboBox6, reader[5].ToString()); //Fsim comboBox7.SelectedIndex = CombSetValue(comboBox7, reader[6].ToString()); //Fsim comboBox10.SelectedIndex = CombSetValue(comboBox10, reader[7].ToString()); //Hdis comboBox11.SelectedIndex = CombSetValue(comboBox11, reader[8].ToString().Replace(".", ",")); //mDis //textBox3.Text = reader[9].ToString();//DrazScrin comboBox16.Text = reader[9].ToString(); //DrazScrin textBox19.Text = reader[10].ToString(); //batari //comboBox13.SelectedIndex = CombSetValue(comboBox13, reader[11].ToString());//compani comboBox13.Text = reader[11].ToString(); //compani idProcInPhone = int.Parse(reader[12].ToString()); //idProcInPhone comboBox12.SelectedIndex = CombSetValue(comboBox12, reader[13].ToString()); //texScren comboBox3.SelectedIndex = CombSetValue(comboBox3, reader[14].ToString()); // soatnoshStor textBox1.Text = reader[15].ToString(); // Cam for (int i = 0; i < idProc.Count; i++) { if (idProc[i] == idProcInPhone) { comboBox2.SelectedIndex = i + 1; break; } } pictureBox1.Image = DBmanager.GetImage(id); pictureBox2.Image = pictureBox1.Image; textBox20.Text = "Добавлено"; textBox5.Text = "Добавлено"; label2.Text = "Изменение"; //mamori = int.Parse(comboBox5.Text); }
private void LoadData() { textBox1.Enabled = false; ImageList imageList = new ImageList(); imageList.ImageSize = new Size(80, 100); listView1.Items.Clear(); string query = $"SELECT a.model, d.color, f.FleshMamari,a.idPhone,c.colech,a.componi,c.idStock,i.colech,c.prise,c.idFleshMem,c.idColor FROM Phons a ,Stock c , Colors d, FleshMem f,OrderBuy i WHERE" + ////(SELECT a.FleshMamari FROM FleshMem a1,Stock b1 WHERE b1.idFleshMem = a1.idFleshMam) $" a.сharged = FALSE AND c.idPhone = a.idPhone AND c.idColor = d.idColor AND f.idFleshMam = c.idFleshMem AND c.idStock = i.idStock AND i.idOrderBuy = {id}"; //AND a.idPhone=b.idPhone OleDbCommand command = new OleDbCommand(query, Form5.myConnection); OleDbDataReader reader = command.ExecuteReader(); int i = 0; idPhone.Clear(); coleches.Clear(); prices.Clear(); colors.Clear(); idFlehs.Clear(); idStock.Clear(); while (reader.Read()) { idPhone.Add(int.Parse(reader[3].ToString())); idStock.Add(int.Parse(reader[6].ToString())); prices.Add(int.Parse(reader[8].ToString())); idFlehs.Add(int.Parse(reader[9].ToString())); colors.Add(reader[9].ToString()); ListViewItem listViewItem; listViewItem = new ListViewItem(new string[] { $"{i + 1}", reader[5].ToString() + " " + reader[0].ToString() + " " + reader[2].ToString() + " ГБ", reader[1].ToString(), reader[7].ToString(), $"0" }); listView1.Items.Add(listViewItem); coleches.Add(int.Parse(reader[4].ToString())); imageList.Images.Add(DBmanager.GetImage(int.Parse(reader[3].ToString()))); listView1.SmallImageList = imageList; listViewItem.ImageIndex = i; i++; } }
public void LoadData() { listView1.Items.Clear(); ImageList imageList = new ImageList(); imageList.ImageSize = new Size(120, 150); //if (query == "") query = $"SELECT a.idPhone, a.model, c.price ,d.FleshMamari , c.colech FROM Phons a,Stock b,Histori c, FleshMem d WHERE" + $" c.idOrder = {id} AND c.idStock = b.idStock AND a.idPhone = b.idPhone AND d.idFleshMam = b.idFleshMem"; OleDbCommand command = new OleDbCommand(query, Form5.myConnection); OleDbDataReader reader = command.ExecuteReader(); int i = 0; double sum = 0; while (reader.Read()) { ListViewItem listViewItem = new ListViewItem(new string[] { "", reader[1].ToString() + " " + reader[3].ToString() + " ГБ", reader[4].ToString(), reader[2].ToString() }); sum += double.Parse(reader[2].ToString()) * double.Parse(reader[4].ToString()); listView1.Items.Add(listViewItem); imageList.Images.Add(DBmanager.GetImage(int.Parse(reader[0].ToString()))); listView1.SmallImageList = imageList; listViewItem.ImageIndex = i; i++; } double result = Math.Round(sum - itogSkid, 2); double skidka = Math.Round(result / sum * 100); label5.Text = $"ИТОГО (BYN) = {sum}"; label6.Text = $"СКИДКА ({skidka}%) = {result}"; label7.Text = $"ИТОГО СО СКИДКОЙ (BYN) = {sum - result}"; reader.Close(); }
public void LoadData(List <int> id = null) { modals.Clear(); listView1.Items.Clear(); this.id = id; if (id.Count == 0) { return; } string where = $"and ( a.idPhone = {id[0]}"; for (int c = 1; c < id.Count; c++) { where += $" OR a.idPhone = {id[c]}"; } where += " )"; string query = $"SELECT model, data, os, ram, sizeSc, fsim,Csim, hDesign, mDesign, scrin, sizeBat," + $"texScren, soatnoshStor, cam, Min(b.prise) ,a.idPhone,idProc FROM Phons a,Stock b WHERE a.idPhone = b.idPhone {where} GROUP BY model, data, os, ram, sizeSc, fsim,Csim, hDesign, mDesign, scrin, sizeBat,texScren, soatnoshStor, cam ,a.idPhone,idProc"; OleDbCommand command = new OleDbCommand(query, Form5.myConnection); OleDbDataReader reader = command.ExecuteReader(); ImageList imageList = new ImageList(); imageList.ImageSize = new Size(90, 120); int i = 0; while (reader.Read()) { ListViewItem listViewItem = new ListViewItem(new string[] { "", reader[0].ToString(), reader[1].ToString(), reader[2].ToString(), reader[3].ToString(), reader[4].ToString(), reader[5].ToString(), reader[6].ToString(), reader[7].ToString(), reader[8].ToString(), reader[9].ToString(), reader[10].ToString(), reader[11].ToString(), reader[12].ToString(), reader[13].ToString(), reader[14].ToString() }); modals.Add(reader[0].ToString()); listView1.Items.Add(listViewItem); imageList.Images.Add(DBmanager.GetImage(int.Parse(reader[15].ToString()))); listView1.SmallImageList = imageList; listViewItem.ImageIndex = i; listView1.Items[i].UseItemStyleForSubItems = false; i++; } listView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); listView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); foreach (ColumnHeader item in listView1.Columns) { item.Width += 20; //item. += 20; } Color color = Color.FromArgb(54, 54, 54); //listView1.Items[1].SubItems[4].BackColor = color; int count = 0; int indexMax = 0; int[] massColons = { 4, 5, 7, 11, 14, 15 }; while (count < massColons.Length) { List <int> maxValus = new List <int>(); for (int ii = 0; ii < i; ii++) { if (massColons[count] != 15) { if (double.Parse(listView1.Items[ii].SubItems[massColons[count]].Text) >= double.Parse(listView1.Items[indexMax].SubItems[massColons[count]].Text)) { indexMax = ii; } } else { if (double.Parse(listView1.Items[ii].SubItems[massColons[count]].Text) <= double.Parse(listView1.Items[indexMax].SubItems[massColons[count]].Text)) { indexMax = ii; } } //listView1.Items[ii].SubItems[4].BackColor = Color.Red; } for (int k = 0; k < i; k++) { if (double.Parse(listView1.Items[k].SubItems[massColons[count]].Text) == double.Parse(listView1.Items[indexMax].SubItems[massColons[count]].Text)) { listView1.Items[k].SubItems[massColons[count]].BackColor = Color.Green; } } count++; button4.Enabled = false; } }
public void LoadData(int id = 0) { idPhone = id; counts.Clear(); counts = new List <List <string> >(); idFleshMems.Clear(); idFleshMems = new List <List <int> >(); for (int i = 0; i < Buttons.Count; i++) { RemoveAll(); } Buttons.Clear(); ColorComboBoxes.Clear(); LabelsCount.Clear(); LabelsPrise.Clear(); Numers.Clear(); addFirst(); string query = $"SELECT c.FleshMamari,a.colech,a.prise,b.color,c.idFleshMam FROM Stock a, Colors b,FleshMem c WHERE" + $" a.idPhone={id} AND c.idFleshMam = a.idFleshMem AND b.idColor=a.idColor AND a.chatged = FALSE ORDER BY c.FleshMamari"; //string query = $"SELECT a.FleshMamari,b.colech,a.prise,b.color,a.idFleshMam FROM FleshMem a,Colors b WHERE a.idPhone={id} AND b.idFleshMem = a.idFleshMam"; OleDbCommand command = new OleDbCommand(query, Form5.myConnection); OleDbDataReader reader = command.ExecuteReader(); if (reader.Read()) { button2.Text = reader[0].ToString() + " ГБ"; comboBox1.Items.Add(reader[3].ToString()); label49.Text = reader[1].ToString(); label23.Text = reader[2].ToString(); numericUpDown1.Maximum = int.Parse(reader[1].ToString()); counts.Add(new List <string>()); counts[count].Add(reader[1].ToString()); idFleshMems.Add(new List <int>()); idFleshMems[count].Add(int.Parse(reader[4].ToString())); comboBox1.SelectedIndex = 0; } while (reader.Read()) { if (Buttons[count].Text != reader[0].ToString() + " ГБ") { count++; CreateButton(reader[0].ToString() + " ГБ"); CreateComboBoxColor(reader[3].ToString()); CreateLableCount(reader[1].ToString()); CreateLablePrise(reader[2].ToString()); CreateNumber(int.Parse(reader[1].ToString())); counts.Add(new List <string>()); counts[count].Add(reader[1].ToString()); idFleshMems.Add(new List <int>()); idFleshMems[count].Add(int.Parse(reader[4].ToString())); } else { ColorComboBoxes[count].Items.Add(reader[3].ToString()); counts[count].Add(reader[1].ToString()); idFleshMems[count].Add(int.Parse(reader[4].ToString())); } } query = $"SELECT model, data, os, ram, sizeSc, fsim,Csim, hDesign, mDesign, scrin, sizeBat," + $" componi, idProc, texScren, soatnoshStor,cam FROM Phons WHERE idPhone={id}"; command = new OleDbCommand(query, Form5.myConnection); reader = command.ExecuteReader(); //reader.Read(); if (reader.Read()) { label2.Text = reader[11].ToString() + " " + reader[0].ToString(); //Модель label20.Text = reader[1].ToString(); //Data label31.Text = reader[2].ToString(); //Os label33.Text = reader[3].ToString(); //Ram label26.Text = reader[4].ToString(); label35.Text = reader[5].ToString(); //Fsim label36.Text = reader[6].ToString(); //Fsim label39.Text = reader[7].ToString(); //Hdis label40.Text = reader[8].ToString().Replace(".", ","); //mDis label32.Text = reader[9].ToString(); //razScrin label37.Text = reader[10].ToString(); //batari label38.Text = reader[11].ToString(); //compani idProcInPhone = int.Parse(reader[12].ToString()); //idProcInPhone label41.Text = reader[13].ToString(); //texScren label42.Text = reader[14].ToString(); // soatnoshStor label25.Text = reader[15].ToString(); // cam } pictureBox1.Image = DBmanager.GetImage(id); if (idProcInPhone != 1) { query = $"SELECT model,speed,nCors,razProc,sGPU,GAccelModl FROM Cors WHERE idProc={idProcInPhone}"; command = new OleDbCommand(query, Form5.myConnection); reader = command.ExecuteReader(); reader.Read(); label43.Text = reader[0].ToString(); label44.Text = reader[1].ToString(); label45.Text = reader[2].ToString(); label46.Text = reader[3].ToString(); label47.Text = reader[4].ToString(); label48.Text = reader[5].ToString(); pictureBox2.Visible = false; reader.Close(); } else { label43.Text = "Пусто"; label44.Text = "Пусто"; label45.Text = "Пусто"; label46.Text = "Пусто"; label47.Text = "Пусто"; label48.Text = "Пусто"; pictureBox2.Visible = true; } }
public void SelectData(string query = "") { listView1.Items.Clear(); modals.Clear(); idPhone.Clear(); ImageList imageList = new ImageList(); imageList.ImageSize = new Size(120, 150); if (query == "") { query = "SELECT a.model,Min(b.prise),a.idPhone,a.сharged,a.componi FROM Phons a, Stock b WHERE сharged = FALSE AND a.idPhone = b.idPhone GROUP BY a.model,a.idPhone,a.сharged,a.componi,b.prise"; } OleDbCommand command = new OleDbCommand(query, Form5.myConnection); OleDbDataReader reader = command.ExecuteReader(); int i = 0; //idPhone.Add(0); while (reader.Read()) { if (i == 0) { ListViewItem listViewItem = new ListViewItem(new string[] { "", " " + reader[4].ToString() + " " + reader[0].ToString(), reader[1].ToString() + " ", 3 + "", 4 + "", 5 + "" }); //MessageBox.Show(reader[2].ToString()); idPhone.Add(int.Parse(reader[2].ToString())); modals.Add(reader[4].ToString() + " " + reader[0].ToString()); listView1.Items.Add(listViewItem); imageList.Images.Add(DBmanager.GetImage(int.Parse(reader[2].ToString()))); listView1.SmallImageList = imageList; listViewItem.ImageIndex = i; i++; } else if (!FindID(idPhone, int.Parse(reader[2].ToString()))) { ListViewItem listViewItem = new ListViewItem(new string[] { "", " " + reader[4].ToString() + " " + reader[0].ToString(), reader[1].ToString() + " ", 3 + "", 4 + "", 5 + "" }); //MessageBox.Show(reader[2].ToString()); idPhone.Add(int.Parse(reader[2].ToString())); modals.Add(reader[4].ToString() + " " + reader[0].ToString()); listView1.Items.Add(listViewItem); imageList.Images.Add(DBmanager.GetImage(int.Parse(reader[2].ToString()))); listView1.SmallImageList = imageList; listViewItem.ImageIndex = i; i++; } } reader.Close(); //ClearFiltrs(); }