Пример #1
0
        private void ItemsList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT);

            cmd.Select("medics").Where("Id", ItemsList.SelectedItem.ToString()).And("Name", SearchBox.Text).Execute();
            MySqlReader r = new MySqlReader(cmd);

            Clear();
            if (r.Read())
            {
                ItemId               = r.ReadInt64("Id");
                MName.Text           = r.ReadString("Name");
                MSS.Text             = r.ReadString("ScientificName");
                MSUP.Text            = r.ReadString("Supplier");
                Ptype                = r.ReadByte("Type");
                MExist.Text          = r.ReadDecimal("Total").ToString();
                MPrice.Text          = r.ReadDecimal("SPrice").ToString();
                MEX.Text             = r.ReadString("ExpirationDate");
                MNotes.Text          = r.ReadString("Notes");
                SearchBox.Foreground = Brushes.Green;
                if (Convert.ToDecimal(MExist.Text) < 1)
                {
                    MExist.Foreground = Brushes.Red;
                    Console.WriteLine("You have no - " + MName.Text + " - I believe that you should get new ones");
                }
                if (Convert.ToDateTime(MEX.Text) <= DateTime.Now.Date)
                {
                    MEX.Background = Brushes.Red;
                    MEX.Foreground = Brushes.OrangeRed;
                    Console.WriteLine("Exy exy - " + MName.Text + " - I believe that you should get rid of that");
                }
                MTypeFromToNo();
                Console.WriteLine("Searched for - " + MName.Text + " -");
            }
        }
Пример #2
0
 private void Page_Loaded(object sender, RoutedEventArgs e)
 {
     if (Environment.OSVersion.Version.Build <= 2600)
     {
         Pb.Height = 10;
     }
     Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart) delegate()
     {
         Pb.Visibility    = Visibility.Visible;
         MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT);
         var mT           = new System.Data.DataTable();
         mT.Columns.Add("الدواء", typeof(string));
         mT.Columns.Add("تاريخ انتهاء الصلاحية", typeof(string));
         mT.Columns.Add("السعر", typeof(decimal));
         mT.Columns.Add("الكمية", typeof(decimal));
         cmd.Select("medics");
         MySqlReader r = new MySqlReader(cmd);
         while (r.Read())
         {
             try
             {
                 if (Convert.ToDateTime(r.ReadString("ExpirationDate")) <= DateTime.Now.Date)
                 {
                     mT.Rows.Add(r.ReadString("Name"), r.ReadString("ExpirationDate"), r.ReadDecimal("SPrice"), r.ReadDecimal("Total"));
                 }
             }
             catch (Exception ex)
             {
                 MessageBox.Show("غالبا هناك خطا فى التواريخ");
                 Kernel.Core.SaveException(ex);
                 break;
             }
         }
         DataGrid.ItemsSource = mT.DefaultView;
         r.Close();
         Pb.Visibility = Visibility.Hidden;
     });
 }
Пример #3
0
        /// <summary>
        /// Selling command
        /// </summary>
        private void SellMedic()
        {
            if (Convert.ToDateTime(MEX.Text) <= DateTime.Now.Date)
            {
                MessageBoxResult result = MessageBox.Show("الدواء منتهى الصلاحيه\nهل تريد الاستمرار", "تحذير", MessageBoxButton.OKCancel, MessageBoxImage.Warning);
                switch (result)
                {
                case MessageBoxResult.OK:
                    Console.WriteLine("WeWa WeWa WeWa WeWa\n\r this is the police sirens run .. run");
                    MessageBox.Show("جارى استكمال عمليه البيع");
                    break;

                case MessageBoxResult.Cancel:
                    Console.WriteLine("Goodboy");
                    MessageBox.Show("تم ايقاف عمليه البيع");
                    return;
                }
            }
            //Already existed drugs
            decimal aExist = 0;
            //What is left after selling some
            decimal tot = 0;

            try
            {
                MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT);
                cmd.Select("medics").Where("Id", ItemId).And("Name", MName.Text).Execute();
                MySqlReader r = new MySqlReader(cmd);
                if (r.Read())
                {
                    aExist = r.ReadDecimal("Total");
                }
                if (aExist > 0)
                {
                    tot = aExist - Convert.ToDecimal(MWSell.Text);
                    if (tot >= 0)
                    {
                        MExist.Text = tot.ToString();
                        MySqlCommand CMD = new MySqlCommand(MySqlCommandType.UPDATE);
                        CMD.Update("medics")
                        .Set("Total", tot).Where("Name", MName.Text).Execute();
                        MessageBox.Show("تم بيع " + MWSell.Text);
                        SaveSold();
                        CompleteSelling = true;
                    }
                    else
                    {
                        MessageBox.Show("الكميه الموجودة لا تناسب ما تحاول بيعه");
                        Console.WriteLine("a little idoit i see in you");
                    }
                }
                else
                {
                    MessageBox.Show("الدواء غير متوفر");
                    Console.WriteLine("So basically you are tring to copy Apple business model");
                }
            }
            catch (Exception ex)
            {
                Kernel.Core.SaveException(ex);
            }
        }
