Exemplo n.º 1
0
 private void SearchButton_Click(object sender, RoutedEventArgs e)
 {
     if (ByName.IsChecked == true)
     {
         MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT).Select("bills").Where("ClientName", SearchBox.Text);
         MySqlReader  r   = new MySqlReader(cmd);
         BillsNoList.Items.Clear();
         while (r.Read())
         {
             BillsNoList.Items.Add(r.ReadString("ID"));
         }
         r.Close();
     }
     else
     {
         MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT).Select("bills").Where("ID", SearchBox.Text);
         MySqlReader  r   = new MySqlReader(cmd);
         if (r.Read())
         {
             BillsNoList.Items.Clear();
             BillsNoList.Items.Add(r.ReadString("ID"));
         }
         r.Close();
     }
 }
Exemplo n.º 2
0
        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            decimal      TP  = 0;
            MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT).Select("bills")
                               .Where("ID", listBox1.GetItemText(listBox1.SelectedItem));
            MySqlReader r = new MySqlReader(cmd);

            while (r.Read())
            {
                textBox1.Clear();
                string AllBills = r.ReadString("Medic");
                textBox1.Text += "رقم الفاتورة : " + r.ReadString("ID") + "\r\n";
                textBox1.Text += "الموظف : " + r.ReadString("User") + "\r\n";
                textBox1.Text += "المشترى : " + r.ReadString("Name") + "\r\n";
                textBox1.Text += "وقت البيع : " + r.ReadString("BillDate") + "\r\n";
                textBox1.Text += "----الادويه---------------------------------\r\n";
                string[] bills = AllBills.Split('#');
                foreach (string[] BillInfo in bills.TakeWhile(bill => bill.Length >= 2).Select(bill => bill.Split('~')))
                {
                    textBox1.Text += "الاسم : " + Convert.ToString(BillInfo[0]) + "  \t";
                    textBox1.Text += "السعر : " + Convert.ToDecimal(BillInfo[1]) + "\r\n";
                    TP            += Convert.ToDecimal(BillInfo[1]);
                }
                textBox1.Text += "--------------------------------------------\r\n";
                textBox1.Text += "الاجمالى = " + TP;
                textBox1.Text += "\r\n--------------------------------------------\r\n";
            }
            r.Close();
        }
Exemplo n.º 3
0
 private void BillsNoList_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (BillsNoList.SelectedIndex != -1)
     {
         MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT).Select("bills").Where("ID", BillsNoList.SelectedItem.ToString());
         MySqlReader  r   = new MySqlReader(cmd);
         while (r.Read())
         {
             decimal TP = 0;
             BillContent.Clear();
             string AllBills = r.ReadString("Medics");
             BillContent.Text += "رقم الفاتورة : " + r.ReadString("ID") + "\r\n";
             BillContent.Text += "الموظف : " + r.ReadString("Cashier") + "\r\n";
             BillContent.Text += "المشترى : " + r.ReadString("ClientName") + "\r\n";
             BillContent.Text += "وقت البيع : " + r.ReadString("BillDate") + "\r\n";
             BillContent.Text += "----الادويه---------------------------------\r\n";
             string[] bills = AllBills.Split('#');
             foreach (string[] BillInfo in bills.TakeWhile(bill => bill.Length >= 2).Select(bill => bill.Split('~')))
             {
                 BillContent.Text += "الاسم : " + Convert.ToString(BillInfo[1]) + "  \t";
                 BillContent.Text += "الكمية : " + Convert.ToString(BillInfo[0]) + " \t";
                 BillContent.Text += "السعر : " + Convert.ToDecimal(BillInfo[2]) + "\r\n";
                 TP += Convert.ToDecimal(BillInfo[2]);
             }
             BillContent.Text += "--------------------------------------------\r\n";
             BillContent.Text += "الاجمالى = " + TP;
             BillContent.Text += "\r\n--------------------------------------------\r\n";
         }
         r.Close();
     }
 }
