/// <summary> /// Create a new DetailTransaction object. /// </summary> /// <param name="transactionID">Initial value of the TransactionID property.</param> /// <param name="productID">Initial value of the ProductID property.</param> public static DetailTransaction CreateDetailTransaction(global::System.String transactionID, global::System.String productID) { DetailTransaction detailTransaction = new DetailTransaction(); detailTransaction.TransactionID = transactionID; detailTransaction.ProductID = productID; return(detailTransaction); }
private void btnDelete_Click(object sender, EventArgs e) { if (txtProductID.Text == "") { MessageBox.Show("Please Choose the Cart to be Deleted First!"); } else { DetailTransaction dd = (from x in db.DetailTransactions join y in db.HeaderTransactions on x.TransactionID equals y.TransactionID where x.ProductID == txtProductID.Text && y.Status == "Pending" && y.UserID == user.UserID select x).First(); db.DetailTransactions.DeleteObject(dd); db.SaveChanges(); refreshTableDetail(); } }
private void btnAddtoCart_Click(object sender, EventArgs e) { if (txtLaundryID.Text.Equals("")) { MessageBox.Show("Please Choose Laundry First"); } else if (numericUpDown1.Value.Equals(0)) { MessageBox.Show("Please Fill the Quantity More Than 0"); } else { key = txtLaundryID.Text; var data = (from x in db.HeaderTransactions join y in db.DetailTransactions on x.TransactionID equals y.TransactionID join z in db.PriceLists on y.ProductID equals z.ProductID where x.Status.Equals("Pending") && z.ProductID == key && x.UserID == user.UserID select new { z.ProductID, z.ProductName, y.Quantity, TotalPrice = y.Quantity * z.ProductPrice }); if (data.Count() == 0) { DetailTransaction d = new DetailTransaction(); var cekHeaderExist = (from x in db.HeaderTransactions where x.Status.Equals("Pending") && x.UserID == user.UserID select x).ToList(); cekH = cekHeaderExist.Count(); if (cekHeaderExist.Count() == 0) { HeaderTransaction h = new HeaderTransaction(); h.TransactionID = txtTransactionID.Text; h.UserID = txtUserID.Text; h.Status = "Pending"; db.HeaderTransactions.AddObject(h); db.SaveChanges(); } d.TransactionID = txtTransactionID.Text; d.ProductID = txtLaundryID.Text; d.Quantity = Convert.ToInt32(Math.Round(numericUpDown1.Value, 0)); d.Price = Int32.Parse(txtPrice.Text); db.DetailTransactions.AddObject(d); db.SaveChanges(); refreshTableDetail(); } else { DetailTransaction d = (from x in db.DetailTransactions join y in db.HeaderTransactions on x.TransactionID equals y.TransactionID where x.ProductID == key && y.Status == "Pending" && y.UserID == user.UserID select x).First(); int qtt = Convert.ToInt32(Math.Round(numericUpDown1.Value, 0)); d.Quantity = d.Quantity + qtt; db.SaveChanges(); refreshTableDetail(); } } grandTotalGenerator(); }
/// <summary> /// Deprecated Method for adding a new object to the DetailTransactions EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToDetailTransactions(DetailTransaction detailTransaction) { base.AddObject("DetailTransactions", detailTransaction); }