private void button1_Click(object sender, EventArgs e) { try { cilent NewClient = new cilent(); if (textBox_clientId.TextLength == 0 || textBox_clientName.TextLength == 0 || textBox_orderId.TextLength == 0) { MessageBox.Show("输入不能为空"); } else { NewClient.cilentId = uint.Parse(textBox_clientId.Text); NewClient.cilentName = textBox_clientName.Text; order tmp = formProgram.orderWin.addOrder(uint.Parse(textBox_orderId.Text), NewClient); InputForm form4 = new InputForm(); form4.getOrder(tmp); form4.ShowDialog(); orderDetail newDetail = form4.returnObject(); tmp.addDetail(newDetail); tmp.calculate(); Form1.orderBindingSource.Add(tmp); Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public IHttpActionResult postOrderDetails(orderDetail data) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } else { orderDetail objOrder = db.orderDetails.Find(data.orderItemId); if (objOrder == null) { db.orderDetails.Add(data); db.SaveChanges(); return(Ok(data)); } else { return(BadRequest("Order id already exist!!")); } } } catch (Exception) { throw; } }
public object getListOrderDetails(string maHoaDon) { DataTable dt = new DataTable(); string cmdtext = string.Format(@" Select SP.TenSanPham,CTDH.SoLuong,CTDH.GiaBan,CTDH.ThanhTien,DH.NgayMua From dbo.Chi_Tiet_Don_Hang CTDH Inner Join dbo.Don_Hang DH On CTDH.MaDonHang = DH.MaDonHang Inner Join dbo.San_Pham SP On SP.MaSanPham = CTDH.MaSanPham Where CTDH.MaDonHang= '{0}'" , maHoaDon); dt = DataAccessHelper.log(cmdtext); List <orderDetail> li = new List <orderDetail>(); foreach (DataRow dr in dt.Rows) { orderDetail or = new orderDetail(); // tên số lượng giá bán thành tiền ngày mua or.tenSanPham = dr[0].ToString(); or.soLuong = int.Parse(dr[1].ToString()); or.giaBan = int.Parse(dr[2].ToString()); or.thanhTien = int.Parse(dr[3].ToString()); or.NgayMua = DateTime.Parse(dr[4].ToString()); li.Add(or); } return(li); }
public ActionResult OrderBooked() { order o = (order)Session["Order"]; db.orders.Add(o); db.SaveChanges(); List <Prod> p = (List <Prod>)Session["myCart"]; for (int i = 0; i < p.Count; i++) { orderDetail od = new orderDetail(); int orderId = db.orders.Max(x => x.ORDER_ID); od.ORDER_FID = orderId; od.PRODUCT_FID = p[i].PROD_ID; od.QUANTITY = p[i].PRO_QUANTITY; od.PURCHASE_PRICE = p[i].PROD_PURCHASE_PRICE; od.SALE_PRICE = p[i].PROD_SALE_PRICE; db.orderDetails.Add(od); db.SaveChanges(); } return(View()); }
public void saveOrder(ConfirmView confirm, int uid, int price) { var order = new order(); order.uid = uid; order.receiver = confirm.receiver; order.phone = confirm.phone; order.address = confirm.address; order.price = price; order.payment = false; order.shipment = false; db.order.AddObject(order); db.SaveChanges(); var orderDetail = new orderDetail(); foreach (var item in cartOperation.GetCurrentCart().cartItems) { orderDetail.orderId = order.id; orderDetail.name = item.name; orderDetail.amount = item.amount; orderDetail.price = item.price; db.orderDetail.AddObject(orderDetail); db.SaveChanges(System.Data.Objects.SaveOptions.None); } }
public IActionResult DeleteOrderDetail(orderDetail actRow) { var identity = (ClaimsIdentity)User.Identity; IEnumerable <Claim> claims = identity.Claims; JObject jo = new JObject(); try { var param = new DynamicParameters(); param.Add("rowId", actRow.rowId.ToString()); param.Add("statusId", "30"); param.Add("sysUserId", HttpContext.User.Claims.FirstOrDefault(m => m.Type == ClaimTypes.NameIdentifier).Value); param.Add("actUser", HttpContext.User.Claims.FirstOrDefault(m => m.Type == ClaimTypes.NameIdentifier).Value); strSql.Clear(); strSql.AppendLine("update C30_orderDetail set statusId=@statusId,actUser=@actUser,actTime=getDate() where rowId=@rowId and sysUserId = @sysUserId"); errStr = Tools.Dapper.ExecuteNonQuery(Tools.System.getConStr("MyDB"), strSql.ToString(), param); if (errStr != "") { throw new Exception(errStr); } jo.Add("resultCode", resultCode); } catch (Exception ex) { resultCode = "01"; jo.Add("resultCode", resultCode); jo.Add("errMsg", ex.Message); } return(Content(JsonConvert.SerializeObject(jo), "application/json")); }
public IActionResult ActOrderDetail(orderDetail actRow) { var identity = (ClaimsIdentity)User.Identity; IEnumerable <Claim> claims = identity.Claims; //string c = claims.FirstOrDefault(x => x.Type == "sysUserId").ToString(); JObject jo = new JObject(); try { var param = new DynamicParameters(); param.Add("orderId", actRow.orderId.ToString()); param.Add("shopId", actRow.shopId.ToString()); param.Add("mealId", actRow.mealId.ToString()); param.Add("orderPrice", int.Parse(actRow.mealPrice.ToString()) * int.Parse(actRow.mealQuantity.ToString())); param.Add("mealPrice", actRow.mealPrice.ToString()); param.Add("mealQuantity", actRow.mealQuantity.ToString()); param.Add("sysUserId", HttpContext.User.Claims.FirstOrDefault(m => m.Type == ClaimTypes.NameIdentifier).Value); param.Add("stausType", "S0"); param.Add("statusId", "10"); param.Add("statusId1", actRow.statusId1.ToString()); param.Add("statusType1", "C3"); param.Add("memo", actRow.memo.ToString()); param.Add("creatUser", HttpContext.User.Claims.FirstOrDefault(m => m.Type == ClaimTypes.NameIdentifier).Value); param.Add("creatTime", DateTime.Now); strSql.Clear(); strSql.AppendLine("select COUNT(*) from C30_orderDetail where orderId = @orderId and sysUserId = @sysUserId and statusId1 = '20' and statusId = '10'"); var countPass = Tools.Dapper.QuerySingleOrDefault(Tools.System.getConStr("MyDB"), strSql.ToString(), param); if (int.Parse(countPass) > 0) { throw new Exception("若要訂餐請先取消PASS"); } strSql.Clear(); strSql.AppendLine("select COUNT(*) from C30_orderDetail where orderId = @orderId and sysUserId = @sysUserId and statusId1 = '10' and statusId = '10'"); var countOrder = Tools.Dapper.QuerySingleOrDefault(Tools.System.getConStr("MyDB"), strSql.ToString(), param); if (actRow.statusId1.ToString() == "20" && int.Parse(countOrder) > 0) { throw new Exception("訂單中尚有餐點"); } strSql.Clear(); strSql.AppendLine("insert into C30_orderDetail (orderId,shopId,mealId,orderPrice,mealPrice,mealQuantity,sysUserId,statusId,stausType,statusId1,statusType1,memo,creatUser,creatTime)"); strSql.AppendLine("VALUES (@orderId,@shopId,@mealId,@orderPrice,@mealPrice,@mealQuantity,@sysUserId,@statusId,@stausType,@statusId1,@statusType1,@memo,@creatUser,@creatTime) "); strSql.AppendLine("SELECT CAST(SCOPE_IDENTITY() as int) as rowId"); var rowId = Tools.Dapper.QuerySingleOrDefault(Tools.System.getConStr("MyDB"), strSql.ToString(), param); //errStr = Tools.Dapper.ExecuteNonQuery(Tools.System.getConStr("MyDB"), strSql.ToString(), param); jo.Add("rowId", rowId); jo.Add("resultCode", resultCode); } catch (Exception ex) { resultCode = "01"; jo.Add("resultCode", resultCode); jo.Add("errMsg", ex.Message); } return(Content(JsonConvert.SerializeObject(jo), "application/json")); }
public ActionResult DeleteConfirmed(int id) { orderDetail orderDetail = db.orderDetail.Find(id); db.orderDetail.Remove(orderDetail); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult OrderBooked() { order o = (order)Session["Order"]; MailMessage mail = new MailMessage(); mail.From = new MailAddress("*****@*****.**"); mail.To.Add(o.ORDER_EMAIL); mail.Subject = "Order Confirmation"; mail.Body = "<b>Rifsa_Softs!</b><br/> thanks for your order of " + o.ORDER_NAME + "at" + System.DateTime.Now + "we will deliver within 24 hours "; mail.IsBodyHtml = true; SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com"); SmtpServer.Port = 587; SmtpServer.UseDefaultCredentials = false; SmtpServer.Credentials = new System.Net.NetworkCredential("*****@*****.**", "popyruqia.."); SmtpServer.EnableSsl = true; SmtpServer.Send(mail); String api = "https://lifetimesms.com/json?api_token=8dffbc6d9cda49784b5f9bfd09fcc2e64c6da05177&api_secret=RifsaSofts&to=" + o.ORDER_CONTACT + "&from=RifsaSofts&message=Order Confirmation.Thanks.....Your Order Has been booked"; HttpWebRequest req = (HttpWebRequest)WebRequest.Create(api); var httpResponse = (HttpWebResponse)req.GetResponse(); // saving data db.orders.Add(o); db.SaveChanges(); List <Prod> p = (List <Prod>)Session["myCart"]; for (int i = 0; i < p.Count; i++) { orderDetail od = new orderDetail(); int orderId = db.orders.Max(x => x.ORDER_ID); od.ORDER_FID = orderId; od.PRODUCT_FID = p[i].PROD_ID; od.QUANTITY = p[i].PRO_QUANTITY; od.PURCHASE_PRICE = p[i].PROD_PURCHASE_PRICE; od.SALE_PRICE = p[i].PROD_SALE_PRICE; db.orderDetails.Add(od); db.SaveChanges(); } return(View()); }
public ActionResult Edit([Bind(Include = "orderdetailID,qtyOrdered,price,orderID,productID")] orderDetail orderDetail) { if (ModelState.IsValid) { db.Entry(orderDetail).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.productID = new SelectList(db.Products, "productID", "description", orderDetail.productID); return(View(orderDetail)); }
public ActionResult Create([Bind(Include = "orderdetailID,qtyOrdered,price,orderID,productID")] orderDetail orderDetail) { if (ModelState.IsValid) { db.OrderDetail.Add(orderDetail); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.productID = new SelectList(db.Product, "productID", "description", orderDetail.productID); return(View(orderDetail)); }
public ActionResult Edit([Bind(Include = "product_id,order_id,price,quantity,created_at")] orderDetail orderDetail) { if (ModelState.IsValid) { db.Entry(orderDetail).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.order_id = new SelectList(db.orders, "id", "status", orderDetail.order_id); ViewBag.product_id = new SelectList(db.products, "id", "name", orderDetail.product_id); return(View(orderDetail)); }
// GET: orderDetails/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } orderDetail orderDetail = db.orderDetail.Find(id); if (orderDetail == null) { return(HttpNotFound()); } return(View(orderDetail)); }
// GET: orderDetails/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } orderDetail orderDetail = db.orderDetail.Find(id); if (orderDetail == null) { return(HttpNotFound()); } ViewBag.productID = new SelectList(db.Products, "productID", "description", orderDetail.productID); return(View(orderDetail)); }
// GET: orderDetails/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } orderDetail orderDetail = db.orderDetails.Find(id); if (orderDetail == null) { return(HttpNotFound()); } ViewBag.order_id = new SelectList(db.orders, "id", "status", orderDetail.order_id); ViewBag.product_id = new SelectList(db.products, "id", "name", orderDetail.product_id); return(View(orderDetail)); }
private void button1_Click(object sender, EventArgs e) { try { if (textBox_Num.TextLength == 0 || textBox_Name.TextLength == 0 || textBox_Price.TextLength == 0) { MessageBox.Show("输入不能为空"); } else { uint i = (uint)(tmpOrder.detailList.Count); NewDetail = new orderDetail(i, new product(double.Parse(textBox_Price.Text), uint.Parse(textBox_ProductId.Text), textBox_Name.Text), uint.Parse(textBox_Num.Text)); Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { int id = Convert.ToInt32(dataGridView1.CurrentRow.Cells["orderDetailIdDataGridViewTextBoxColumn"].Value); // deleteing if (e.ColumnIndex == 6) { orderDetail order = new orderDetail(); order.orderDetailId = id; if (!orderCrud.delete(order)) { MessageBox.Show("Что-то пошло не так"); } else { MessageBox.Show("Заказ удалён"); } } }
public ActionResult OList(orderDetail vm) { int userId = (int)Session[CDictionary.SK_LOGINED_USER_ID]; var currentCart = db.OrderList .Where(m => m.oId == vm.oId); if (currentCart != null) { foreach (var item in currentCart) { item.oQty += vm.orderQty; } db.SaveChanges(); return(RedirectToAction("OList", "Order")); } return(View(currentCart)); }
public order AddOrder(int CustID, ShopBasket myCart) { // Создаем и инициализируем новый заказ order o = new order { userId = CustID // Ид-р заказчика }; db.orders.Add(o); // Добавляем заказ в сущность // Проходим по строкам корзины и добавляем их в детали заказа car c; foreach (var line in myCart.GetLines()) { c = db.cars.Find(line.ProdID); orderDetail ordItems = new orderDetail { car = line.ProdID, car1 = c, total = 1, amount = line.Quantity, date = DateTime.Today, order = o.orderId, order1 = o, approved = "y" }; // Через навигационное свойство добавляем позицию в заказ o.orderDetails.Add(ordItems); } ; db.SaveChanges(); // Возвращаем новый вставленный заказ return(o); }
protected void ButtonDoPayment_Click(object sender, EventArgs e) { // Retrieve card informations card myCard = new card(); myCard.number = TextBoxCardNumber.Text; myCard.type = DropDownListCardType.SelectedValue; myCard.expirationDate = TextBoxCardExpiration.Text; myCard.cvx = TextBoxCardCryptogram.Text; myCard.ownerBirthdayDate = TextBoxCardBirthday.Text; myCard.password = TextBoxCardPassword.Text; // Retrieve payment informations payment myPayment = new payment(); myPayment.amount = TextBoxPaymentAmount.Text; myPayment.currency = TextBoxPaymentCurrency.Text; myPayment.action = DropDownListPaymentFunction.SelectedValue; myPayment.mode = DropDownListPaymentMode.SelectedValue;; myPayment.contractNumber = TextBoxPaymentContract.Text; myPayment.differedActionDate = TextBoxPaymentDifferedDate.Text; // Retrieve order informations order myOrder = new order(); myOrder.@ref = TextBoxOrderReference.Text; myOrder.origin = TextBoxOrderOrigin.Text; myOrder.country = TextBoxOrderCountry.Text; myOrder.taxes = TextBoxOrderTaxes.Text; myOrder.currency = TextBoxOrderCurrency.Text; myOrder.amount = TextBoxOrderAmount.Text; myOrder.date = TextBoxOrderDate.Text; // Retrieve order details (first part) orderDetail myOrderDetails1 = new orderDetail(); myOrderDetails1.@ref = TextBoxItem1Reference.Text; myOrderDetails1.price = TextBoxItem1Price.Text; myOrderDetails1.quantity = TextBoxItem1Quantity.Text; myOrderDetails1.comment = TextBoxItem1Comment.Text; // Retrieve order details (second part) orderDetail myOrderDetails2 = new orderDetail(); myOrderDetails2.@ref = TextBoxItem2Reference.Text; myOrderDetails2.price = TextBoxItem2Price.Text; myOrderDetails2.quantity = TextBoxItem2Quantity.Text; myOrderDetails2.comment = TextBoxItem2Comment.Text; myOrder.details = new orderDetail[] { myOrderDetails1, myOrderDetails2 }; // Retrieve private datas privateData myPrivateData1 = new privateData(); privateData myPrivateData2 = new privateData(); privateData myPrivateData3 = new privateData(); myPrivateData1.key = TextBoxPrivateDataKey1.Text; myPrivateData1.value = TextBoxPrivateDataValue1.Text; myPrivateData2.key = TextBoxPrivateDataKey2.Text; myPrivateData2.value = TextBoxPrivateDataValue2.Text; myPrivateData3.key = TextBoxPrivateDataKey2.Text; myPrivateData3.value = TextBoxPrivateDataValue3.Text; var myPrivateDataList = new privateData[] { myPrivateData1, myPrivateData2, myPrivateData3 }; // Retrieve buyer informations buyer myBuyer = new buyer(); myBuyer.email = TextBoxBuyerEmail.Text; myBuyer.accountCreateDate = TextBoxBuyerAccountDate.Text; myBuyer.accountAverageAmount = TextBoxBuyerAverageAmount.Text; myBuyer.accountOrderCount = TextBoxBuyerOrderCount.Text; //Returned datas transaction myTransaction = new transaction(); authorization myAuthorization = new authorization(); //Retrieve Web Service Version string transient = null; string linkedTransactionId = null; //string contractNumber = myPayment.contractNumber; string contractNumber; string resultContainer; extendedCardType extendedCard; cardOut cardOut; recurring recurring = null; try { var client = PaymentApiFactory.GetDirectPaymentAPIClient(); result Result = client.doAuthorization(ref transient, GlobalVariables.APIVersion, myPayment, null, myCard, myOrder, myBuyer, null, ref myPrivateDataList, null, null, null, null, ref linkedTransactionId, recurring, out myTransaction, out myAuthorization, out cardOut, out extendedCard, out contractNumber, out resultContainer); //Returned datas TextBoxResultCode.Text = Result.code; TextBoxResultShortMessage.Text = Result.shortMessage; TextBoxResultLongMessage.Text = Result.longMessage; TextBoxTransactionID.Text = myTransaction.id; } catch (Exception E) { LabelError.Visible = true; LabelError.Text = "Error : " + E.ToString(); } }
protected void ButtonDoPayment_Click(object sender, EventArgs e) { // Retrieve payment informations var myPayment = new payment(); myPayment.amount = TextBoxPaymentAmount.Text; myPayment.currency = TextBoxPaymentCurrency.Text; myPayment.action = DropDownListPaymentFunction.SelectedValue; myPayment.mode = DropDownListPaymentMode.SelectedValue;; myPayment.contractNumber = TextBoxPaymentContract.Text; myPayment.differedActionDate = TextBoxPaymentDifferedDate.Text; // Retrieve order informations var myOrder = new order(); myOrder.@ref = TextBoxOrderReference.Text; myOrder.origin = TextBoxOrderOrigin.Text; myOrder.country = TextBoxOrderCountry.Text; myOrder.taxes = TextBoxOrderTaxes.Text; myOrder.currency = TextBoxOrderCurrency.Text; myOrder.amount = TextBoxOrderAmount.Text; myOrder.date = TextBoxOrderDate.Text; // Retrieve order details (first part) var myOrderDetails1 = new orderDetail(); myOrderDetails1.@ref = TextBoxItem1Reference.Text; myOrderDetails1.price = TextBoxItem1Price.Text; myOrderDetails1.quantity = TextBoxItem1Quantity.Text; myOrderDetails1.comment = TextBoxItem1Comment.Text; // Retrieve order details (second part) var myOrderDetails2 = new orderDetail(); myOrderDetails2.@ref = TextBoxItem2Reference.Text; myOrderDetails2.price = TextBoxItem2Price.Text; myOrderDetails2.quantity = TextBoxItem2Quantity.Text; myOrderDetails2.comment = TextBoxItem2Comment.Text; myOrder.details = new orderDetail[] { myOrderDetails1, myOrderDetails2 }; //retrieve contrats informations var selectedContratsList = TextBoxContratList.Text.Split(new char[] { ';' }); // Retrieve private datas var myPrivateData1 = new privateData(); var myPrivateData2 = new privateData(); var myPrivateData3 = new privateData(); myPrivateData1.key = TextBoxPrivateDataKey1.Text; myPrivateData1.value = TextBoxPrivateDataValue1.Text; myPrivateData2.key = TextBoxPrivateDataKey2.Text; myPrivateData2.value = TextBoxPrivateDataValue2.Text; myPrivateData3.key = TextBoxPrivateDataKey2.Text; myPrivateData3.value = TextBoxPrivateDataValue3.Text; var myPrivateDataList = new privateData[] { myPrivateData1, myPrivateData2, myPrivateData3 }; // Retrieve buyer informations var myBuyer = new buyer(); myBuyer.email = TextBoxBuyerEmail.Text; myBuyer.accountCreateDate = TextBoxBuyerAccountDate.Text; myBuyer.accountAverageAmount = TextBoxBuyerAverageAmount.Text; myBuyer.accountOrderCount = TextBoxBuyerOrderCount.Text; myBuyer.mobilePhone = TextBoxBuyerPhone.Text; myBuyer.customerId = TextBoxBuyerCustomerId.Text; myBuyer.legalStatus = TextBoxBuyerLegalStatus.Text; myBuyer.legalDocument = TextBoxBuyerLegalDocument.Text; myBuyer.birthDate = TextBoxBuyerBirthDate.Text; myBuyer.walletCardInd = TextBoxBuyerWalletCardInd.Text; myBuyer.walletDisplayed = TextBoxBuyerWalletDisplayed.Text; //myBuyerOld.walletSecured string token = ""; string redirectURL = ""; string stepCode = ""; string reqCode = ""; string method = ""; try { var client = PaymentApiFactory.GetWebPaymentAPIClient(); result Result = client.doWebPayment(GlobalVariables.APIVersion, myPayment, TextBoxReturnUrl.Text, TextBoxCancelUrl.Text, myOrder, TextBoxNotificationUrl.Text, selectedContratsList, new string[] { }, myPrivateDataList, "FR", "", myBuyer, null, "SSL", null, null, null, null, null, null, null, null, null, out token, out redirectURL, out stepCode, out reqCode, out method); //Returned datas TextBoxResultCode.Text = Result.code; TextBoxResultShortMessage.Text = Result.shortMessage; TextBoxResultLongMessage.Text = Result.longMessage; TextBoxToken.Text = token; TextBoxRedirectURL.Text = redirectURL; } catch (Exception E) { LabelError.Visible = true; LabelError.Text = "Error : " + E.ToString(); } }