Exemplo n.º 4
0
 private void SellB_Click(object sender, EventArgs e)
 {
     BillsTable.Client = Client.Text;
     BillsTable.MName  = PName.Text;
     BillsTable.MCost  = Convert.ToDecimal(PCost.Text);
     if (PName.Text != "" && Client.Text != "" && NewBill.Checked)
     {
         SellMedic();
         if (SellCom != true)
         {
             return;
         }
         BillsTable.newbill();
         try
         {
             MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT).Select("bills").Order("ID");
             MySqlReader  r   = new MySqlReader(cmd);
             if (r.Read())
             {
                 BillNO.Text = r.ReadString("ID");
             }
             r.Close();
             SellCom = false;
         }
         catch (Exception el)
         {
             Program.SaveException(el);
         }
     }
     else if (PName.Text != "" && Client.Text != "" && !NewBill.Checked)
     {
         SellMedic();
         if (SellCom == false)
         {
             return;
         }
         BillsTable.updatebill();
         SellCom = false;
     }
     else if (PName.Text == "" || PCost.Text == "")
     {
         MessageBox.Show("لا يوجد دواء");
     }
     else if (Client.Text == "")
     {
         MessageBox.Show("ادخل اسم المشترى");
     }
     else
     {
         MessageBox.Show("الدواء غير متوفر");
     }
 }
Exemplo n.º 5
0
        private void SL1()
        {
            MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT);

            cmd.Select("medlog"); //.Where("SellDate", Convert.ToUInt16(DateTime.Now.Day));
            MySqlReader r = new MySqlReader(cmd);

            while (r.Read())
            {
                dd1.Rows.Add(r.ReadString("Name"), r.ReadString("SellDate"), r.ReadString("Cost"));
                ff   = Convert.ToDecimal(r.ReadString("Cost"));
                ff1 += ff;
            }
            r.Close();
        }
Exemplo n.º 6
0
 private void nb()
 {
     try
     {
         MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT).Select("bills").Order("ID", true);
         MySqlReader  r   = new MySqlReader(cmd);
         while (r.Read())
         {
             listBox1.Items.Add(r.ReadString("ID") /* + " || " + r.ReadString("Name")*/);
         }
         r.Close();
     }
     catch (Exception ee)
     {
         Program.SaveException(ee);
     }
 }
Exemplo n.º 7
0
 private void endexp()
 {
     try
     {
         MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT);
         cmd.Select("medics").Where("Expiry", Convert.ToUInt16(DateTime.Now.Month), false);
         MySqlReader r = new MySqlReader(cmd);
         while (r.Read())
         {
             dataGridView1.Rows.Add(r.ReadString("Name"), r.ReadString("Expiry"), r.ReadString("Count"));
         }
         r.Close();
     }
     catch (Exception eee)
     {
         MessageBox.Show(eee.ToString());
     }
 }
Exemplo n.º 8
0
 public void end()
 {
     try
     {
         MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT);
         cmd.Select("medics").Where("Count", "0");
         MySqlReader r = new MySqlReader(cmd);
         while (r.Read())
         {
             MedLog.Text += r.ReadString("Name") + "\r\n";
             MedLog.Text += "----------------------------------------\r\n";
         }
         r.Close();
     }
     catch (Exception eee)
     {
         MessageBox.Show(eee.ToString());
     }
 }
Exemplo n.º 9
0
 private void Page_Loaded(object sender, RoutedEventArgs e)
 {
     Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart) delegate()
     {
         try
         {
             MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT).Select("bills").Order("ID", true);
             MySqlReader r    = new MySqlReader(cmd);
             while (r.Read())
             {
                 BillsNoList.Items.Add(r.ReadString("ID"));
             }
             r.Close();
         }
         catch (Exception ex)
         {
             Kernel.Core.SaveException(ex);
         }
     });
 }
Exemplo n.º 10
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;
     });
 }
Exemplo n.º 11
0
 private void IL()
 {
     try
     {
         MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT);
         cmd.Select("medics").Where("Count", 0, true);
         MySqlReader r = new MySqlReader(cmd);
         while (r.Read())
         {
             decimal tt, ff = 0;
             ff = Convert.ToDecimal(r.ReadString("Price"));
             tt = Convert.ToDecimal(r.ReadString("Count"));
             DGV.Rows.Add(r.ReadString("Name"), r.ReadString("Price"), r.ReadString("Count"), r.ReadString("Expiry"));
             pp += ff * tt;
         }
         totalprice.Text = "اجمالى سعر الموجود :" + Convert.ToDecimal(pp) + "جنيه";
         r.Close();
     }
     catch (Exception ee)
     {
         Program.SaveException(ee);
     }
 }
Exemplo n.º 12
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));
         cmd.Select("medics").Where("Total", 0);
         MySqlReader r = new MySqlReader(cmd);
         while (r.Read())
         {
             mT.Rows.Add(r.ReadString("Name"));
         }
         DataGrid.ItemsSource = mT.DefaultView;
         r.Close();
         Pb.Visibility = Visibility.Hidden;
     });
 }
