예제 #1
0
        private void BtnAdd_Click(object sender, EventArgs e)
        {
            Toast toast   = new Toast();
            Sell  sel_add = new Sell();

            if (txtitemName.Text == "" || TxtCustomerName.Text == "" || numericUpDown1.Value == 0)
            {
                toast.labl_caption.Text = "يجيب ان تدخل البيانات";
                toast.Show();
            }

            else
            {
                if (BtnAdd.Text == "إضافة")
                {
                    sel_add.ItemName   = txtitemName.Text;
                    sel_add.CustomerId = TxtCustomerName.Text;
                    sel_add.SellDate   = DateTime.Parse(txtSellDate.Text);
                    // sel_add.InvoiceId = Convert.ToInt32( txtInvoiceName.Text);
                    sel_add.SellPrice    = float.Parse(txtSell.Text);
                    sel_add.SellQuantity = int.Parse(numericUpDown1.Value.ToString());
                    sel_add.TotalPrrice  = float.Parse(txtTotalPrice.Text);
                    db.Sells.Add(sel_add);

                    int    i      = int.Parse(txtitemName.SelectedValue.ToString());
                    TB_CAT tb_cat = db.TB_CAT.Where(x => x.ID == i).FirstOrDefault();
                    tb_cat.ItemQuantity -= int.Parse(numericUpDown1.Value.ToString());

                    db.SaveChanges();
                    toast.labl_caption.Text = "تم اضافة صنف بيع جديد";
                    toast.Show();
                    this.Close();
                }
                else
                {
                    int i = int.Parse(txtid.Text);
                    sel_add = db.Sells.Where(s => s.Id == i).FirstOrDefault();

                    //sel_add.Id = id;
                    sel_add.ItemName   = txtitemName.Text;
                    sel_add.CustomerId = TxtCustomerName.Text;
                    sel_add.SellDate   = DateTime.Parse(txtSellDate.Text);
                    // sel_add.InvoiceId = int.Parse(txtInvoiceName.Text);
                    sel_add.SellPrice    = float.Parse(txtSell.Text);
                    sel_add.SellQuantity = int.Parse(numericUpDown1.Value.ToString());
                    sel_add.TotalPrrice  = float.Parse(txtTotalPrice.Text);
                    db.SaveChanges();
                    toast.labl_caption.Text = "تم تعديل صنف مبيع جديد";
                    toast.Show();
                    this.Close();
                }
            }
        }
예제 #2
0
        private void btn_add_Click(object sender, EventArgs e)
        {
            Toast toast = new Toast();

            try
            {
                //check
                if (txt_name.Text == "" || txt_price_buy.Text == "" || txt_price_sell.Text == "")
                {
                    toast.labl_caption.Text = "يجيب ان تدخل البيانات";
                    toast.Show();
                }
                else
                {
                    if (id == 0)
                    {
                        //add
                        tb_cat.CAT_Name       = txt_name.Text;
                        tb_cat.CAT_Price_buy  = Convert.ToDouble(txt_price_buy.Text);
                        tb_cat.CAT_Price_sale = Convert.ToDouble(txt_price_sell.Text);
                        tb_cat.ItemQuantity   = int.Parse(numericUpDown1.Value.ToString());
                        tb_cat.TotalBuy       = Convert.ToDouble(txtTotalprice.Text);
                        db.TB_CAT.Add(tb_cat);
                        db.SaveChanges();
                        toast.labl_caption.Text = "تم اضافة صنق جديد";
                        toast.Show();
                        this.Close();
                    }
                    else
                    {
                        //edit
                        tb_cat.ID              = id;
                        tb_cat.CAT_Name        = txt_name.Text;
                        tb_cat.CAT_Price_buy   = Convert.ToDouble(txt_price_buy.Text);
                        tb_cat.CAT_Price_sale  = Convert.ToDouble(txt_price_sell.Text);
                        tb_cat.ItemQuantity    = int.Parse(numericUpDown1.Value.ToString());
                        tb_cat.TotalBuy        = Convert.ToDouble(txtTotalprice.Text);
                        db.Entry(tb_cat).State = System.Data.Entity.EntityState.Modified;
                        db.SaveChanges();
                        toast.labl_caption.Text = "تم تعديل صنق جديد";
                        toast.Show();

                        this.Close();
                    }
                }
            }
            catch
            {
                toast.labl_caption.Text = " برجاء ادخال البيانات صحيحة";
                toast.Show();
            }
        }
예제 #3
0
        private void btn_add_Click(object sender, EventArgs e)
        {
            Toast toast = new Toast();


            if (txt_name.Text == "" && txt_phone.Text == "")
            {
                toast.labl_caption.Text = "  يجيب ان تدخل البيانات صحيحة";
                toast.Show();
            }

            else if (txt_phone.Text.Length < 11)
            {
                toast.labl_caption.Text = " يجيب ان يكون رقم الهاتف صحيح";
                toast.Show();
            }
            else
            {
                if (id == 0)
                {
                    //add
                    tb_sup.Sup_Name  = txt_name.Text;
                    tb_sup.Sup_Phone = txt_phone.Text;
                    //tb_sup.Sup_Start_Date = DateTime.Parse(txt_start.Text.ToString());
                    tb_sup.Sup_Start_Date = dateTimePicker1.Value;
                    db.TB_SUP.Add(tb_sup);
                    db.SaveChanges();
                    toast.labl_caption.Text = "تم اضافة مورد جديد";
                    toast.Show();
                    this.Close();
                }
                else
                {
                    //edit
                    tb_sup.ID             = id;
                    tb_sup.Sup_Name       = txt_name.Text;
                    tb_sup.Sup_Phone      = txt_phone.Text;
                    tb_sup.Sup_Start_Date = DateTime.Parse(dateTimePicker1.Text);


                    db.Entry(tb_sup).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                    toast.labl_caption.Text = "تم تعديل مورد جديد";
                    toast.Show();
                    this.Close();
                }
            }
        }
