Exemplo n.º 1
0
        private void btnDeletGroup_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (IDGroup != 0)
                {
                    if (MessageBox.Show("هل تريد حذف العنصر المحدد؟", "حذف", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                    {
                        PharmaLinq = new Linq.PharmaLinqDataContext(flag.Con);
                        Linq.Group group = PharmaLinq.Groups.Single(item => item.ID_Groups == IDGroup);

                        group.Exist = false;
                        PharmaLinq.SubmitChanges();

                        MessageBox.Show("تم الحذف");


                        USC.USC_GROUPS_MANGE frm = new USC_GROUPS_MANGE();
                        MainWindow.GetMainForm.GridUsc.Children.Clear();
                        MainWindow.GetMainForm.GridUsc.Children.Add(frm);
                    }
                }
                else
                {
                    MessageBox.Show("الرجاء اختيار عنصر");
                }
            }
            catch (Exception ex)
            {
                flag.Con.Close();
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 2
0
        private void btnDeletUser_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (UserId != 0)
                {
                    PharmaLinq = new Linq.PharmaLinqDataContext(flag.Con);

                    if (MessageBox.Show("هل تريد حذف العنصر المحدد؟", "حذف", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                    {
                        var user = PharmaLinq.Users.Single(item => item.ID_User == UserId);
                        user.Exist = false;
                        PharmaLinq.SubmitChanges();
                        MessageBox.Show("تم الحذف");
                        Dt = flag.Fill_DataGrid_join("SELECT * FROM [dbo].[Users] where  Exist = 'true'");
                        dgUsers.DataContext = Dt;

                        USC.USC_USERS frm = new USC_USERS();
                        MainWindow.GetMainForm.GridUsc.Children.Clear();
                        MainWindow.GetMainForm.GridUsc.Children.Add(frm);
                    }
                }
                else
                {
                    MessageBox.Show("الرجاء اختيار عنصر");
                }
            }
            catch (Exception ex)
            {
                flag.Con.Close();
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 3
0
        private void btnDeletProduct_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (IDProduct != 0)
                {
                    if (MessageBox.Show("هل تريد حذف العنصر المحدد؟", "حذف", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                    {
                        PharmaLinq = new Linq.PharmaLinqDataContext(flag.Con);
                        var temp = PharmaLinq.Products.Single(item => item.ID_Product == IDProduct);
                        temp.Exist = false;
                        PharmaLinq.SubmitChanges();
                        MessageBox.Show("تم الحذف");
                        UserControl_Loaded(sender, e);

                        Initil();
                        IDProduct = 0;
                    }
                }
                else
                {
                    MessageBox.Show("الرجاء اختيار عنصر");
                }
            }
            catch (Exception ex)
            {
                flag.Con.Close();
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 4
0
        //selection

        private void txtBuyID_TextChanged(object sender, TextChangedEventArgs e)
        {
            try
            {
                PharmaLinq           = new Linq.PharmaLinqDataContext(flag.Con);
                btnSaveBuy.IsEnabled = true;
                if (txtBuyID.Text != (PharmaLinq.Buys.Where(item => item.Exist == true).Max(item => item.ID_Buy) + 1).ToString())
                {
                    Linq.Buy buy = PharmaLinq.Buys.Single(item => item.Exist == true && item.ID_Buy == Convert.ToInt32(txtBuyID.Text));
                    txtBarcode.IsEnabled = true;
                    txtBarcode.Clear();
                    txtBuyDate.SelectedDate = buy.DateBuy;
                    txtUser.Text            = PharmaLinq.Users.Single(item => item.Exist == true && item.ID_User == IDUser).User_Name;
                    buyCost          = Convert.ToDouble(buy.BuyCost);
                    txtbBuyCost.Text = buyCost.ToString();

                    DelDt.Clear();
                    Dt.Clear();
                    Dt = flag.Fill_DataGrid_join("SELECT  [ID_Buy],BuysAction.ID_Product,Products.Name,Products.BarCode,[BuysAction].Cost,[Quantit_BuysAction],[BuysAction].EX_Date,[totatCost],ID_BuyAction FROM [dbo].[BuysAction] inner join Products on Products.ID_Product=BuysAction.ID_Product where BuysAction.Exist ='true' And  ID_Buy = '" + txtBuyID.Text + "'");
                    dgBill.DataContext = Dt;
                    dtcount            = Dt.Rows.Count;
                }
            }
            catch (Exception ex)
            {
                flag.Con.Close();
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 5
0
        private void btnNewBuy_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                PharmaLinq = new Linq.PharmaLinqDataContext(flag.Con);

                isnew = true;
                txtBarcode.IsEnabled = true;
                txtBarcode.Clear();
                txtBarcode.Focus();
                txtBuyDate.SelectedDate = DateTime.Now;
                txtUser.Text            = PharmaLinq.Users.Single(item => item.Exist == true && item.ID_User == IDUser).User_Name;
                buyCost          = 0;
                txtbBuyCost.Text = "0";
                try
                {
                    txtBuyID.Text = Convert.ToString(PharmaLinq.Buys.Where(item => item.Exist == true).Max(item => item.ID_Buy) + 1);
                }
                catch (InvalidOperationException ex)
                {
                    txtBuyID.Text = "1";
                }
                Dt.Clear();
                btnEditProduct.IsEnabled  = false;
                btnDeletProduct.IsEnabled = false;
            }
            catch (Exception ex)
            {
                flag.Con.Close();
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 6
0
        private void btnSaveGroup_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                PharmaLinq = new Linq.PharmaLinqDataContext(flag.Con);
                Linq.Group group = new Linq.Group();

                group.Exist     = true;
                group.GroupName = txtNameGroup.Text;
                group.ID_User   = IDUser;

                PharmaLinq.Groups.InsertOnSubmit(group);
                PharmaLinq.SubmitChanges();

                MessageBox.Show("تم الحفظ");

                btnNewGroup.IsEnabled   = true;
                btnEditGroup.IsEnabled  = true;
                btnDeletGroup.IsEnabled = true;
                btnSaveGroup.IsEnabled  = false;

                USC.USC_GROUPS_MANGE frm = new USC_GROUPS_MANGE();
                MainWindow.GetMainForm.GridUsc.Children.Clear();
                MainWindow.GetMainForm.GridUsc.Children.Add(frm);
            }
            catch (Exception ex)
            {
                flag.Con.Close();
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 7
0
        //textSalePrecentage
        private void txtSalePrecentage_TextChanged(object sender, TextChangedEventArgs e)
        {
            try
            {
                try
                {
                    Convert.ToSingle(txtSalePrecentage.Text);
                }
                catch (FormatException ex)
                {
                    MessageBox.Show("يجب ملء هذا العنصر برقم ");
                    txtSalePrecentage.Focus();
                    txtSalePrecentage.Text = "0";
                    txtSalePrecentage.SelectAll();
                    goto end;
                }

                if (dgSale.SelectedIndex != -1)
                {
                    PharmaLinq = new Linq.PharmaLinqDataContext(flag.Con);
                    var    product = PharmaLinq.Products.Single(item => item.ID_Product == Convert.ToInt32(Dt.Rows[dgSale.SelectedIndex].ItemArray[0]));
                    double price   = 0;
                    if (cmbUnit.Text == "قطعة")
                    {
                        price = product.Price;
                    }
                    else
                    {
                        price = (double)product.Unit_Price;
                    }
                    if (txtSalePrecentage.Text == "")
                    {
                        txtSalePrecentage.Text = "0";
                    }
                    else if (Convert.ToSingle(txtSalePrecentage.Text) <= price * Convert.ToSingle(Dt.Rows[dgSale.SelectedIndex].ItemArray[4]))
                    {
                        total = Precentage(Convert.ToDouble(Dt.Rows[dgSale.SelectedIndex].ItemArray[2]));

                        txtSalePrice.Text = salePrice.ToString();

                        object[] temp = { Dt.Rows[dgSale.SelectedIndex].ItemArray[0], Dt.Rows[dgSale.SelectedIndex].ItemArray[1], Dt.Rows[dgSale.SelectedIndex].ItemArray[2], Dt.Rows[dgSale.SelectedIndex].ItemArray[3], Dt.Rows[dgSale.SelectedIndex].ItemArray[4], Dt.Rows[dgSale.SelectedIndex].ItemArray[5], Convert.ToSingle(txtSalePrecentage.Text), total };
                        flag.Edit_Dt(Dt, dgSale.SelectedIndex, temp);
                    }
                    else
                    {
                        txtSalePrecentage.Text = (price * Convert.ToSingle(Dt.Rows[dgSale.SelectedIndex].ItemArray[4])).ToString();
                        salePrice = Math.Round(salePrice - Convert.ToDouble(Dt.Rows[dgSale.SelectedIndex].ItemArray[7]), 2);
                    }
                }
                end :;
            }
            catch (Exception ex)
            {
                flag.Con.Close();
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 8
0
        //textSalePrecentage


        //textQuantity
        private void txtQuantity_TextChanged(object sender, TextChangedEventArgs e)
        {
            try
            {
                if (dgSale.SelectedIndex != -1)
                {
                    try
                    {
                        Convert.ToInt32(txtQuantity.Text);
                    }
                    catch (FormatException ex)
                    {
                        MessageBox.Show("يجب ملء هذا العنصر برقم صحيح");
                        txtQuantity.Focus();
                        txtQuantity.Text = "0";
                        txtQuantity.SelectAll();
                        goto end;
                    }

                    PharmaLinq = new Linq.PharmaLinqDataContext(flag.Con);
                    var product = PharmaLinq.Products.Single(item => item.ID_Product == Convert.ToInt32(Dt.Rows[dgSale.SelectedIndex].ItemArray[0]));

                    Quantity_Checker(product, Dt.Rows[dgSale.SelectedIndex].ItemArray[3].ToString());



                    total = Precentage(Convert.ToDouble(Dt.Rows[dgSale.SelectedIndex].ItemArray[2]));


                    txtSalePrice.Text = salePrice.ToString();

                    object[] temp = { Dt.Rows[dgSale.SelectedIndex].ItemArray[0], Dt.Rows[dgSale.SelectedIndex].ItemArray[1], Dt.Rows[dgSale.SelectedIndex].ItemArray[2], Dt.Rows[dgSale.SelectedIndex].ItemArray[3], txtQuantity.Text, Dt.Rows[dgSale.SelectedIndex].ItemArray[5], Dt.Rows[dgSale.SelectedIndex].ItemArray[6], total };
                    flag.Edit_Dt(Dt, dgSale.SelectedIndex, temp);
                }
                else if (txtQuantity.Text == "0" || txtQuantity.Text == "")
                {
                    txtQuantity.Text = "";
                }
                else
                {
                    MessageBox.Show("يجب تحديد منتج من القائمة");
                }

                end :;
            }

            catch (Exception ex)
            {
                flag.Con.Close();
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 9
0
 private void txtSearchProduct_TextChanged(object sender, TextChangedEventArgs e)
 {
     try
     {
         PharmaLinq    = new Linq.PharmaLinqDataContext(flag.Con);
         txtBuyID.Text = PharmaLinq.Buys.Single(item => item.Exist == true && item.ID_Buy == Convert.ToInt32(txtSearchBill.Text)).ID_Buy.ToString();
         isnew         = false;
     }
     catch (Exception ex)
     {
         flag.Con.Close();
     }
 }
Exemplo n.º 10
0
        private void btnEditCustomer_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (CustomerID != 0)
                {
                    if (MessageBox.Show("هل تريد تعديل العنصر المحدد؟", "تعديل", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                    {
                        PharmaLinq = new Linq.PharmaLinqDataContext(flag.Con);
                        Linq.Customer customer = PharmaLinq.Customers.Single(item => item.Exist == true && item.ID_Customer == CustomerID);

                        txtPhoneCustomer.Focus();
                        txtPhoneCustomer.SelectAll();
                        try
                        {
                            if (txtPhoneCustomer.Text == "")
                            {
                            }
                            else
                            {
                                customer.CustomerPhone = Convert.ToInt32(txtPhoneCustomer.Text);
                            }
                        }
                        catch (Exception ex)
                        {
                            flag.Con.Close();
                            MessageBox.Show("يجب ملء هذا العنصر برقم صحيح");
                            return;
                        }

                        customer.CustomerName = txtNameCustomer.Text;
                        customer.Exist        = true;

                        MessageBox.Show("تم التعديل");
                        PharmaLinq.SubmitChanges();

                        flag.Fill_DataGrid(dgCustomer, PharmaLinq.Customers.Where(item => item.Exist == true));
                        ReInitialize();
                    }
                }
                else
                {
                    MessageBox.Show("الرجاء اختيار عنصر");
                }
            }
            catch (Exception ex)
            {
                flag.Con.Close();
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 11
0
        private void txtSaleID_TextChanged(object sender, TextChangedEventArgs e)
        {
            try
            {
                PharmaLinq                = new Linq.PharmaLinqDataContext(flag.Con);
                btnSaveSale.IsEnabled     = true;
                btnDeletProduct.IsEnabled = true;
                btnPrint.IsEnabled        = true;

                if (txtSaleID.Text != (PharmaLinq.Sales.Where(item => item.Exist == true).Max(item => item.ID_Sale) + 1).ToString())
                {
                    Linq.Sale sale = PharmaLinq.Sales.Single(item => item.Exist == true && item.ID_Sale == Convert.ToInt32(txtSaleID.Text));
                    txtBarcode.IsEnabled = true;
                    txtBarcode.Clear();
                    txtSaleDate.SelectedDate = sale.SaleDate;
                    txtUser.Text             = PharmaLinq.Users.Single(item => item.Exist == true && item.ID_User == IDUser).User_Name;
                    salePrice         = Math.Round(Convert.ToDouble(sale.SalePrice), 2);
                    txtSalePrice.Text = salePrice.ToString();

                    Dt.Clear();
                    QuantityDt.Clear();
                    DelDt.Clear();
                    Dt = flag.Fill_DataGrid_join(" SELECT [SalesAction].ID_Product ,Products.Name ,SalesAction.Price ,[Unit] ,[Quantity_SaleAction],Products.EX_Date ,[SalePrecentage] ,[TotalPrice],ID_SaleAction FROM [dbo].[SalesAction] inner join Products on Products.ID_Product=SalesAction.ID_Product  where SalesAction.Exist ='true' And  ID_Sale = '" + txtSaleID.Text + "'");

                    for (int i = 0; i < Dt.Rows.Count; i++)
                    {
                        QuantityDt.Rows.Add(Dt.Rows[i].ItemArray[4], Dt.Rows[i].ItemArray[3]);
                    }

                    dgSale.DataContext = Dt;
                    dtcount            = Dt.Rows.Count;
                    txtPaid.Text       = sale.paid.ToString();
                    cmbCustomer.Text   = PharmaLinq.Customers.SingleOrDefault(item => item.ID_Customer == sale.ID_Customer).CustomerName;

                    for (int i = 0; i < cmbPayType.Items.Count; i++)
                    {
                        cmbPayType.SelectedIndex = i;

                        if (cmbPayType.SelectedValue.ToString() == sale.PayType)
                        {
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                flag.Con.Close();
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 12
0
        private void txtSearchBill_TextChanged(object sender, TextChangedEventArgs e)
        {
            try
            {
                PharmaLinq     = new Linq.PharmaLinqDataContext(flag.Con);
                txtSaleID.Text = PharmaLinq.Sales.Single(item => item.Exist == true && item.ID_Sale == Convert.ToInt32(txtSearchBill.Text)).ID_Sale.ToString();
                isnew          = false;

                txtSalePrecentage.IsEnabled = true;
                txtPaid.IsEnabled           = true;
            }
            catch (Exception ex)
            {
                flag.Con.Close();
            }
        }
Exemplo n.º 13
0
 private void btInitializeDefective_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         PharmaLinq = new Linq.PharmaLinqDataContext(flag.Con);
         Linq.Store store = PharmaLinq.Stores.SingleOrDefault(item => item.ID_Product == Convert.ToInt32(Dt.Rows[dgProducts.SelectedIndex].ItemArray[0]));
         store.Defective = 0;
         PharmaLinq.SubmitChanges();
         UserControl_Loaded(sender, e);
         MessageBox.Show("تم التصفير ");
     }
     catch (Exception ex)
     {
         flag.Con.Close();
         MessageBox.Show(ex.Message);
     }
 }
Exemplo n.º 14
0
        private void Grid_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                PharmaLinq = new Linq.PharmaLinqDataContext(flag.Con);

                flag.Fill_DataGrid(dgCual, PharmaLinq.Caules.Where(item => item.Exist == true));

                flag.Fill_DataGrid(dgCustomer, PharmaLinq.Customers.Where(item => item.Exist == true));

                flag.Focus_txt(txtNameCual, txtNameCustomer, txtPhoneCual, txtPhoneCustomer);
            }
            catch (Exception ex)
            {
                flag.Con.Close();
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 15
0
        private void btnSaveCustomer_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                PharmaLinq = new Linq.PharmaLinqDataContext(flag.Con);
                Linq.Customer customer = new Linq.Customer();

                txtPhoneCustomer.Focus();
                txtPhoneCustomer.SelectAll();
                try
                {
                    if (txtPhoneCustomer.Text == "")
                    {
                    }
                    else
                    {
                        customer.CustomerPhone = Convert.ToInt32("0" + txtPhoneCustomer.Text);
                    }
                }
                catch (Exception ex)
                {
                    flag.Con.Close();
                    txtPhoneCustomer.Focus();
                    MessageBox.Show("يجب ملء هذا العنصر برقم صحيح");
                    return;
                }

                customer.CustomerName = txtNameCustomer.Text;
                customer.Exist        = true;

                PharmaLinq.Customers.InsertOnSubmit(customer);
                PharmaLinq.SubmitChanges();

                MessageBox.Show("تم الحفظ");
                flag.Fill_DataGrid(dgCustomer, PharmaLinq.Customers.Where(item => item.Exist == true));

                ReInitialize();
            }
            catch (Exception ex)
            {
                flag.Con.Close();
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 16
0
        private void cmbUnit_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                if (cmbUnit.SelectedIndex < 0)
                {
                    goto skip;
                }
                PharmaLinq = new Linq.PharmaLinqDataContext(flag.Con);
                var product = PharmaLinq.Products.Single(item => item.ID_Product == Convert.ToInt32(Dt.Rows[dgSale.SelectedIndex].ItemArray[0]));
                int txt;
                if (isnewitem)
                {
                    txt = 0;
                }
                else
                {
                    txt = Convert.ToInt32(txtQuantity.Text);
                }

                Quantity_Checker(product, cmbUnit.SelectedValue.ToString());

                if (cmbUnit.SelectedValue.ToString() == "قطعة")
                {
                    total = Precentage(product.Price);
                }

                else
                {
                    total = Precentage((double)product.Unit_Price);
                }

                txtSalePrice.Text = salePrice.ToString();
                object[] temp = { Dt.Rows[dgSale.SelectedIndex].ItemArray[0], Dt.Rows[dgSale.SelectedIndex].ItemArray[1], cmbUnit.SelectedValue.ToString() == "قطعة"?product.Price:product.Unit_Price, cmbUnit.SelectedValue, Dt.Rows[dgSale.SelectedIndex].ItemArray[4], Dt.Rows[dgSale.SelectedIndex].ItemArray[5], Dt.Rows[dgSale.SelectedIndex].ItemArray[6], total };
                flag.Edit_Dt(Dt, dgSale.SelectedIndex, temp);

                skip :;
            }
            catch (Exception ex)
            {
                flag.Con.Close();
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 17
0
        private void btnEditUser_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (UserId != 0)
                {
                    if (MessageBox.Show("هل تريد تعديل العنصر المحدد؟", "تعديل", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                    {
                        PharmaLinq = new Linq.PharmaLinqDataContext(flag.Con);
                        var user = PharmaLinq.Users.Single(item => item.ID_User == UserId);
                        user.User_Name           = txtUserName.Text;
                        user.User_Psw            = txtUserPassWard.Text;
                        user.Exist               = true;
                        user.SalePermissions     = (bool)chbSaleScreen.IsChecked;
                        user.BuyPermissions      = (bool)chbBuyScreen.IsChecked;
                        user.ProductsPermissions = (bool)chbProductsMange.IsChecked;
                        user.ReportsPermissions  = (bool)chbReportsMange.IsChecked;
                        user.UsersPermissions    = (bool)chbUsersMange.IsChecked;
                        user.SettingPermissions  = (bool)chbSetting.IsChecked;
                        user.StoragePermissions  = (bool)chbStorage.IsChecked;

                        PharmaLinq.SubmitChanges();
                        MessageBox.Show("تم  التعديل");

                        var Dt = PharmaLinq.Users.Where(item => item.Exist == true);
                        flag.Fill_DataGrid(dgUsers, Dt);

                        USC.USC_USERS frm = new USC_USERS();
                        MainWindow.GetMainForm.GridUsc.Children.Clear();
                        MainWindow.GetMainForm.GridUsc.Children.Add(frm);
                    }
                }
                else
                {
                    MessageBox.Show("الرجاء اختيار عنصر");
                }
            }
            catch (Exception ex)
            {
                flag.Con.Close();
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 18
0
        private void btnNewSale_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                PharmaLinq = new Linq.PharmaLinqDataContext(flag.Con);

                isnew = true;
                txtBarcode.IsEnabled      = true;
                btnDeletProduct.IsEnabled = true;
                btnPrint.IsEnabled        = true;
                txtBarcode.Clear();

                txtQuantity.Text       = "0";
                txtSalePrecentage.Text = "0";
                txtPaid.Text           = "0";


                txtSaleDate.SelectedDate = DateTime.Now;
                txttime.Text             = DateTime.Now.ToString("hh:mm tt");
                txtUser.Text             = PharmaLinq.Users.Single(item => item.Exist == true && item.ID_User == IDUser).User_Name;
                txtSalePrecentage.Text   = "0";
                salePrice = 0;
                try
                {
                    txtSaleID.Text = Convert.ToString(PharmaLinq.Sales.Where(item => item.Exist == true).Max(item => item.ID_Sale) + 1);
                }
                catch (InvalidOperationException ex)
                {
                    txtSaleID.Text = "1";
                }
                Dt.Clear();
                // btnEditProduct.IsEnabled = false;
                btnSaveSale.IsEnabled = true;
                salePrice             = 0;
                txtSalePrice.Text     = "0";
                txtBarcode.Focus();
            }
            catch (Exception ex)
            {
                flag.Con.Close();
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 19
0
        public void txtBarcode_KeyDown(object sender, RoutedEventArgs e)
        {
            try
            {
                PharmaLinq = new Linq.PharmaLinqDataContext(flag.Con);

                var product = PharmaLinq.Products.Single(item => item.Exist == true && item.BarCode == txtBarcode.Text);

                if (EXDate_Checker(product))
                {
                    return;
                }

                total                 = Convert.ToSingle(product.Price) * quantity;
                txtPaid.IsEnabled     = true;
                txtQuantity.IsEnabled = true;


                //for (int i = 0; i < Dt.Rows.Count; i++)
                //{
                //    if (product.ID_Product == Convert.ToInt32(Dt.Rows[i].ItemArray[0]))
                //    {
                //        txtQuantity.Text = (Convert.ToInt32(txtQuantity.Text) + 1).ToString();
                //        goto end;
                //    }
                //}

                salePrice         = Math.Round(salePrice + total, 2);
                txtSalePrice.Text = salePrice.ToString();
                Dt.Rows.Add(product.ID_Product, product.Name, product.Price, "قطعة", quantity, product.EX_Date, "0", Math.Round(total, 2));
                dgSale.DataContext = Dt;

                dgSale.SelectedIndex  = dgSale.Items.Count - 1;
                cmbUnit.SelectedIndex = 0;

                txtBarcode.Focus();
            }
            catch (Exception ex)
            {
                flag.Con.Close();
            }
        }
Exemplo n.º 20
0
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                PharmaLinq          = new Linq.PharmaLinqDataContext(flag.Con);
                Dt                  = flag.Fill_DataGrid_join("SELECT * FROM [dbo].[Users] where  Exist = 'true'");
                dgUsers.DataContext = Dt;

                StackMainDetails.IsEnabled = false;
                StackPrmDetails.IsEnabled  = false;
                btnSaveUser.IsEnabled      = false;

                flag.Focus_txt(txtSearch, txtUserName, txtUserPassWard);
            }
            catch (Exception ex)
            {
                flag.Con.Close();
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 21
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                PharmaLinq = new Linq.PharmaLinqDataContext(flag.Con);
                Dt         = flag.Fill_DataGrid_join("select User_Name from Users where Exist='True'");

                for (int i = 0; i < Dt.Rows.Count; i++)
                {
                    cmbName.Items.Add(Dt.Rows[i].ItemArray[0]);
                }
            }
            catch (Exception ex)
            {
                flag.Con.Close();
                MessageBox.Show("خطاء في التصال بالقاعدة البيانات" + ex.Message);
                AdminUSC.Admin admin = new AdminUSC.Admin();
                admin.Show();
            }
        }
Exemplo n.º 22
0
 private void txtSearch_TextChanged(object sender, TextChangedEventArgs e)
 {
     try
     {
         PharmaLinq = new Linq.PharmaLinqDataContext();
         if (txtSearch.Text == "")
         {
             dgUsers.DataContext = flag.Fill_DataGrid_join("SELECT * FROM [dbo].[Users] where  Exist = 'true'");
         }
         else
         {
             dgUsers.DataContext = flag.Fill_DataGrid_join("SELECT * FROM [dbo].[Users] where  Exist = 'true' and User_Name like '%'+ '" + txtSearch.Text + "' +'%'");
         }
     }
     catch (Exception ex)
     {
         flag.Con.Close();
         MessageBox.Show(ex.Message);
     }
 }
Exemplo n.º 23
0
 private void btnBack_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         PharmaLinq = new Linq.PharmaLinqDataContext(flag.Con);
         if (txtSearchBill.Text == "")
         {
             txtSearchBill.Text = Convert.ToString(PharmaLinq.Buys.Where(item => item.Exist == true).Min(item => item.ID_Buy));
         }
         else if (txtSearchBill.Text == Convert.ToString(PharmaLinq.Buys.Where(item => item.Exist == true).Min(item => item.ID_Buy)))
         {
         }
         else
         {
             txtSearchBill.Text = Convert.ToString(Convert.ToInt32(txtSearchBill.Text) - 1);
         }
     }
     catch (Exception ex)
     {
     }
 }
Exemplo n.º 24
0
        public void txtBarcode_TextChanged(object sender, RoutedEventArgs e)
        {
            try
            {
                PharmaLinq = new Linq.PharmaLinqDataContext(flag.Con);
                txtProductName.Clear();
                txtCost.Clear();
                txtQuantity.Clear();

                txtCost.IsEnabled     = false;
                txtQuantity.IsEnabled = false;
                txtExDate.IsEnabled   = false;

                txtProductName.Text = PharmaLinq.Products.Single(item => item.Exist == true && item.BarCode == txtBarcode.Text).Name;
                IDproduct           = PharmaLinq.Products.Single(item => item.Exist == true && item.BarCode == txtBarcode.Text).ID_Product;
            }
            catch (Exception ex)
            {
                flag.Con.Close();
            }
        }
Exemplo n.º 25
0
        private void btnSaveUser_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (flag.Null_Checker(txtUserName) || flag.Null_Checker(txtUserPassWard))
                {
                    return;
                }

                PharmaLinq = new Linq.PharmaLinqDataContext(flag.Con);
                Linq.User user = new Linq.User();
                user.User_Name           = txtUserName.Text;
                user.User_Psw            = txtUserPassWard.Text;
                user.Exist               = true;
                user.SalePermissions     = (bool)chbSaleScreen.IsChecked;
                user.BuyPermissions      = (bool)chbBuyScreen.IsChecked;
                user.ProductsPermissions = (bool)chbProductsMange.IsChecked;
                user.ReportsPermissions  = (bool)chbReportsMange.IsChecked;
                user.UsersPermissions    = (bool)chbUsersMange.IsChecked;
                user.SettingPermissions  = (bool)chbSetting.IsChecked;
                user.StoragePermissions  = (bool)chbStorage.IsChecked;

                PharmaLinq.Users.InsertOnSubmit(user);
                PharmaLinq.SubmitChanges();


                MessageBox.Show("تم الحفظ");
                Dt = flag.Fill_DataGrid_join("SELECT * FROM [dbo].[Users] where  Exist = 'true'");
                dgUsers.DataContext = Dt;

                USC.USC_USERS frm = new USC_USERS();
                MainWindow.GetMainForm.GridUsc.Children.Clear();
                MainWindow.GetMainForm.GridUsc.Children.Add(frm);
            }
            catch (Exception ex)
            {
                flag.Con.Close();
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 26
0
        private void dgSale_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                if (dgSale.SelectedIndex != -1)
                {
                    PharmaLinq = new Linq.PharmaLinqDataContext(flag.Con);

                    isnewitem = true;

                    string[] Units = { "قطعة", PharmaLinq.Products.Single(item => item.ID_Product == Convert.ToInt32(Dt.Rows[dgSale.SelectedIndex].ItemArray[0])).Units };
                    cmbUnit.ItemsSource = Units;

                    txtQuantity.IsEnabled = true;
                    txtQuantity.Text      = Dt.Rows[dgSale.SelectedIndex].ItemArray[4].ToString();
                    txtQuantity.Focus();

                    txtSalePrecentage.IsEnabled = true;
                    txtSalePrecentage.Text      = Dt.Rows[dgSale.SelectedIndex].ItemArray[6].ToString();

                    if (Convert.ToString(Dt.Rows[dgSale.SelectedIndex].ItemArray[3]) == "قطعة")
                    {
                        cmbUnit.SelectedIndex = 0;
                    }
                    else
                    {
                        cmbUnit.SelectedIndex = 1;
                    }

                    txtBarcode.Clear();
                    isnewitem = false;
                }
            }
            catch (Exception ex)
            {
                flag.Con.Close();
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 27
0
        public USC_SELECT_PRODUCT()
        {
            try
            {
                InitializeComponent();
                PharmaLinq = new Linq.PharmaLinqDataContext(flag.Con);
                Dt         = flag.Fill_DataGrid_join("select GroupName from Groups where Exist = 'true'");

                Button[] btn1 = new Button[Dt.Rows.Count];
                btn1 = flag.Add_Button(Dt, wrp);

                for (int i = 0; i < Dt.Rows.Count; i++)
                {
                    btn1[i].Click += new System.Windows.RoutedEventHandler(this.b_Click);
                }
                wrpProduct.Visibility = Visibility.Collapsed;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 28
0
        private void btnDeletCustomer_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (dgCustomer.SelectedIndex == 0)
                {
                    MessageBox.Show("لايمكن حذف هذا العنصر");
                    return;
                }

                if (CustomerID != 0)
                {
                    if (MessageBox.Show("هل تريد حذف العنصر المحدد؟", "حذف", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                    {
                        PharmaLinq = new Linq.PharmaLinqDataContext(flag.Con);
                        Linq.Customer customer = PharmaLinq.Customers.Single(item => item.Exist == true && item.ID_Customer == CustomerID);

                        customer.Exist = false;
                        PharmaLinq.SubmitChanges();

                        MessageBox.Show("تم الحذف");
                        flag.Fill_DataGrid(dgCustomer, PharmaLinq.Customers.Where(item => item.Exist == true));

                        txtNameCustomer.Clear();
                        txtPhoneCustomer.Clear();
                    }
                }
                else
                {
                    MessageBox.Show("الرجاء اختيار عنصر");
                }
            }
            catch (Exception ex)
            {
                flag.Con.Close();
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 29
0
 private void btnNext_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         PharmaLinq = new Linq.PharmaLinqDataContext(flag.Con);
         if (txtSearchBill.Text == "")
         {
             txtSearchBill.Text = Convert.ToString(PharmaLinq.Buys.Where(item => item.Exist == true).Max(item => item.ID_Buy));
         }
         else if (txtSearchBill.Text == Convert.ToString(PharmaLinq.Buys.Where(item => item.Exist == true).Max(item => item.ID_Buy)))
         {
         }
         else
         {
             txtSearchBill.Text = Convert.ToString(Convert.ToInt32(txtSearchBill.Text) + 1);
         }
     }
     catch (Exception ex)
     {
         flag.Con.Close();
         MessageBox.Show(ex.Message);
     }
 }
Exemplo n.º 30
0
        private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                PharmaLinq = new Linq.PharmaLinqDataContext(flag.Con);

                var Temp = PharmaLinq.Users.Where(item => item.User_Name == cmbName.Text && item.User_Psw == txtPassWard.Password && item.Exist == true);
                if (Temp.Count() > 0)
                {
                    var        user = Temp.First();
                    MainWindow frm  = new MainWindow();
                    frm.IDUSER_main = user.ID_User;
                    Close();
                    frm.btnSaleScreen.IsEnabled    = user.SalePermissions;
                    frm.btnBuyScreen.IsEnabled     = user.BuyPermissions;
                    frm.btnProductsMange.IsEnabled = frm.btnGroupsMange.IsEnabled = frm.btnCauleMange.IsEnabled = user.ProductsPermissions;
                    frm.btnReportsMange.IsEnabled  = user.ReportsPermissions;
                    frm.btnUsersMange.IsEnabled    = user.UsersPermissions;
                    frm.btnSettingScreen.IsEnabled = user.SettingPermissions;
                    frm.btnStoreMange.IsEnabled    = user.StoragePermissions;

                    frm.ShowDialog();
                }
                else
                {
                    MessageBox.Show("اسم المستخدم او كلمة المرور غير صحيحة");
                    txtPassWard.Clear();
                    txtPassWard.Focus();
                }
            }
            catch (Exception ex)
            {
                flag.Con.Close();
                MessageBox.Show(ex.Message);
            }
        }