private void Button_Click_8(object sender, RoutedEventArgs e) { ordini delete = lb1.SelectedItem as ordini; if (MessageBox.Show( "Удалить заказ " + delete.nomer_zakaza + "?", "Внимание", MessageBoxButton.OKCancel, MessageBoxImage.Warning) == MessageBoxResult.OK) { SQLiteConnection m_dbConn = new SQLiteConnection(); SQLiteCommand m_sqlCmd = new SQLiteCommand(); m_dbConn = new SQLiteConnection("Data Source=" + dbFileName + ";Version=3;"); m_dbConn.Open(); m_sqlCmd.Connection = m_dbConn; m_sqlCmd.CommandText = "DELETE FROM ordini where nomer_zakaza='" + delete.nomer_zakaza + "'"; m_sqlCmd.ExecuteNonQuery(); m_sqlCmd.Dispose(); m_dbConn.Close(); GC.Collect(); File.Delete(delete.file_path); MessageBox.Show("Готово"); select(); } }
private void lb1_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { string pathtmp = path_ordini + @"\"; if (lb1.SelectedItem != null) { ordini selected_item = (lb1.SelectedItem as ordini); if (File.Exists(pathtmp + selected_item.nomer_zakaza + ".JPG")) { BitmapImage btmap = new BitmapImage(); btmap.BeginInit(); btmap.UriSource = new Uri(pathtmp + selected_item.nomer_zakaza + ".JPG"); btmap.CacheOption = BitmapCacheOption.OnLoad; btmap.EndInit(); img.Source = btmap; //GC.Collect(); } else { img.Source = new BitmapImage(new Uri(@"/TreeCadN;component/Foto/nofoto.jpg", UriKind.RelativeOrAbsolute)); } } else { img.Source = new BitmapImage(new Uri(@"/TreeCadN;component/Foto/nofoto.jpg", UriKind.RelativeOrAbsolute)); } // img.Source = btmap; }
private void Button_Click_3(object sender, RoutedEventArgs e) { ordini duplicate = lb1.SelectedItem as ordini; if (MessageBox.Show( "Дублировать заказ?", "Внимание", MessageBoxButton.OKCancel, MessageBoxImage.Warning) == MessageBoxResult.OK) { object xamb = neqqqqq.getParam(neqqqqq.Ambiente, "GetObject", "XAMB"); object info = neqqqqq.getParamG(xamb, "INFO"); object info2 = neqqqqq.getParamG(info, "INFO"); neqqqqq.getParam(xamb, "carica", duplicate.file_path); string newnum = neqqqqq.getParamI(info, "NuovoNumeroOrdine").ToString(); neqqqqq.setParamP(info, "Numero", newnum); neqqqqq.getParam(info2, "Add", "_NOMEFILEPARETI", duplicate.nomer_zakaza); neqqqqq.getParamI(xamb, "salva");//сохраним SQLiteConnection m_dbConn = new SQLiteConnection(); SQLiteCommand m_sqlCmd = new SQLiteCommand(); m_dbConn = new SQLiteConnection("Data Source=" + dbFileName + ";Version=3;"); m_dbConn.Open(); m_sqlCmd.Connection = m_dbConn; string pattern = "000000"; string nom_form = pattern.Remove(0, newnum.Length) + newnum; m_sqlCmd.CommandText = "INSERT OR IGNORE INTO ordini(file_path, nomer_zakaza) VALUES('" + path_ordini + "\\" + nom_form + ".eve', '" + nom_form + "')"; m_sqlCmd.ExecuteNonQuery(); m_sqlCmd.Dispose(); m_dbConn.Close(); GC.Collect(); MessageBox.Show("Новый заказ имеет номер " + nom_form); select(); } }
void select(bool first = false) { // MessageBox.Show(nomer); if (!first) { save_setting(); } SQLiteConnection m_dbConn = new SQLiteConnection(); SQLiteCommand m_sqlCmd = new SQLiteCommand(); m_dbConn = new SQLiteConnection("Data Source=" + dbFileName + ";Version=3;"); m_dbConn.Open(); m_sqlCmd.Connection = m_dbConn; m_sqlCmd.CommandText = "SELECT * FROM ordini order by nomer_zakaza DESC"; List <ordini> spisok = new List <ordini>(); var reader = m_sqlCmd.ExecuteReader(); while (reader.Read()) { string[] date_split = reader["SROK"].ToString().Split('.'); string date_sorted = ""; if (date_split.Length == 3) { date_sorted = date_split[2] + "." + date_split[1] + "." + date_split[0]; } string[] salon_pre = reader["SALON"].ToString().Split(','); spisok.Add(new ordini { file_path = reader["file_path"].ToString(), FIO_klienta = reader["FIO"].ToString(), nomer_zakaza = reader["nomer_zakaza"].ToString(), Date_last = reader["last_upd"].ToString(), manager_salons = reader["manager"].ToString(), orderprice = reader["orderprice"].ToString().Trim(), _RIFFABRICA = reader["_RIFFABRICA"].ToString(), _RIFSALON = reader["_RIFSALON"].ToString(), SROK = reader["SROK"].ToString(), SALON = salon_pre.Length >= 3 ? salon_pre[1] + " " + salon_pre[2] : "", date_sorted = date_sorted, date_last_update = reader["date_last_update"].ToString().Equals("") ? "" : UnixTimeToDateTime(Convert.ToDouble(reader["date_last_update"].ToString())).ToString("g"), date_last_update_sort = reader["date_last_update"].ToString(), status = reader["status"].ToString(), prim = reader["prim"].ToString(), //, // papka_zakaza = PapkaZakaz(reader["nomer_zakaza"].ToString(), reader["FIO"].ToString()) }); } reader.Close(); // // lb1.ItemsSource = spisok; m_sqlCmd.Dispose(); m_dbConn.Close(); GC.Collect(); viewSource1.Source = spisok; lb1.ItemsSource = viewSource1.View; viewSource1.View.Refresh(); //выбор при открытии string evefile = "000000".Substring(0, 6 - nomer.Length) + nomer; ordini polucnxs = spisok.Find(x => x.nomer_zakaza.Equals(evefile)); lb1.SelectedItem = polucnxs; visiblecolumns(); }