private void buttonProvestiZakaz_Click(object sender, RoutedEventArgs e) { try { DataGridZakaz current = dataGrid1.SelectedItem as DataGridZakaz; if (current.status == "Неоформленный") { db.updateStatuzZakaz(Convert.ToInt32(current.id)); dataGrid1.ItemsSource = db.selectZakaz(); Excel.Application excelApp; Excel.Workbooks excelappworkbooks; Excel.Workbook excelappworkbook; Excel.Sheets excelsheets; Excel.Worksheet excelworksheet; Excel.Range excelcells; excelApp = new Excel.Application(); excelApp.Visible = true; excelappworkbooks = excelApp.Workbooks; excelApp.SheetsInNewWorkbook = 1; excelappworkbook = excelappworkbooks.Add(Type.Missing); excelsheets = excelappworkbook.Worksheets; excelworksheet = (Excel.Worksheet)excelsheets.get_Item(1); excelworksheet.Activate(); excelcells = (Excel.Range)excelworksheet.Cells[1, 1]; excelcells.Value2 = "Наименования товара"; excelcells = (Excel.Range)excelworksheet.Cells[1, 2]; excelcells.Value2 = "Количесиво товара"; excelcells = (Excel.Range)excelworksheet.Cells[1, 3]; excelcells.Value2 = "Размер товара"; excelcells = (Excel.Range)excelworksheet.Cells[1, 4]; excelcells.Value2 = "Цвет товара"; excelcells = (Excel.Range)excelworksheet.Cells[1, 5]; excelcells.Value2 = "Артикуль товара"; excelcells = (Excel.Range)excelworksheet.Cells[2, 1]; excelcells.Value2 = current.nameTovara; excelcells = (Excel.Range)excelworksheet.Cells[2, 2]; excelcells.Value2 = current.numbeTovara; excelcells = (Excel.Range)excelworksheet.Cells[2, 3]; excelcells.Value2 = current.sizeTovara; excelcells = (Excel.Range)excelworksheet.Cells[2, 4]; excelcells.Value2 = current.colorTovara; excelcells = (Excel.Range)excelworksheet.Cells[2, 5]; excelcells.Value2 = current.articul; } else { MessageBox.Show("Заказ уже оформлен"); } } catch { MessageBox.Show("Выберите заказ"); } }
private void MenuItem_Click_2(object sender, RoutedEventArgs e) { DataGridZakaz current = dataGrid1.SelectedItem as DataGridZakaz;; WindowForAddNewZakaz WindowForAddNewZakaz = new WindowForAddNewZakaz(current.id); if (WindowForAddNewZakaz.ShowDialog() == true) { MessageBox.Show("Заказ успешно изменен"); dataGrid1.ItemsSource = db.selectZakaz(); } }
private void button3_Click(object sender, RoutedEventArgs e) { try { DataGridZakaz current = dataGrid1.SelectedItem as DataGridZakaz; db.updateStatuzZakazFinish(Convert.ToInt32(current.id)); dataGrid1.ItemsSource = db.selectZakaz(); } catch { MessageBox.Show("Выберите заказ"); } }
//Возвращает только один заказ для изменения public DataGridZakaz selectZakaz(int id) { conn.Open(); string query = "SELECT * FROM zakaz where id='" + id + "'"; cmd = new MySqlCommand(query, conn); MySqlDataReader reader = cmd.ExecuteReader(); DataGridZakaz list = new DataGridZakaz(); try { while (reader.Read()) { list = new DataGridZakaz( Convert.ToInt32(reader["id"]), reader["fio"].ToString(), reader["adres"].ToString(), reader["adres_comment"].ToString(), reader["mob_tel"].ToString(), reader["ssylka"].ToString(), reader["id_tovara"].ToString(), reader["name_tovara"].ToString(), reader["size_tovara"].ToString(), reader["color_tovara"].ToString(), reader["numbe_tovara"].ToString(), reader["img_tovara"], reader["articul"].ToString(), reader["price_tovara"].ToString(), reader["skidka"].ToString(), reader["comment"].ToString(), reader["otp_kur"].ToString(), reader["price_kur"].ToString(), reader["price_pochta"].ToString(), reader["predoplata"].ToString(), reader["index_tovara"].ToString(), reader["trek"].ToString(), reader["status"].ToString(), reader["dateZak"].ToString() ); } } catch { } conn.Close(); return(list); }
private void MenuItem_Click_3(object sender, RoutedEventArgs e) { try { DataGridZakaz current = dataGrid1.SelectedItem as DataGridZakaz; WindowForConfirm = new WindowForConfirm("Вы действительно хотите удалить заказ"); if (WindowForConfirm.ShowDialog() == true) { db.deleteZakaz(Convert.ToInt32(current.id)); dataGrid1.ItemsSource = db.selectZakaz(); } } catch { MessageBox.Show("Выберите заказ"); } }
//вызвын из контексной меню public WindowForAddNewZakaz(int id) { InitializeComponent(); flagForConst = false; this.id = id; DataGridZakaz currentUpdateZakaz = db.selectZakaz(id); this.status = currentUpdateZakaz.status; string[] arrayAdres = currentUpdateZakaz.adresForUpdate.Split(new char[] { '$' }, StringSplitOptions.RemoveEmptyEntries); this.adresStrana.Text = arrayAdres[0].Replace("Страна: ", ""); this.AdresGorod.Text = arrayAdres[1].Replace(" город: ", ""); this.adreskray.Text = arrayAdres[2].Replace(" край: ", ""); this.adresOblast.Text = arrayAdres[3].Replace(" область: ", ""); this.adresRayon.Text = arrayAdres[4].Replace(" район: ", ""); this.adresUlitsa.Text = arrayAdres[5].Replace(" улица: ", ""); this.adresDom.Text = arrayAdres[6].Replace(" дом: ", ""); this.adresKorpus.Text = arrayAdres[7].Replace(" корпус: ", ""); this.adresKvartira.Text = arrayAdres[8].Replace(" кв: ", ""); adresComment.Text = currentUpdateZakaz.adresComment; this.date.Text = currentUpdateZakaz.dateZak; textBoxNameTovara.Text = currentUpdateZakaz.nameTovara; textBoxIdTovara.Text = currentUpdateZakaz.idTovara; articul.Text = currentUpdateZakaz.articul; textBoxSizeTovara.Text = currentUpdateZakaz.sizeTovara; textBoxColorTovara.Text = currentUpdateZakaz.colorTovara; textBoxNumbeTovara.Text = currentUpdateZakaz.numbeTovara; ImgTovara.Source = imageFunc(currentUpdateZakaz.imgTovara); imgData = currentUpdateZakaz.imgTovara; fio.Text = currentUpdateZakaz.fio; this.tel.Text = currentUpdateZakaz.tel; this.ssylka.Text = currentUpdateZakaz.ssylkaNaSosSeti; textBoxPriceTovara.Text = currentUpdateZakaz.priceTovara; this.skidka.Text = currentUpdateZakaz.skidka; this.priceKur.Text = currentUpdateZakaz.priceKur; this.pricePochta.Text = currentUpdateZakaz.priceDeliveryPochta; textBoxIndex.Text = currentUpdateZakaz.index; this.trek.Text = currentUpdateZakaz.trek; this.predoplata.Text = currentUpdateZakaz.predOplata; this.comment.Text = currentUpdateZakaz.comment; }