Beispiel #1
0
        /// <summary>
        /// adding item to order
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonOrderItemsInOrderTab_Click(object sender, EventArgs e)
        {
            if (textBoxOrderNumberInOrderTab.Text == "" || !(comboBoxOrderItemsInAddOrderTab.SelectedIndex > -1))
            {
                MessageBox.Show("please enter value by double click on the order \n Or choosing product");
            }
            else
            {
                using (testDBEntities db = new testDBEntities())
                {
                    t_Items item = db.t_Items.Where(x => x.ItemDescription.Equals(comboBoxOrderItemsInAddOrderTab.Text)).FirstOrDefault();
                    model_OrdersItem.t_Items = item;
                    t_Orders order = db.t_Orders.Where(x => x.ID == model_t_Orders.ID).FirstOrDefault();

                    long order_id = order.ID;

                    model_OrdersItem.t_Orders = order;
                    db.OrdersItems.Add(model_OrdersItem);
                    db.SaveChanges();

                    evalTotalAmount(order_id);
                    ClearDataGridView_t_Orders();
                    populateDataGridView_t_Orders();
                    MessageBox.Show("Added Successfully");
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// insering value to textbos depending on double click on datagrid
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dataGridViewItems_DoubleClick(object sender, EventArgs e)
        // poplate text box when data grid being pressed
        {
            if (dataGridViewItems.CurrentRow.Index != -1)
            {
                model_t_Items.ID = Convert.ToInt32(dataGridViewItems.CurrentRow.Cells["ID"].Value);
                using (testDBEntities db = new testDBEntities())
                {
                    model_t_Items = db.t_Items.Where(x => x.ID == model_t_Items.ID).FirstOrDefault();

                    textBoxItemsAmount.Text     = model_t_Items.ItemAmount.ToString();
                    textBoxItemsPrice.Text      = model_t_Items.ItemPrice.ToString();
                    comboBoxMeasuremntUnit.Text = model_t_Items.ItemU_M.ToString();
                    richTextBoxItemsDesc.Text   = model_t_Items.ItemDescription.ToString();
                }
            }
        }