private void Remove(object sender, EventArgs e) { for (int i = 0; i < t.Count; i++) { for (int j = 0; j < Win.program.listTables.Count; j++) { if (Win.program.listTables[j].НомерЗаказа == ((StartTaga)PanelX.Children[i]).index) { Win.program.listTables.RemoveAt(j); break; } } } Win.SaveThisBase(); Close(); }
//Сохранить базу как private void MenuItem_Click_5(object sender, RoutedEventArgs e) { Win.SaveThisBase(); SaveFileDialog fD = new SaveFileDialog { Filter = "Leroy Base (*.lmb)|*.lmb|All files (*.*)|*.*" }; if (fD.ShowDialog() == true) { using (FileStream fs = new FileStream(fD.FileName, FileMode.Create)) formatter.Serialize(fs, Win.program); Win.settings.path = fD.FileName; } }
//Открыть новую базу private void MenuItem_Click_4(object sender, RoutedEventArgs e) { Win.SaveThisBase(); OpenFileDialog fD = new OpenFileDialog { Filter = "Leroy Base (*.lmb)|*.lmb|All files (*.*)|*.*" }; if (fD.ShowDialog() == true) { using (FileStream fs = new FileStream(fD.FileName, FileMode.OpenOrCreate)) Win.program = (Program)formatter.Deserialize(fs); Win.settings.path = fD.FileName; ClearList(); } }
void Upid() { while (true) { float m = 0; for (int i = 0; i < Win.program.listTables.Count; i++) { m += Win.program.listTables[i].Деньга * Win.program.listTables[i].Количество / 100; Thread.Sleep(50); } Dispatcher.Invoke(() => Title = "LM Client - " + Win.program.listTables.Count.ToString() + " клиентов. " + "Общая стоймость: " + m.ToString() + "RUR"); while (Dispatcher.Invoke(() => Win.program.listTables.Count != Components.Children.Count)) { if (Dispatcher.Invoke(() => Win.program.listTables.Count > Components.Children.Count)) { Dispatcher.Invoke(() => Components.Children.Add(new Table())); } else { Dispatcher.Invoke(() => Components.Children.RemoveAt(Components.Children.Count - 1)); } } Dispatcher.Invoke(() => Win.OpenThisBase()); for (int i = 0; i < Dispatcher.Invoke(() => Win.program.listTables.Count); i++) { try { Dispatcher.Invoke(() => ((Table)Components.Children[i]).Дата = Win.program.listTables[i].Дата.ToString("dd.MM.yyyy")); Dispatcher.Invoke(() => ((Table)Components.Children[i]).ДатаПрихода = Win.program.listTables[i].ДатаПрихода.ToString("dd.MM.yyyy")); Dispatcher.Invoke(() => ((Table)Components.Children[i]).Артикул = Win.program.listTables[i].Артикул.ToString()); Dispatcher.Invoke(() => ((Table)Components.Children[i]).ИмяКлиента = Win.program.listTables[i].ИмяКлиента); Dispatcher.Invoke(() => ((Table)Components.Children[i]).ИмяТовара = Win.program.listTables[i].ИмяТовара); Dispatcher.Invoke(() => ((Table)Components.Children[i]).Статус = Win.program.listTables[i].Статус.ToString()); Dispatcher.Invoke(() => ((Table)Components.Children[i]).НомерКлиента = Win.program.listTables[i].НомерКлиента.ToString()); Dispatcher.Invoke(() => ((Table)Components.Children[i]).SizeChang()); Thread.Sleep(50); } catch { } } Thread.Sleep(3000); } }
private void LKM(object sender, EventArgs e) { for (int i = 0; i < Win.program.listTables.Count; i++) { if (Win.program.listTables[i].НомерЗаказа == ((StartTaga)sender).index) { Win.program.listTables.RemoveAt(i); break; } } Win.SaveThisBase(); t.Remove(((StartTaga)sender).index); PanelX.Children.RemoveAt(PanelX.Children.IndexOf(((StartTaga)sender))); if (PanelX.Children.Count == 0) { Close(); } }
private void Reboot_Click(object sender, RoutedEventArgs e) { richTextBox1.Text = ""; Win.settings.pass = PasstextBox.Password; Win.SaveSettings(); try { var XML = "XML=<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<SMS>\n" + "<operations>\n" + "<operation>GETSTATUS</operation>\n" + "</operations>\n" + "<authentification>\n" + "<username>" + Win.log + "</username>\n" + "<password>" + PasstextBox.Password + "</password>\n" + "</authentification>\n" + "<statistics>\n" + "<messageid>msg15</messageid>\n" + "</statistics>\n" + "</SMS>\n"; HttpWebRequest request = WebRequest.Create("http://api.myatompark.com/members/sms/xml.php") as HttpWebRequest; request.Method = "Post"; request.ContentType = "application/x-www-form-urlencoded"; UTF8Encoding encoding = new UTF8Encoding(); byte[] data = encoding.GetBytes(XML); request.ContentLength = data.Length; Stream dataStream = request.GetRequestStream(); dataStream.Write(data, 0, data.Length); using (HttpWebResponse response = request.GetResponse() as HttpWebResponse) { if (response.StatusCode != HttpStatusCode.OK) { throw new Exception(String.Format( "Server error (HTTP {0}: {1}).", response.StatusCode, response.StatusDescription)); } string s = new StreamReader(response.GetResponseStream()).ReadToEnd(); if (s.Length < 255) { MessageBox.Show("Пароль неверный", "Ошибочка"); } XmlDocument doc = new XmlDocument(); doc.LoadXml(s); XmlNode root_node = doc.DocumentElement; XmlNodeList nodes = root_node.ChildNodes; foreach (XmlNode n in nodes) { if (n.Name == "message") { richTextBox1.Text = "[" + n.Attributes["sentdate"].Value + "] | " + n.Attributes["status"].Value.Replace("0", "Идёт отправка") + "\n" + richTextBox1.Text; } } richTextBox1.Text = richTextBox1.Text.Replace("SENT", "Отослано"); richTextBox1.Text = richTextBox1.Text.Replace("NOT_DELIVERED", "Не доставлено"); richTextBox1.Text = richTextBox1.Text.Replace("DELIVERED", "Доставлено"); richTextBox1.Text = richTextBox1.Text.Replace("NOT_ALLOWED", "Оператор не обслуживается"); richTextBox1.Text = richTextBox1.Text.Replace("INVALID_DESTINATION_ADDRESS", "Неверный адрес для доставки"); richTextBox1.Text = richTextBox1.Text.Replace("INVALID_SOURCE_ADDRESS", "Неправильное имя «От кого»"); richTextBox1.Text = richTextBox1.Text.Replace("NOT_ENOUGH_CREDITS", "Недостаточно кредитов"); richTextBox1.Text = richTextBox1.Text.Replace("0000-00-00 00:00:00", "Идёт Отправка"); } } catch (Exception s) { MessageBox.Show(s.ToString()); } if (Win.settings.today != "") { label1.Content = "Ваш лимит сообщений: " + Win.settings.today + " СМС"; } else { label1.Content = ""; } }
private void Send_Click(object sender, RoutedEventArgs e) { rich.Text = rich.Text.Replace("<num>", Win.program.listTables[index].НомерЗаказа.ToString()); rich.Text = rich.Text.Replace("<time>", DateTime.Now.ToString("hh:mm")); rich.Text = rich.Text.Replace("<date>", DateTime.Now.ToString("dd MMMMMMMMMMM")); rich.Text = rich.Text.Replace("<dateE>", Win.program.listTables[index].ДатаПрихода.ToString("dd MMMMMMMMMMM")); rich.Text = rich.Text.Replace("<name>", Win.program.listTables[index].ИмяКлиента); rich.Text = rich.Text.Replace("<nomber>", Win.program.listTables[index].НомерКлиента); rich.Text = rich.Text.Replace("<obj>", Win.program.listTables[index].ИмяТовара); rich.Text = rich.Text.Replace("<qua>", Win.program.listTables[index].Количество.ToString()); rich.Text = rich.Text.Replace("<art>", Win.program.listTables[index].Артикул.ToString()); rich.Text = rich.Text.Replace("<prod>", Win.program.listTables[index].Поставщик); try { var XML = "XML=<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<SMS>\n" + "<operations>\n" + "<operation>SEND</operation>\n" + "</operations>\n" + "<authentification>\n" + "<username>" + Win.log + "</username>\n" + "<password>" + Win.settings.pass + "</password>\n" + "</authentification>\n" + "<message>\n" + "<sender>LEROYMERLIN</sender>\n" + "<text>" + rich.Text + "</text>\n" + "</message>\n" + "<numbers>\n"; if (s == ServiceSMS.ОповещениеИзменаДаты) { XML += "<number messageID=\"msg17\">+7" + Nomber.Text + "</number>\n" + "</numbers>\n" + "</SMS>\n"; } if (s == ServiceSMS.ВнесениеВСписок) { XML += "<number messageID=\"msg16\">+7" + Nomber.Text + "</number>\n" + "</numbers>\n" + "</SMS>\n"; } if (s == ServiceSMS.ПриходТовара) { XML += "<number messageID=\"msg15\">+7" + Nomber.Text + "</number>\n" + "</numbers>\n" + "</SMS>\n"; } HttpWebRequest request = WebRequest.Create("http://api.myatompark.com/members/sms/xml.php") as HttpWebRequest; request.Method = "Post"; request.ContentType = "application/x-www-form-urlencoded"; UTF8Encoding encoding = new UTF8Encoding(); byte[] data = encoding.GetBytes(XML); request.ContentLength = data.Length; Stream dataStream = request.GetRequestStream(); dataStream.Write(data, 0, data.Length); using (HttpWebResponse response = request.GetResponse() as HttpWebResponse) { if (response.StatusCode != HttpStatusCode.OK) { throw new Exception(String.Format( "Server error (HTTP {0}: {1}).", response.StatusCode, response.StatusDescription)); } } Win.settings.смсразослано++; Win.settings.мсмсразослано++; } catch (Exception s) { MessageBox.Show(s.Message); } if (s == ServiceSMS.ПриходТовара) { Win.OpenThisBase(); for (int i = 0; i < Win.program.listTables.Count; i++) { if (Win.program.listTables[i] == Win.program.listTables[index]) { ((Table)Win.mainWindow.Components.Children[i]).Статус = "Оповещён"; Win.program.listTables[i] = new Taga(Win.program.listTables[index]); break; } } Win.SaveThisBase(); } Close(); }