Ejemplo n.º 1
0
        private void but_add_Click(object sender, EventArgs e)
        {
            if (tx_address.Text != "" && tx_age.Text != "" && tx_name.Text != "" && tx_password.Text != "" && tx_position.Text != "" && tx_salary.Text != "" && tx_id.Text != "")
            {
                try
                {
                    employee emp = new employee()
                    {
                        address  = tx_address.Text,
                        age      = int.Parse(tx_age.Text),
                        ID_name  = tx_id.Text,
                        password = tx_password.Text,
                        name     = tx_name.Text,
                        salary   = Single.Parse(tx_salary.Text),
                        position = tx_position.Text
                    };
                    db.employees.Add(emp);
                    db.SaveChanges();
                    tx_address.Text = tx_age.Text = tx_name.Text = tx_password.Text = tx_position.Text = tx_salary.Text = tx_id.Text = "";
                }

                catch (Exception r)
                {
                    MessageBox.Show(r.Message);
                }
            }
            else
            {
                lb_validated.Text = "An empty field";
            }
        }
 private void bt_save_Click(object sender, EventArgs e)
 {
     if (tx_cate.Text != "" && tx_DateEX.Text != "" && tx_DateOfPro.Text != "" && tx_importer.Text != "" && tx_name.Text != "" && tx_numbill.Text != "" && tx_priceItem.Text != "" && tx_productprice.Text != "" && tx_qun.Text != "")
     {
         try
         {
             portselling port = new portselling()
             {
                 balance          = int.Parse(tx_balance.Text),
                 phone_importer   = int.Parse(tx_phone.Text),
                 address_importer = tx_address.Text,
                 name_importer    = tx_importer.Text
             };
             Produc product = new Produc()
             {
                 Buy_id             = int.Parse(tx_numbill.Text),
                 ProductPrice       = float.Parse(tx_productprice.Text),
                 ProductQty         = int.Parse(tx_qun.Text),
                 ProductCateg       = tx_cate.Text,
                 item_price         = float.Parse(tx_priceItem.Text),
                 name_importer      = tx_importer.Text,
                 Data_of_expiration = DateTime.Parse(tx_DateEX.Text),
                 ProductName        = tx_name.Text,
             };
             db.Producs.Add(product);
             db.SaveChanges();
         }
         catch (EntitySqlException m)
         {
             MessageBox.Show(m.Message);
         }
     }
 }
Ejemplo n.º 3
0
 private void bt_Save_Click(object sender, EventArgs e)
 {
     if (Productname != null)
     {
         if (tx_DateEX.Text != "" && tx_DateOfPro.Text != "" && tx_importer.Text != "" && tx_numbill.Text != "" && tx_priceItem.Text != "" && tx_productprice.Text != "" && tx_qun.Text != "")
         {
             try
             {
                 var product = db.Producs.Find(Productname);
                 product.Buy_id             = int.Parse(tx_numbill.Text);
                 product.Data_of_expiration = DateTime.Parse(tx_DateEX.Text);
                 product.Data_of_production = DateTime.Parse(tx_DateOfPro.Text);
                 product.item_price         = float.Parse(tx_priceItem.Text);
                 product.name_importer      = tx_importer.Text;
                 product.ProductQty         = int.Parse(tx_qun.Text);
                 product.ProductPrice       = float.Parse(tx_productprice.Text);
                 db.SaveChanges();
             }
             catch (EntitySqlException b)
             {
                 MessageBox.Show(b.Message);
             }
             this.Dispose();
         }
     }
 }
Ejemplo n.º 4
0
        internal void Add_Item()
        {
            NumSave     = 0;
            label3.Text = "";
            if (tx_quantity.Text != "" && cb_category.Text != "" && cb_product.Text != "")
            {
                try
                {
                    Item.billnum   = idBill;
                    Item.item_name = cb_product.Text;
                    Item.itemQty   = int.Parse(tx_quantity.Text);
                    int check = pro.Calculate_quantity(int.Parse(tx_quantity.Text), Item.item_name);
                    if (check == 1)
                    {
                        db.items.Add(Item);
                        db.SaveChanges();
                        Saving_item(Item);
                    }
                    if (check == 0)
                    {
                        db.items.Add(Item);
                        db.SaveChanges();
                        Saving_item(Item);
                        Acc.ItemQUn_0.Add(Item.item_name);
                    }
                    if (check == -1)
                    {
                        label3.ForeColor = Color.Red;
                        label3.Text      = "The Quantity isnot available";
                    }
                    NumSave++;
                }

                catch (Exception e)
                {
                    MessageBox.Show(e.Message);
                }
            }
            else
            {
                label3.Text = "You should enter item";
            }
        }