public void InsertOrderDetail(eOrderDetail od)
        {
            OrderDetail i = new OrderDetail();

            i.detailID  = od.DetailID;
            i.unitprice = (decimal)od.Unitprice;
            i.amount    = (decimal)od.Amount;
            i.orderID   = od.OrderID;
            i.teleID    = od.TeleID;
            db.OrderDetails.InsertOnSubmit(i);
            db.SubmitChanges();
        }
        //Order Detail
        #region

        public List <eOrderDetail> GetAllOrderDetails()
        {
            var lsi = db.OrderDetails.ToList();
            List <eOrderDetail> ls = new List <eOrderDetail>();

            foreach (OrderDetail i in lsi)
            {
                eOrderDetail im = new eOrderDetail();
                im.DetailID  = (int)i.detailID;
                im.Unitprice = (double)i.unitprice;
                im.Amount    = (double)i.amount;
                im.OrderID   = (int)i.orderID;
                im.TeleID    = (int)i.teleID;
                ls.Add(im);
            }
            return(ls);
        }
Exemple #3
0
        private void btnThanhToan_Click(object sender, EventArgs e)
        {
            eOrder o = new eOrder();

            o.CusName   = txtcusName.Text.TrimEnd();
            o.OrderDate = DateTime.Now;
            o.EmpID     = int.Parse(txtEmId.Text.TrimEnd());
            o.EmpName   = txtemName.Text.Trim();
            o.Total     = double.Parse(txtTotal.Text.Trim());
            o.State     = "Moi lap";
            qldtdd.InsertOrder(o);
            MessageBox.Show("Thanh toán thành công");
            for (int i = 0; i <= dgvImpDetail.Rows.Count - 1; i++)
            {
                eOrderDetail cthd = new eOrderDetail();
                cthd.OrderID = o.OrderID;
                //cthd.Amount = double.Parse(dgvImpDetail.Rows[i].Cells["amount"].Value.ToString().Trim());
                //cthd.Unitprice = double.Parse(dgvImpDetail.Rows[i].Cells["unitprice"].Value.ToString().Trim());
                //cthd.TeleID = int.Parse(dgvImpDetail.Rows[i].Cells["teleID"].Value.ToString());
                //qldtdd.InsertOrderDetail(cthd);
                MessageBox.Show("a" + o.OrderID);
            }
        }