Beispiel #1
0
        private void left_Click(object sender, RoutedEventArgs e)
        {
            if (aProductData == null || aProductData.Id == 0) return;
            var tmp = aProductData.Prev();
            if (tmp == null || tmp.Id == 0) return;

            aProductData = tmp;
            loadData(aProductData);
        }
Beispiel #2
0
 private void Button_Click_2(object sender, RoutedEventArgs e)
 {
     var tmp = aProductData.SearchPhoneByTheProductName(ProductNameSearch.Text);
     if (tmp != null && tmp.Id != 0)
     {
         aProductData = tmp;
         loadData(aProductData);
     }
 }
Beispiel #3
0
        public MainWindow()
        {
            InitializeComponent();

            warehouse = new Warehouse();
            service   = new ServiceController("Service1");
            aProductData = new AssociatedProductData(warehouse, warehouse.First());
            loadData(aProductData);
        }
Beispiel #4
0
 public static ProductData ToProductData(AssociatedProductData aProductData)
 {
     return new ProductData
     {
         Model = aProductData.Model,
         ProductName = aProductData.ProductName,
         Id = aProductData.Id,
         BarCode = aProductData.BarCode,
         ProductType = aProductData.ProductType,
         AlertLevel = aProductData.AlertLevel,
         Ammount = aProductData.Ammount,
         Price = aProductData.Price
     };
 }
Beispiel #5
0
        private void OnElapsedTime(object source, ElapsedEventArgs e)
        {
            var emsend = System.Configuration.ConfigurationManager.AppSettings["emailsender"].ToString();
            var emrec = System.Configuration.ConfigurationManager.AppSettings["emailreciver"].ToString();
            var emsrv = System.Configuration.ConfigurationManager.AppSettings["emailserver"].ToString();
            var empass = System.Configuration.ConfigurationManager.AppSettings["emailpasswd"].ToString();

            Warehouse warehouse = new Warehouse();

            TraceService("Chectking started" + DateTime.Now);
            TraceService("All products:" + warehouse.ToList().Count.ToString() + DateTime.Now);

            var all = warehouse.ToList();

            var act = new AssociatedProductData(warehouse, warehouse.First());

            while (act != null && act.Id != 0)
            {
                if (act.Ammount < act.AlertLevel)
                {
                    MailMessage Message = new MailMessage();

                    Message.From = new MailAddress(emsend);
                    Message.To.Add("*****@*****.**");
                    Message.Subject = "Supply request";
                    Message.Body = "Please supply at least" + (act.AlertLevel - act.Ammount) + " " + act.ProductName + "(" + act.Model + ")" + "!!!";

                    SmtpClient client = new SmtpClient();
                    client.Host = emsrv;
                    client.Port = 587;
                    client.UseDefaultCredentials = false;
                    client.DeliveryMethod = SmtpDeliveryMethod.Network;
                    client.EnableSsl = true;
                    client.Credentials = new NetworkCredential(emsend, empass);
                    client.Send(Message);
                    TraceService("Sending email:" + DateTime.Now);
                }

                act = act.Next();

            }
            TraceService("All products checked " + DateTime.Now);
        }
Beispiel #6
0
 public AssociatedProductData Prev(AssociatedProductData aProductData)
 {
     return ToAProductData((ToProductData(aProductData).Prev(warehouse)));
 }
Beispiel #7
0
 public AssociatedProductData Next(AssociatedProductData aProductData)
 {
     return ToAProductData((ToProductData(aProductData).Next(warehouse)));
 }
Beispiel #8
0
 private void loadData(AssociatedProductData aProductData)
 {
     ID.Text = aProductData.Id.ToString();
     ProductName.Text = aProductData.ProductName;
     Model.Text = aProductData.Model;
     ProductType.Text = aProductData.ProductType.ToString();
     BarCode.Text = aProductData.BarCode;
     Ammount.Text = aProductData.Ammount.ToString();
     AlertLevel.Text = aProductData.AlertLevel.ToString();
 }