Beispiel #1
0
        private void order_aply_btn_Click(object sender, RoutedEventArgs e)
        {
            int sp = 0;
            List <order_details> lstp = db1.order_details.ToList();

            foreach (order_details p in lstp)
            {
                sp += (p.products.price * p.quantity);
            }
            if (sp == 0)
            {
                MessageBox.Show("you have not choose any product", "Error", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            else
            {
                string notes = notes_txb.Text;
                ordr.notes        = notes;
                ordr.company_name = supplier_name_txb.Text;
                ordr.date         = DateTime.Now;
                client_or_supplier client_Or_Supplier = db1.client_or_supplier.ToArray()[1];
                ordr.c_or_s_id          = 2;
                ordr.client_or_supplier = client_Or_Supplier;
                this.Close();
                checkSupplier chk = new checkSupplier(db1, order_details_dtgrid, ordr);
                chk.ShowDialog();
            }
        }
Beispiel #2
0
 private void cntue_Click(object sender, RoutedEventArgs e)
 {
     if (client_name_txb.Text != "" && emp.Id != 0)
     {
         List <order_details> lst_p = db1.order_details.ToList();
         foreach (order_details p in lst_p)
         {
             db1.order_details.Remove(p);
             db1.SaveChanges();
         }
         string c_name = client_name_txb.Text;
         cd.first_name = c_name.Substring(0, c_name.IndexOf(' ') + 1);
         cd.last_name  = c_name.Remove(0, c_name.IndexOf(' ') + 1);
         if (dlvr.IsChecked == true)
         {
             client_info clinf = new client_info(db1, cd);
             clinf.ShowDialog();
         }
         db1.SaveChanges();
         client_or_supplier client_Or_Supplier = db1.client_or_supplier.ToArray()[0];
         order ordr = new order {
             c_or_s_id = 1, client_or_supplier = client_Or_Supplier, employee = emp, client_details = cd
         };
         newOrder newOrder = new newOrder(db1, ordr, dlvr.IsChecked == true);
         this.Close();
         newOrder.ShowDialog();
         lst_p = db1.order_details.ToList();
     }
 }
Beispiel #3
0
        private void add_product_btn_Click_1(object sender, RoutedEventArgs e)
        {
            int price;

            if (name_add_product.Text != "" && price_add_product.Text != "" && kind_add_product.SelectedItem != null && (add_sell.IsChecked == true || add_buy.IsChecked == true) && add_prd_pack_lsb.SelectedItem != null)
            {
                if (checking_name(name_add_product.Text))
                {
                    string name = name_add_product.Text;
                    price = Convert.ToInt32(price_add_product.Text);
                    kind_product       kp       = db1.kind_product.ToArray()[kind_add_product.SelectedIndex];
                    client_or_supplier cl_or_sp = new client_or_supplier();
                    int i = 0;
                    if (add_sell.IsChecked == true)
                    {
                        if (add_buy.IsChecked == true)
                        {
                            i        = 2;
                            cl_or_sp = db1.client_or_supplier.ToArray()[i];
                        }
                        else
                        {
                            i        = 0;
                            cl_or_sp = db1.client_or_supplier.ToArray()[i];
                        }
                    }
                    else
                    {
                        if (add_buy.IsChecked == true)
                        {
                            i        = 1;
                            cl_or_sp = db1.client_or_supplier.ToArray()[i];
                        }
                    }
                    products p = new products {
                        name = name, price = price, kind_product = kp, kind_product_id = kind_add_product.SelectedIndex + 1, pack = add_prd_pack_lsb.SelectedItem.ToString().Substring(37), client_or_supplier = cl_or_sp, c_or_s_id = i + 1
                    };
                    db1.products.Add(p);
                    db1.SaveChanges();
                    MessageBox.Show("The product has been added", "Succes", MessageBoxButton.OK, MessageBoxImage.Information);
                    this.Close();
                }
                else
                {
                    MessageBox.Show("The name of the product is already exist in the system", "Error", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
            }
            else
            {
                MessageBox.Show("Fill all the fields", "Error", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
Beispiel #4
0
        private void product_change_btn_Click(object sender, RoutedEventArgs e)
        {
            int price;

            if (pro != null && name_chnge_product.Text != "" && price_chnge_product.Text != "" && kind_chnge_product.SelectedItem != null && (chnge_sell.IsChecked == true || chnge_buy.IsChecked == true) && change_prd_pack_lsb.SelectedItem != null)
            {
                string name = name_chnge_product.Text;
                price = Convert.ToInt32(price_chnge_product.Text);
                kind_product       kp       = db1.kind_product.ToArray()[kind_chnge_product.SelectedIndex];
                client_or_supplier cl_or_sp = new client_or_supplier();
                int i = 0;
                if (chnge_sell.IsChecked == true)
                {
                    if (chnge_buy.IsChecked == true)
                    {
                        i        = 2;
                        cl_or_sp = db1.client_or_supplier.ToArray()[i];
                    }
                    else
                    {
                        i        = 0;
                        cl_or_sp = db1.client_or_supplier.ToArray()[i];
                    }
                }
                else
                {
                    if (chnge_buy.IsChecked == true)
                    {
                        i        = 1;
                        cl_or_sp = db1.client_or_supplier.ToArray()[i];
                    }
                }
                pro.name               = name;
                pro.price              = price;
                pro.kind_product       = kp;
                pro.kind_product_id    = kind_chnge_product.SelectedIndex + 1;
                pro.pack               = change_prd_pack_lsb.SelectedItem.ToString().Substring(37);
                pro.client_or_supplier = cl_or_sp;
                pro.c_or_s_id          = i + 1;
                db1.SaveChanges();
                MessageBox.Show("The product has been changed", "Succes", MessageBoxButton.OK, MessageBoxImage.Information);
                this.Close();
            }
            else
            {
                MessageBox.Show("Fill all the fields", "Error", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }