public List <Order> getAllOrdersbyCust(int id) { IOrderDAL _order = new OrderDAL(); IProductDAL _product = new ProductDAL(); List <Order> allOrders = _order.getAllOrdersbyCust(id); List <Order> list = new List <Order>(); foreach (var item in allOrders) { List <OrderLine> orderlineslist = new List <OrderLine>(); List <OrderLine> OLlist = _order.getAllOrderLinesOfOrder(item.id); foreach (var OrderLineItems in OLlist) { orderlineslist.Add(new OrderLine() { id = OrderLineItems.id, productid = OrderLineItems.productid, quantity = OrderLineItems.quantity, product = _product.findProduct(OrderLineItems.productid), orderid = OrderLineItems.orderid }); } list.Add(new Order() { id = item.id, orderdate = item.orderdate, customerid = item.customerid, customer = _customer.getCustomer(item.customerid), orderLine = orderlineslist }); } return(list); }
public override void BindControl() { QuotationDAL dal = new QuotationDAL(); var quotes = dal.GetQuotesBySource(SourceType, SourceNo); List <Quotation> quotes2 = new List <Quotation>(); string enqNo = string.Empty; Order ord = new Order(); if (string.Equals(SourceType, SysConst.SourceTypeEnquiry, StringComparison.OrdinalIgnoreCase)) { ord = new OrderDAL().GetOrderByEnq(SourceNo); if (ord != null) { quotes2 = dal.GetQuotesBySource(SysConst.SourceTypeOrder, ord.Order_No); } } else if (string.Equals(SourceType, SysConst.SourceTypeOrder, StringComparison.OrdinalIgnoreCase)) { ord = new OrderDAL().GetOrderByNo(SourceNo); if (!string.IsNullOrEmpty(ord.EnqNo)) { var enq = new EnquiryDAL().GetEnquiryByNo(ord.EnqNo); quotes2 = dal.GetQuoteByEnq(enq.Enquiry_No); } } quotes.AddRange(quotes2); var result = quotes.Distinct(new QuotationComparer()).OrderBy(q => q.Quotation_No); Utility.BindDataToRepeater(rpQuotation, result); }
public static bool Cancel(Product Prodfound) { bool status = false; status = OrderDAL.Cancel(Prodfound); return(status); }
public JsonResult payOrder([FromBody] JObject data) { string sessionUserId = HttpContext.Session.GetString("userId"); string sessionPassword = HttpContext.Session.GetString("password"); UserDAL userDal = new UserDAL(); OrderDAL orderDal = new OrderDAL(); ItemDAL itemDal = new ItemDAL(); string orderId = data.Value <string>("order_id"); Order order = orderDal.getOrderById(orderId); // 权限验证 if (sessionUserId == null || userDal.getUserById(sessionUserId)?.password != sessionPassword || order?.userId != sessionUserId) { return(new JsonResult(Return.Error("用户未登录或无权限访问", HttpStatusCodes.Status401Unauthorized))); } if (order == null) { return(new JsonResult(Return.Error("找不到此订单", StatusCodes.OrderNotFound))); } if (order.paymentTime != null) { return(new JsonResult(Return.Error("订单已被支付过", StatusCodes.OrderAlreadyPaid))); } order.paymentTime = DateTime.Now; int result = orderDal.updateOrder(order); return(new JsonResult(Return.Success(result))); }
/*[HttpPost] * public ActionResult OrderNow(ShoppingCart sc) * { * //ADD ORDER * var newOrder = new Order * { * CustomerName = User.Identity.Name, * OrderDate = DateTime.Now, * ShipDate = DateTime.Now.AddDays(3) * }; * using (OrderDAL service = new OrderDAL()) * { * service.AddOrder(newOrder); * * //ADD DETAIL * foreach (var item in service.getData(sc.CartID)) * { * var newDetail = new OrderDetail * { * OrderID = newOrder.OrderID, * BookID = sc.BookID, * Quantity = sc.Quantity, * Price = sc.Book.Price * }; * * service.AddDetail(newDetail); * } * } * return RedirectToAction("Index", new { id = newOrder.OrderID }); * }*/ public ActionResult Final() { //ADD ORDER var newOrder = new Order { CustomerName = User.Identity.Name, OrderDate = DateTime.Now, ShipDate = DateTime.Now.AddDays(5) }; using (OrderDAL service = new OrderDAL()) { service.AddOrder(newOrder); //ADD DETAIL foreach (var item in service.getData(User.Identity.Name).ToList()) { var newDetail = new OrderDetail { OrderID = newOrder.OrderID, BookID = item.BookID, Quantity = item.Quantity, Price = item.Book.Price }; service.AddDetail(newDetail); service.removeCart(item); } } return(RedirectToAction("Index", new { id = newOrder.OrderID })); }
public static List <Product> Getorderd() { List <Product> orderd = new List <Product>(); orderd = OrderDAL.Getorderd(); return(orderd); }
public JObject Payfor(dynamic in_data) { try { JObject data = JObject.Parse(in_data.ToString()); string us_id = data["CarpoolSSID"].ToString(); string ods_id = data["ods_id"].ToString(); string option = data["option"].ToString(); if (us_id == null || Session["CarpoolSSID"]?.ToString() != us_id) { return(SendData(15001, "未授权访问")); } if (ods_id == null || ods_id == "") { return(SendData(400, "请求错误")); } bool result = OrderDAL.Payfor(ods_id); if (result) { return(SendData(200)); } else { return(SendData(20000, "服务错误")); } } catch (Exception e) { return(SendData(400, "请求错误")); } }
public List <Movie> showCartItems(string id) { var OrderDAL = new OrderDAL(); List <Movie> allItems = OrderDAL.showCartItems(id); return(allItems); }
public ActionResult Ordernew() { var oder1 = new Order { CustomerName = Session["username"].ToString(), OrderDate = DateTime.Now, ShipDate = DateTime.Now.AddDays(3), }; using (OrderDAL service = new OrderDAL()) { service.AddOrder(oder1); foreach (var oder in service.GetAllData(Session["username"].ToString()).ToList()) { var detailorder = new OrderDetail { OrderID = oder1.OrderID, BookID = oder.BookID, Quantity = oder.Quantity, Price = oder.Book.Price }; service.AddDetailOrder(detailorder); service.RemoveCart(oder); } } return(RedirectToAction("Index", new { id = oder1.OrderID })); }
public JObject IsApplyOrInvate(dynamic in_data) { try { JObject data = JObject.Parse(in_data.ToString()); string us_id = data["CarpoolSSID"].ToString(); string or_id = data["or_id"].ToString(); string option = data["option"].ToString(); if (us_id == null || Session["CarpoolSSID"]?.ToString() != us_id) { return(SendData(15001, "未授权访问")); } bool result = false; switch (option) { case "0": //申请 result = OrderDAL.IsApply(or_id, us_id); break; case "1": //邀请 result = OrderDAL.IsInvate(or_id, us_id); break; default: return(SendData(400, "请求错误")); } return(SendData(200, data: result ? 1 : 0)); } catch (Exception e) { return(SendData(400, "请求错误")); } }
// GET: Order public ActionResult Index(int id) { using (OrderDAL service = new OrderDAL()) { return(View(service.GetAllOrder(id).ToList())); } }
public void TestValidQty(int qty) { OrderDAL Repo; LocationDAL LocDal; var conn = new SqliteConnection("DataSource=:memory:"); conn.Open(); try { var options = new DbContextOptionsBuilder <WheyMenContext>() .UseSqlite(conn) .Options; using (var context = new WheyMenContext(options)) { context.Database.EnsureCreated(); } using (var context = new WheyMenContext(options)) { TestSetup(context); Repo = new OrderDAL(context); LocDal = new LocationDAL(context); var orderItem = new OrderItem { Oid = 1, Qty = qty, Pid = 5, }; Assert.IsTrue(orderItem.ValidateQuantity(LocDal.GetQty(5))); } } finally { conn.Close(); } }
private static void ReadExecuteReader(List <OrderItems> comList, SqlCommand cmd) { var connString = ConfigurationManager.ConnectionStrings["ConnStringDeltoneCRM"].ConnectionString; var orderdal = new OrderDAL(connString); using (SqlDataReader sdr = cmd.ExecuteReader()) { if (sdr.HasRows) { while (sdr.Read()) { var sbj = new OrderItems(); sbj.OrderId = (sdr["OrderID"].ToString()); sbj.OrderDate = Convert.ToDateTime(sdr["OrderedDateTime"].ToString()).ToString("dd-MMM-yyyy"); sbj.SupplierCode = (sdr["SupplierCode"].ToString()); sbj.ItemDescription = (sdr["Description"].ToString()); sbj.Qty = sdr["Quantity"].ToString(); sbj.UnitPrice = sdr["UnitAmount"].ToString(); sbj.XeroId = sdr["XeroInvoiceNumber"].ToString(); sbj.SupplierName = sdr["SupplierName"].ToString(); sbj.Cog = sdr["COGamount"].ToString(); sbj.Type = "1"; sbj.ComName = orderdal.getCompanyNameByOrderId(Convert.ToInt32(sbj.OrderId)); if (sdr["Status"].ToString() == "CANCELLED") { sbj.Type = "3"; sbj.XeroId = sdr["XeroInvoiceNumber"].ToString() + " - CANCELLED"; } comList.Add(sbj); } } } }
private static void ReadExecuteReaderCredit(List <OrderItems> comList, SqlCommand cmd) { var connString = ConfigurationManager.ConnectionStrings["ConnStringDeltoneCRM"].ConnectionString; var orderdal = new OrderDAL(connString); using (SqlDataReader sdr = cmd.ExecuteReader()) { if (sdr.HasRows) { while (sdr.Read()) { var sbj = new OrderItems(); sbj.OrderId = (sdr["CreditNote_ID"].ToString()); sbj.OrderDate = Convert.ToDateTime(sdr["DateCreated"].ToString()).ToString("dd-MMM-yyyy"); sbj.SupplierCode = (sdr["SupplierCode"].ToString()); sbj.ItemDescription = (sdr["Description"].ToString()); sbj.Qty = sdr["Quantity"].ToString(); sbj.UnitPrice = sdr["UnitAmount"].ToString(); sbj.XeroId = sdr["XeroCreditNoteID"].ToString(); sbj.SupplierName = sdr["SupplierName"].ToString(); sbj.Cog = sdr["COG"].ToString(); sbj.XeroId = sbj.XeroId + " - " + (sdr["CreditNoteReason"].ToString()); sbj.Type = "2"; sbj.ComName = orderdal.getCompanyNameByCreditId(Convert.ToInt32(sbj.OrderId)); comList.Add(sbj); } } } }
private string GetContactOrderName(string orderId) { var connString = ConfigurationManager.ConnectionStrings["ConnStringDeltoneCRM"].ConnectionString; OrderDAL orderdal = new OrderDAL(connString); return(orderdal.GetOrderContactPersonName(Convert.ToInt32(orderId))); }
public void GetOrderByIDTest() { OrderDAL dal = new OrderDAL(ConfigurationManager.ConnectionStrings["Shipper"].ConnectionString); var result = dal.GetOrderById(7); Assert.IsTrue(result.OrderID == 7, "returned ID does not match request"); }
public JObject GetInfo(dynamic in_data) { try { JObject data = JObject.Parse(in_data.ToString()); string id = data["id"].ToString(); string option = data["option"].ToString(); if (id == "" || option == "") { return(SendData(400, "请求错误")); } JObject car_json = null; switch (option) { case "0": //用户id car_json = CarDAL.GetInfo(id); break; case "1": //订单id JObject or_json = OrderDAL.GetInfo(id); car_json = CarDAL.GetInfo(or_json["us_id"].ToString()); break; default: return(SendData(400, "请求错误")); } return(SendData(200, data: car_json)); } catch (Exception e) { return(SendData(400, "请求错误")); } }
static void Main() { var dal = new OrderDAL(); var list = dal.GetAllOrders(); Console.WriteLine("All Orders"); foreach (var itm in list) { Console.WriteLine($" {itm.OrderId} \t {itm.CustomerId} \t{itm.EmployeeId} \t{itm.ShipName} \t{itm.ShipAddress} \t{itm.Status}"); } dal.InsertOrder(new Order { CustomerId = "TOMSP", EmployeeId = 3, OrderDate = DateTime.Now, RequiredDate = DateTime.Now, ShippedDate = DateTime.Now, ShipVia = 2, Freight = (decimal?)1.4300, ShipName = "Toms Spezialitäten", ShipAddress = "Luisenstr. 48", ShipCity = "Münster", ShipRegion = string.Empty, ShipPostalCode = "44087", ShipCountry = "Germany", Status = Order.StatusOrder.Completed }); Console.WriteLine("Успешно добавлена запись"); dal.DeleteOrder(11019); Console.WriteLine("Запись удалена"); dal.GetAllOrdersWithDetails(); dal.UpdateOrder(10285, "WILMK", 1, DateTime.Now, 1, (decimal)1000, "Test Ship", "Russia, Samara Region, Samara", "Samara", "Samara Region", "445445", "Russia"); Console.WriteLine("Успешно внесены изменения в запись"); }
private void CreateAuditRecord(string stsMessage, string endmessage) { var columnName = "Status"; var talbeName = "Order"; var ActionType = stsMessage; int primaryKey = Convert.ToInt32(str_ORDERID); var CONNSTRING = ConfigurationManager.ConnectionStrings["ConnStringDeltoneCRM"].ConnectionString; var newvalues = "Order Id " + str_ORDERID + " :Order Status changed from " + endmessage; var loggedInUserId = Convert.ToInt32(Session["LoggedUserID"].ToString()); SqlConnection conn = new SqlConnection(); conn.ConnectionString = CONNSTRING; var previousValues = "APPROVED"; var strCompanyID = new OrderDAL(CONNSTRING).getCompanyIDFromOrder(primaryKey); new DeltoneCRM_DAL.CompanyDAL(CONNSTRING).CreateActionONAuditLog(previousValues, newvalues, loggedInUserId, conn, 0, columnName, talbeName, ActionType, primaryKey, Convert.ToInt32(strCompanyID)); }
protected string ReturnAllItems(string orderId) { String strOutput = "{\"aaData\":["; var connString = ConfigurationManager.ConnectionStrings["ConnStringDeltoneCRM"].ConnectionString; OrderDAL repDayOffDal = new OrderDAL(connString); var targetConfigs = repDayOffDal.GetOrderCommissionLIst(orderId); foreach (var item in targetConfigs) { //String strEdit = "<img src='../../Images/Edit.png' onclick='Delete(" + item.Id + ")'/>"; strOutput = strOutput + "[\"" + item.CommId + "\"," + "\"" + item.UserId + "\"," + "\"" + item.RepName + "\"," + "\"" + item.Amount + "\"," + "\"" + item.OrderId + "\"],"; } if (targetConfigs.Count() > 0) { int Length = strOutput.Length; strOutput = strOutput.Substring(0, (Length - 1)); } strOutput = strOutput + "]}"; return(strOutput); }
public ActionResult Edit([Bind(Include = "Id, OrderDate, Customer, ShopAssistant, Amount, Price")] OrderDTO orderDTO) { IUnitOfWork database = new EFUnitOfWork(); var product = database.Products.GetIdByName(orderDTO.Product); var customer = database.Customers.GetIdByName(orderDTO.Customer); var shopAssistant = database.ShopAssistants.GetIdByName(orderDTO.ShopAssistant); var order = new OrderDAL { OrderDate = orderDTO.OrderDate, Id = orderDTO.Id, Amount = orderDTO.Amount, Price = orderDTO.Price, CustomerId = customer.Value, ProductId = product.Value, ShopAssistantId = shopAssistant.Value }; try { if (ModelState.IsValid) { database.Orders.Update(order); database.Orders.Save(); return(RedirectToAction("Index")); } } catch (DataException /* dex */) { //Log the error (uncomment dex variable name after DataException and add a line here to write a log. ModelState.AddModelError(string.Empty, "Unable to save changes. Try again, and if the problem persists contact your system administrator."); } return(View(orderDTO)); }
public static bool Insert(Product Prodfound) { bool status = false; status = OrderDAL.Add(Prodfound); return(status); }
private async Task CreateOrders(ConfigurationData configData, List <customers> customers, List <products> products) { List <string> dealers = ProductDAL.GetDistinctDealerItem(configData.ConnectionString); List <orders> orders = OrderDAL.FetchOrders(configData.ConnectionString, order => order.orderdate >= DateTime.Parse("12/11/2017")); foreach (var o in orders) { if (!string.IsNullOrEmpty(o.orderno)) { var customer = customers.FirstOrDefault(I => I.customer_id == o.customerid); if (customer != null && customer.qb_customer_id.HasValue) { string response = await CreateInvoice(quickbooksURL, o, customer.qb_customer_id.Value.ToString(), customer.non_taxable, products, (dealers.Contains(customer.billing_firstname))); if (!response.StartsWith("error")) { //JToken outer = JToken.Parse(response); //var pId = outer["Invoice"]["Id"].Value<int>(); //o.qb_product_id = pId; //ProductDAL.UpdateProduct(configData, pId, prod.SKU); } } } } }
public ActionResult Cart() { var orderCarts = (List <OrderCart>)Session["OrderCartList"]; var order = new OrderDAL().GetCart(orderCarts); return(View("Cart", order)); }
public ActionResult GetOcHead(string OcID) { var list = OrderDAL.GetOcHeadByID(OcID); var result = new { rows = list }; return(Json(result, JsonRequestBehavior.AllowGet)); }
public override void BindControl() { RefineDAL dal = new RefineDAL(); var result = dal.GetRefineBySource(SourceType, SourceNo); string enqNo = string.Empty; List <Refine> refines2 = new List <Refine>(); Order ord = new Order(); if (string.Equals(SourceType, SysConst.SourceTypeEnquiry, StringComparison.OrdinalIgnoreCase)) { ord = new OrderDAL().GetOrderByEnq(SourceNo); if (ord != null) { refines2 = dal.GetRefineBySource(SysConst.SourceTypeOrder, ord.Order_No); } } else if (string.Equals(SourceType, SysConst.SourceTypeOrder, StringComparison.OrdinalIgnoreCase)) { ord = new OrderDAL().GetOrderByNo(SourceNo); if (!string.IsNullOrEmpty(ord.EnqNo)) { var enq = new EnquiryDAL().GetEnquiryByNo(ord.EnqNo); refines2 = dal.GetRefineByEnq(enq.Enquiry_No); } } result.AddRange(refines2); result = result.Distinct(new RefineComparer()).OrderBy(r => r.Refine_No).ToList(); Utility.BindDataToRepeater(rpRefinement, result); }
public ActionResult GetOcHeadReturnList(OrderHead model) { var list = OrderDAL.GetOcHeadReturnList(model); var result = new { rows = list }; return(Json(result, JsonRequestBehavior.AllowGet)); }
public MemberOrderEntity CreateEntityByOrderID(string orderid, ref string msg) { try { MemberOrderEntity orderEntity = new MemberOrderEntity(); OrderDAL orderDal = new OrderDAL(); var order = MemberOrderDAL.GetMemberOrder(orderid); if (order == null) { return(null); } orderEntity.Number = order.Number; orderEntity.OrderDate = order.OrderDate; orderEntity.OrderID = order.OrderId; orderEntity.TotalMoney = Convert.ToDouble(order.TotalMoney); orderEntity.TotalPv = Convert.ToDouble(order.TotalPv); orderEntity.TotalMoneyReturned = Convert.ToDouble(order.TotalMoneyReturned); orderEntity.TotalPvReturned = Convert.ToDouble(order.TotalPvReturned); List <MemberOrderDetailsEntity> details = orderDal.GetMemberOrderDetailsEntity(orderid); orderEntity.Details = details; return(orderEntity); } catch (Exception ex) { msg = "生成错误:" + ex.Message; return(null); } }
public ActionResult AddList1(string OcID) { //listOrderInfo.Add(model); //var result = new { total = 100, rows = listOrderInfo }; //return Json(result, JsonRequestBehavior.AllowGet); //string OcID = Request["OcID"] == null ? "" : Request["OcID"].ToString(); OrderDetails model = new OrderDetails(); var sr = new StreamReader(Request.InputStream); var stream = sr.ReadToEnd(); //var entity = JsonConvert.DeserializeObject<PlaceOrder>(stream); JArray ja = (JArray)JsonConvert.DeserializeObject(stream); //model.ProductMo = ja[0]["ProductMo"].ToString(); //for (int i = 0; i < ja.Count; i++) //{ // var ja0 = ja[i]; model.ProductMo = ja[0]["value"].ToString(); model.ProductID = ja[1]["value"].ToString(); //model.ProductID = ja[i]["ProductID"].ToString(); //model.OrderQty = Convert.ToInt32(ja[i]["OrderQty"].ToString()); //model.Price = Convert.ToDecimal(ja[i]["Price"].ToString()); //} model.OcID = OcID; string result = OrderDAL.UpdateOcDetails(model); //return Json("OK"); return(Json(result, JsonRequestBehavior.AllowGet)); }
protected void btnGenerateOrder_Click(object sender, EventArgs e) { var quote = new QuotationDAL().GetQuoteByNo(GetQueryStringValue("quono")); if (string.Equals(quote.SourceType, SysConst.SourceTypeOrder, StringComparison.OrdinalIgnoreCase)) { ClientScript.RegisterClientScriptBlock(this.GetType(), "createorder", "<script>alert('来源为订单的报价单不能再次生成订单');</script>" ); return; } string enqNo = quote.SourceNo; Order ord = new OrderDAL().GetOrderByEnq(enqNo); if (ord == null) { ord = Utility.GenerateOrder(quote); } ClientScript.RegisterClientScriptBlock(this.GetType(), "createorder", string.Format("<script>window.open('orderform.aspx?ordid={0}&ordno={1}&sourceno={2}&sourcetype=Q')</script>", ord.Order_Id, ord.Order_No, ord.SourceNo)); }
/// <summary> /// Inserts the person and order. /// </summary> /// <returns></returns> private bool InsertPersonAndOrder() { PersonDAL personDAL = new PersonDAL(ConfigurationManager.ConnectionStrings["trainingConnectionString"].ConnectionString); PersonDTO personDTO = new PersonDTO(); personDTO.Firstname = Server.HtmlEncode(FirstName.Text); personDTO.Surname = Server.HtmlEncode(Surname.Text); personDTO.Address = new AddressDTO(); personDTO.Address.Address1 = Server.HtmlEncode(Address1.Text); personDTO.Address.Address2 = Server.HtmlEncode(Address2.Text); personDTO.Address.Address3 = Server.HtmlEncode(Address3.Text); personDTO.Address.City = Server.HtmlEncode(City.Text); personDTO.Address.Country = Server.HtmlEncode(Country.Text); personDTO.Address.Postcode = Server.HtmlEncode(PostCode.Text); try { personDAL.Save(personDTO); } catch (Exception ex) { throw ex; } try { OrderDAL orderDAL = new OrderDAL(ConfigurationManager.ConnectionStrings["trainingConnectionString"].ConnectionString); OrderDTO orderDTO = new OrderDTO(); orderDTO.PersonID = personDTO.PersonID; orderDTO.OrderLines = GetValues(); orderDAL.Save(orderDTO); } catch (Exception ex) { throw ex; //new System.ArgumentException("An error occured when saving an order"); } return true; }