Exemplo n.º 13
0
 private void loginlog()
 {
     try
     {
         MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT);
         cmd.Select("logs").Where("LoginDate", Convert.ToUInt16(DateTime.Now.Day));
         MySqlReader r = new MySqlReader(cmd);
         while (r.Read())
         {
             logss1.Text += "اسم المستخدم : " + r.ReadString("Account") + "\r\n";
             logss1.Text += "وقت الدخول : " + r.ReadString("LoginDate");
             logss1.Text += "\r\n----------------------------------------------\r\n";
         }
         r.Close();
     }
     catch (Exception eee)
     {
         MessageBox.Show(eee.ToString());
     }
     try
     {
         MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT);
         cmd.Select("logs").Where("LoginDate", Convert.ToUInt16(DateTime.Now.Day), false);
         MySqlReader r = new MySqlReader(cmd);
         while (r.Read())
         {
             logss2.Text += "اسم المستخدم : " + r.ReadString("Account") + "\r\n";
             logss2.Text += "وقت الدخول : " + r.ReadString("LoginDate");
             logss2.Text += "\r\n----------------------------------------------\r\n";
         }
         r.Close();
     }
     catch (Exception ee)
     {
         MessageBox.Show(ee.ToString());
     }
 }
Exemplo n.º 14
0
        /// <summary>
        /// Convert C# datetime type and data to mysql for V0.9.9.7
        /// </summary>
        void CDfcts()
        {
            var         ncmd = new Database.MySqlCommand(MySqlCommandType.SELECT).Select("logs");
            MySqlReader r    = new MySqlReader(ncmd);

            while (r.Read())
            {
                var uN   = r.ReadString("Username");
                var uLi  = r.ReadString("LoginDate");
                var uLo  = r.ReadString("LogoutDate");
                var oUli = uLi;
                var dt1  = Convert.ToDateTime(uLi);
                uLi = dt1.ToString("yyyy-MM-dd HH:mm:ss");
                var ucmd = new Database.MySqlCommand(MySqlCommandType.UPDATE);
                if (uLo != "")
                {
                    var dt2 = Convert.ToDateTime(uLo);
                    uLo = dt2.ToString("yyyy-MM-dd HH:mm:ss");
                    ucmd.Update("logs")
                    .Set("LoginDate", uLi)
                    .Set("LogoutDate", uLo)
                    .Where("Username", uN)
                    .And("LoginDate", oUli)
                    .Execute();
                }
                else
                {
                    ucmd.Update("logs")
                    .Set("LoginDate", uLi)
                    .Where("Username", uN)
                    .And("LoginDate", oUli)
                    .Execute();
                }
            }
            r.Close();
        }
Exemplo n.º 15
0
 private void SellM_Click(object sender, RoutedEventArgs e)
 {
     if (MName.Text == "" || MPrice.Text == "" || MExist.Text == "" || MWSell.Text == "")
     {
         MessageBox.Show("لا يمكن اتمام عمليه البيع بسبب وجود حقل مهم فارغ");
         return;
     }
     if (EnBills.IsChecked == true)
     {
         BillsTable.bClient = Client.Text;
         BillsTable.bMName  = MName.Text;
         BillsTable.bMCost  = Convert.ToDecimal(MPrice.Text) * Convert.ToDecimal(MWSell.Text);
         if (MName.Text != "" && Client.Text != "" && NewBill.IsChecked == true)
         {
             SellMedic();
             if (CompleteSelling != true)
             {
                 return;
             }
             BillsTable.newbill();
             try
             {
                 MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT).Select("bills").Order("ID");
                 MySqlReader  r   = new MySqlReader(cmd);
                 if (r.Read())
                 {
                     BillNo.Text = r.ReadString("ID");
                 }
                 r.Close();
                 CompleteSelling = false;
             }
             catch (Exception ex)
             {
                 Core.SaveException(ex);
             }
         }
         else if (MName.Text != "" && Client.Text != "" && NewBill.IsChecked == false)
         {
             SellMedic();
             if (CompleteSelling == false)
             {
                 return;
             }
             BillsTable.updatebill();
             CompleteSelling = false;
         }
         else if (Client.Text == "")
         {
             MessageBox.Show("ادخل اسم المشترى/العميل");
         }
         else
         {
             MessageBox.Show("الدواء غير متوفر");
         }
     }
     else
     {
         SellMedic();
         CompleteSelling = false;
     }
 }
Exemplo n.º 16
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();
 }