Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            int      prodid = int.Parse(textBox1.Text);
            string   itemame = textBox2.Text, categories = comboBox1.Text;
            DateTime expirydate = DateTime.Parse(dateTimePicker1.Text);
            int      price      = int.Parse(txtPrice.Text);

            var st = new ProductInfo_Tab
            {
                ProductID  = prodid,
                itemName   = itemame,
                Price      = price,
                Categories = categories,
                insertDate = DateTime.Now,
                ExpiryDate = expirydate,
            };

            db.ProductInfo_Tab.Add(st);
            db.SaveChanges();
            MessageBox.Show("Succesfully Inserted");
            loadData();
        }
Exemplo n.º 2
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Are you sure to delete ?", "Delete record", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                using (var supermarket = new SuperEntities())
                {
                    var customer_id = txtCustomerID.Text;
                    var fullname    = txtFullName.Text;
                    var email       = txtEmail.Text;
                    var address     = txtAddress.Text;

                    var st = (from s in supermarket.Customers where s.CustomerID == customer_id select s).First();
                    supermarket.Customers.Remove(st);
                    supermarket.SaveChanges();
                    MessageBox.Show("Successfully deleted.");
                    LoadData();
                }
            }
        }
Exemplo n.º 3
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            // Update
            var customer_id = txtCustomerID.Text;
            var fullname    = txtFullName.Text;
            var email       = txtEmail.Text;
            var address     = txtAddress.Text;

            using (var supermarket = new SuperEntities())
            {
                var st = (from s in supermarket.Customers where s.CustomerID == customer_id select s).First();
                st.CustomerID = customer_id;
                st.FullName   = fullname;
                st.Email      = email;
                st.Address    = address;
                supermarket.SaveChanges();
                MessageBox.Show("Successfully Updated.");
                LoadData();
            }
        }
Exemplo n.º 4
0
        private void btnInsert_Click(object sender, EventArgs e)
        {
            try
            {
                //panel1.Enabled = true;
                //txtCustomerID.Focus();
                //Customer c = new Customer();
                //supermarket.Customers.Add(c);
                //customerBindingSource.MoveLast();

                using (var supermarket = new SuperEntities())
                {
                    var customer_id = txtCustomerID.Text;
                    var fullname    = txtFullName.Text;
                    var email       = txtEmail.Text;
                    var address     = txtAddress.Text;

                    var st = new SupermarketFIX.Customer
                    {
                        CustomerID = customer_id,
                        FullName   = fullname,
                        Email      = email,
                        Address    = address
                    };

                    supermarket.Customers.Add(st);
                    supermarket.SaveChanges();
                    MessageBox.Show("Succesfully Inserted");
                    LoadData();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 5
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            var transno    = lblTransno.Text;
            var customerid = gridCustomer.CurrentRow.Cells[0];

            using (var context = new SuperEntities())
            {
                foreach (DataGridViewRow row in gridOrder.Rows)
                {
                    if (row.IsNewRow)
                    {
                        continue;
                    }
                    var product_id  = row.Cells[0].Value.ToString();
                    var item_name   = row.Cells[1].Value.ToString();
                    var price       = row.Cells[2].Value.ToString();
                    var quantity    = row.Cells[3].Value.ToString();
                    var price_total = row.Cells[4].Value.ToString();

                    var order = new Order();
                    order.TransNo   = transno;
                    order.ProductId = int.Parse(product_id);
                    order.Price     = int.Parse(price);
                    order.Qty       = int.Parse(quantity);
                    order.Total     = int.Parse(price_total);
                    order.SDate     = DateTime.Now;

                    context.Orders.Add(order);
                    context.SaveChanges();
                }
            }

            gridOrder.Rows.Clear();
            gridOrder.Refresh();
            GetTransNo();
        }