예제 #4
0
        //delete

        private void btn_delete_Click(object sender, EventArgs e)
        {
            Toast toast = new Toast();

            try
            {
                id = Convert.ToInt32(gridView1.GetFocusedRowCellValue("ID"));
                var res = MessageBox.Show("هل انت متاكد من عملية الحذف", "حذف", MessageBoxButtons.YesNo);
                if (res == DialogResult.Yes)
                {
                    tb_sup = db.TB_SUP.Where(x => x.ID == id).FirstOrDefault();
                    db.Entry(tb_sup).State = EntityState.Deleted;
                    db.SaveChanges();
                    toast.labl_caption.Text = "تم حذف المورد بنجاح";
                    toast.Show();
                    this.Close();
                    //renew tale
                    update_data();
                }
            }
            catch
            {
                MessageBox.Show("يجب تحديد مورد للحذف");
            }
        }
예제 #5
0
파일: Main.cs 프로젝트: Mohamedyousef97/SMP
        private void btn_logout_Click_1(object sender, EventArgs e)
        {
            FRM_LOGIN login = new FRM_LOGIN();


            tb_user = db.TB_Users.Where(x => x.User_State == "True").FirstOrDefault();

            tb_user.User_State      = "Fales";
            db.Entry(tb_user).State = System.Data.Entity.EntityState.Modified;

            db.SaveChanges();

            this.Enabled = false;
            login.Show();
            this.Hide();
        }
예제 #6
0
        private void btn_delete_Click(object sender, EventArgs e)
        {
            Toast toast = new Toast();
            Buyer del   = new Buyer();

            id = Convert.ToInt32(gridView1.GetFocusedRowCellValue("Id"));
            var res = MessageBox.Show("هل انت متأكد من الحذف", "الحذف", MessageBoxButtons.YesNo);

            if (res == DialogResult.Yes)
            {
                del = db.Buyers.Where(s => s.Id == id).FirstOrDefault();
                db.Buyers.Remove(del);
                db.SaveChanges();
                toast.labl_caption.Text = "تم حذف الصنف بنجاح";
                toast.Show();
                this.Close();
                Update_data();
            }

            else
            {
                MessageBox.Show("قم بتحديد للحذف ");
            }
        }
예제 #7
0
        private void BtnAdd_Click(object sender, EventArgs e)
        {
            Toast toast = new Toast();

            try {
                if (txtitemName.Text == "" || txtSuppliersName.Text == "" || numericUpDown1.Value == 0 || txtBuy.Text == "")
                {
                    toast.labl_caption.Text = "يجيب ان تدخل البيانات";
                    toast.Show();
                }
                else
                {
                    if (BtnAdd.Text == "إضافة")
                    {
                        Buyer bu = new Buyer()
                        {
                            name = (txtitemName.Text),

                            SuppliersName = txtSuppliersName.Text,
                            BuyingDate    = this.dateTimePicker1.Value.Date,
                            BuyingPrice   = float.Parse(txtBuy.Text),
                            SellingPrice  = float.Parse(txtSell.Text),
                            Profit        = float.Parse(txtTotalPrice.Text),
                            itemsNumbers  = int.Parse(numericUpDown1.Value.ToString())
                        };
                        db.Buyers.Add(bu);
                        int    i      = int.Parse(txtitemName.SelectedValue.ToString());
                        TB_CAT tb_cat = db.TB_CAT.Where(x => x.ID == i).FirstOrDefault();
                        tb_cat.ItemQuantity += int.Parse(numericUpDown1.Value.ToString());
                        db.SaveChanges();
                        toast.labl_caption.Text = "تم اضافة صنق جديد";
                        toast.Show();
                        this.Close();
                    }
                    else
                    {
                        Buyer buyer_add = new Buyer();
                        int   i         = int.Parse(txtid.Text);
                        buyer_add = db.Buyers.Where(s => s.Id == i).FirstOrDefault();

                        //sel_add.Id = id;
                        buyer_add.name = (txtitemName.Text);

                        buyer_add.SuppliersName = txtSuppliersName.Text;
                        buyer_add.BuyingDate    = this.dateTimePicker1.Value.Date;
                        buyer_add.BuyingPrice   = float.Parse(txtBuy.Text);
                        buyer_add.SellingPrice  = float.Parse(txtSell.Text);
                        buyer_add.Profit        = float.Parse(txtTotalPrice.Text);
                        buyer_add.itemsNumbers  = int.Parse(numericUpDown1.Value.ToString());
                        db.SaveChanges();
                        toast.labl_caption.Text = "تم تعديل صنف مبيع جديد";
                        toast.Show();
                        this.Close();
                    }
                }
            }
            catch
            {
                toast.labl_caption.Text = "برجاء ادخال البيانات صحيحة";
                toast.Show();
            }
        }