Пример #4
0
 private void SearchButton_Click(object sender, RoutedEventArgs e)
 {
     Clear();
     try
     {
         if (ByBarCode.IsChecked == true)
         {
             MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT);
             cmd.Select("medics").Where("Barcode", SearchBox.Text).Execute();
             MySqlReader r = new MySqlReader(cmd);
             if (r.Read())
             {
                 ItemId               = r.ReadInt64("Id");
                 MName.Text           = r.ReadString("Name");
                 MSS.Text             = r.ReadString("ScientificName");
                 MSUP.Text            = r.ReadString("Supplier");
                 Ptype                = r.ReadByte("Type");
                 MExist.Text          = r.ReadDecimal("Total").ToString();
                 MPrice.Text          = r.ReadDecimal("SPrice").ToString();
                 MEX.Text             = r.ReadString("ExpirationDate");
                 MNotes.Text          = r.ReadString("Notes");
                 SearchBox.Foreground = Brushes.Green;
                 if (Convert.ToDecimal(MExist.Text) < 1)
                 {
                     MExist.Foreground = Brushes.Red;
                     Console.WriteLine("You have no - " + MName.Text + " - " + ItemId + " - I believe that you should get new ones");
                 }
                 if (Convert.ToDateTime(MEX.Text) <= DateTime.Now.Date)
                 {
                     MEX.Background = Brushes.Red;
                     MEX.Foreground = Brushes.OrangeRed;
                     Console.WriteLine("bad deadpool - " + MName.Text + " - " + ItemId + " - you should get rid of that");
                 }
                 Console.WriteLine("Searched for - " + MName.Text + " - " + ItemId + " -");
             }
             else
             {
                 SearchBox.Foreground = Brushes.Red;
                 Console.WriteLine("Searched for - " + SearchBox.Text + " - with no luck");
             }
             r.Close();
             ItemsList.Items.Clear();
             while (r.Read())
             {
                 ItemsList.Items.Add(r.ReadInt64("Id"));
             }
             if (ItemsList.Items.Count < 1)
             {
                 ItemsList.Items.Clear();
                 ItemsList.Items.Add("لا يوجد شئ اخر");
             }
             r.Close();
         }
         else if (ByBarCode.IsChecked == false)
         {
             MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT);
             cmd.Select("medics").Where("Name", SearchBox.Text).Execute();
             MySqlReader r = new MySqlReader(cmd);
             if (r.Read())
             {
                 ItemId               = r.ReadInt64("Id");
                 MName.Text           = r.ReadString("Name");
                 MSS.Text             = r.ReadString("ScientificName");
                 MSUP.Text            = r.ReadString("Supplier");
                 Ptype                = r.ReadByte("Type");
                 MExist.Text          = r.ReadDecimal("Total").ToString();
                 MPrice.Text          = r.ReadDecimal("SPrice").ToString();
                 MEX.Text             = r.ReadString("ExpirationDate");
                 MNotes.Text          = r.ReadString("Notes");
                 SearchBox.Foreground = Brushes.Green;
                 if (Convert.ToDecimal(MExist.Text) < 1)
                 {
                     MExist.Foreground = Brushes.Red;
                     Console.WriteLine("You have no - " + MName.Text + " - I believe that you should get new ones");
                 }
                 if (Convert.ToDateTime(MEX.Text) <= DateTime.Now.Date)
                 {
                     MEX.Background = Brushes.Red;
                     MEX.Foreground = Brushes.OrangeRed;
                     Console.WriteLine("Red Alert - " + MName.Text + " - you should get rid of that");
                 }
                 Console.WriteLine("Searched for - " + MName.Text + " -");
             }
             else
             {
                 SearchBox.Foreground = Brushes.Red;
                 Console.WriteLine("Searched for - " + SearchBox.Text + " - with no luck");
             }
             ItemsList.Items.Clear();
             while (r.Read())
             {
                 ItemsList.Items.Add(r.ReadInt64("Id"));
             }
             if (ItemsList.Items.Count < 1)
             {
                 ItemsList.Items.Clear();
                 ItemsList.Items.Add("لا يوجد شئ اخر");
             }
             r.Close();
         }
         MTypeFromToNo();
     }
     catch (Exception ex)
     {
         Core.SaveException(ex);
     }
     SearchBox.Items.Refresh();
 }