Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox2.Text == string.Empty)
            {
                label1.Text = "ادخل الكمية صحيحة";
                textBox2.Focus();
                return;
            }
            if (metroComboBox1.SelectedValue == null)
            {
                label1.Text = "اختار منتج صحيح";

                return;
            }
            models.Mabeaat mb = new models.Mabeaat();
            mb.date      = dateTimePicker1.Value;
            mb.Prod_id   = Int32.Parse(metroComboBox1.SelectedValue.ToString());
            mb.togarr_id = Int32.Parse(metroComboBox2.SelectedValue.ToString());
            mb.Status_id = Int32.Parse(metroComboBox3.SelectedValue.ToString());

            mb.Quantity = decimal.Parse(textBox2.Text);
            mb.note     = textBox3.Text;
            decimal price = db.Products.Where(i => i.id == mb.Prod_id).Select(i => i.price).Single();

            mb.Total_price = (price * mb.Quantity);
            ///calculations form
            Calculations cl = new Calculations();

            cl.textBox1.Text = price.ToString();
            cl.textBox2.Text = mb.Quantity.ToString();
            cl.textBox3.Text = mb.Total_price.ToString();
            cl.textBox4.Text = money_done.ToString();

            cl.ShowDialog();
            var mon = cl.textBox4.Text.ToString();

            mb.money_done  = decimal.Parse(mon);
            mb.Total_price = decimal.Parse(cl.textBox3.Text.ToString());
            mb.money_res   = mb.Total_price - mb.money_done;
            ///add to database
            if (button1.Text == "أضافة")
            {
                crd.mabeaat(mb, System.Data.Entity.EntityState.Added);
                MessageBox.Show("تم الاضافة بنجاح");
            }
            else
            {
                mb.id = int.Parse(textBox1.Text);
                crd.mabeaat(mb, System.Data.Entity.EntityState.Modified);
                MessageBox.Show("تم التعديل بنجاح");
            }
            Close();
        }
Пример #2
0
        private void button3_Click(object sender, EventArgs e)
        {
            if ((MessageBox.Show("هل متأكد من حذف العنصر المحدد", "عملية الحذف", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes))
            {
                models.Mabeaat ms = new models.Mabeaat();
                ms.id = Int32.Parse(DataGrid.CurrentRow.Cells[0].Value.ToString());

                crd.mabeaat(ms, System.Data.Entity.EntityState.Deleted);
                fill();
                MessageBox.Show("تم الحذف بنجاح");
            }
        }