Beispiel #1
0
 public void editItemU_M(string itemU_M, TextBox textBox_ItemU_M, DataGridView dataGridView_U_M)
 {
     model_t_ItemU_M.ItemU_M = itemU_M;
     using (testDBEntities db = new testDBEntities())
     {
         db.Entry(model_t_ItemU_M).State = EntityState.Modified;
         db.SaveChanges();
     }
     ClearDataGridView_t_ItemU_M(textBox_ItemU_M);
     populateDataGridView_t_ItemU_M(dataGridView_U_M);
     MessageBox.Show("Submitted Successfully");
 }
Beispiel #2
0
        /// <summary>
        /// editng item on items  table
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonItemsEdit_Click(object sender, EventArgs e)
        {
            model_t_Items.ItemAmount      = Convert.ToDecimal(textBoxItemsAmount.Text.Trim());
            model_t_Items.ItemPrice       = Convert.ToDecimal(textBoxItemsPrice.Text.Trim());
            model_t_Items.ItemU_M         = comboBoxMeasuremntUnit.Text.Trim();
            model_t_Items.ItemDescription = richTextBoxItemsDesc.Text.Trim();

            using (testDBEntities db = new testDBEntities())
            {
                db.Entry(model_t_Items).State = EntityState.Modified;
                db.SaveChanges();
            }
            ClearDataGridView_t_Items();
            populateDataGridViewItems();
            MessageBox.Show("Submitted Successfully");
        }
Beispiel #3
0
        /// <summary>
        /// editing order
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonOrdersEdit_Click(object sender, EventArgs e)
        {
            model_t_Orders.OrderDate       = Convert.ToDateTime(dateTimePickerOrders.Text.Trim());
            model_t_Orders.CustomerName    = textBoxOrders_CustName.Text.Trim();
            model_t_Orders.CustomerAddress = textBoxOrdersCust_Adress.Text.Trim();
            model_t_Orders.CustomerPhone   = textBoxCustomerPhone.Text.Trim();
            //model_t_Orders.TotalAmount = Convert.ToDecimal(textBoxOrdersToatl.Text.Trim());
            model_t_Orders.RefaundAmount = Convert.ToDecimal(textBoxRefaundAmount.Text.Trim());
            model_t_Orders.CustomerCity  = textBoxOrdersCustomerCity.Text.Trim();

            using (testDBEntities db = new testDBEntities())
            {
                db.Entry(model_t_Orders).State = EntityState.Modified;
                db.SaveChanges();
            }
            populateDataGridView_t_Orders();
            ClearDataGridView_t_Orders();
            MessageBox.Show("Submitted Successfully");
        }
Beispiel #4
0
        /// <summary>
        /// measurement unit editng , need double click on datagrid before to poplate text box's
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button_U_M_Edit_Click(object sender, EventArgs e)
        {
            //ItemU_M_Helper um = new ItemU_M_Helper();
            //um.editItemU_M(textBox_ItemU_M.Text.Trim(), textBox_ItemU_M, dataGridView_U_M);

            model_t_ItemU_M.ItemU_M = textBox_ItemU_M.Text.Trim();
            using (testDBEntities db = new testDBEntities())
            {
                db.Entry(model_t_ItemU_M).State = EntityState.Modified;
                db.SaveChanges();
            }
            ItemU_M_Helper um = new ItemU_M_Helper();

            um.ClearDataGridView_t_ItemU_M(textBox_ItemU_M);
            um.populateDataGridView_t_ItemU_M(dataGridView_U_M);
            //ClearDataGridView_t_ItemU_M();
            //populateDataGridView_t_ItemU_M();
            MessageBox.Show("Submitted Successfully");
        }
Beispiel #5
0
        /// <summary>
        /// evaluting total amount in order after add/del item
        /// </summary>
        /// <param name="order_id"></param>
        private void evalTotalAmount(long order_id)
        {
            using (testDBEntities db = new testDBEntities())
            {
                //MessageBox.Show(m_order_item.t_Orders.ID.ToString());
                List <OrdersItem> all_OrdersItems = db.OrdersItems.Where(x => x.t_Orders.ID == order_id).ToList <OrdersItem>();

                decimal total = 0;
                foreach (OrdersItem order_item in all_OrdersItems)
                {
                    total += (decimal)order_item.t_Items.ItemPrice;
                }

                t_Orders order = db.t_Orders.Where(x => x.ID == order_id).FirstOrDefault();
                order.TotalAmount = total;

                db.Entry(order).State = EntityState.Modified;
                db.SaveChanges();
            }
        }
Beispiel #6
0
        /// <summary>
        /// delete item from db
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonItemsDel_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Are You Sure to Delete this Record ?", "EF CRUD Operation", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                using (testDBEntities db = new testDBEntities())
                {
                    var entry = db.Entry(model_t_ItemU_M);

                    if (entry.State == EntityState.Detached)
                    {
                        db.t_Items.Attach(model_t_Items);
                    }
                    db.t_Items.Remove(model_t_Items);
                    db.SaveChanges();
                    populateDataGridViewItems();
                    ClearDataGridView_t_Items();
                    MessageBox.Show("Deleted Successfully");
                }
            }
        }
Beispiel #7
0
        public void Del_U_M_Record(t_ItemU_M model_t_ItemU_M, TextBox textBox_ItemU_M, DataGridView dataGridView_U_M)
        {
            if (MessageBox.Show("Are You Sure to Delete this Record ?", "EF CRUD Operation", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                using (testDBEntities db = new testDBEntities())
                {
                    var entry = db.Entry(model_t_ItemU_M);

                    if (entry.State == EntityState.Detached)
                    {
                        db.t_ItemU_M.Attach(model_t_ItemU_M);
                    }
                    db.t_ItemU_M.Remove(model_t_ItemU_M);
                    db.SaveChanges();
                    ClearDataGridView_t_ItemU_M(textBox_ItemU_M);
                    populateDataGridView_t_ItemU_M(dataGridView_U_M);
                    MessageBox.Show("Deleted Successfully");
                }
            }
        }