public DeliItem GetDeliItemByOrderID(string OrderID) { DeliItem obj_DeliItem = new DeliItem(); using (OnlineShoppingDataContext db = new OnlineShoppingDataContext()) { var data = db.sp_GetDeliItemByOrderID(OrderID); foreach (var obj in data) { obj_DeliItem.DeliItemID = obj.DeliItemID; obj_DeliItem.OrderID = obj.OrderID; obj_DeliItem.OrderNo = obj.OrderNo; obj_DeliItem.OrderQuantity = obj.OrderQuantity; obj_DeliItem.OrderAmount = obj.OrderAmount; obj_DeliItem.DiscountAmount = obj.DiscountAmount; obj_DeliItem.Tax = obj.Tax; obj_DeliItem.DeliveryCharges = obj.DeliveryCharges; obj_DeliItem.CustomerName = obj.CustomerName; obj_DeliItem.CustomerMobile = obj.CustomerMobile; obj_DeliItem.CustomerAddress = obj.CustomerAddress; obj_DeliItem.OrderDescription = obj.OrderDescription; obj_DeliItem.EstDeliveryDate = obj.EstDeliveryDate; obj_DeliItem.CreatedDate = obj.CreatedDate; obj_DeliItem.UpdatedDate = obj.UpdatedDate; obj_DeliItem.DeliManID = obj.DeliManID; obj_DeliItem.DeliMan_Name = obj.DeliMan_Name; obj_DeliItem.DeliMan_Mobile = obj.DeliMan_Mobile; obj_DeliItem.Status = obj.Status; } } return(obj_DeliItem); }
public OrderInfo InsertOrder(OrderInfo obj_order) { Guid id = Guid.NewGuid(); obj_order.OrderID = id.ToString(); obj_order.OrderNo = CreateOrderNo(); using (OnlineShoppingDataContext db = new OnlineShoppingDataContext()) { tbl_OrderInfo tbl_order = new tbl_OrderInfo(); tbl_order.OrderID = obj_order.OrderID; tbl_order.OrderNo = obj_order.OrderNo; tbl_order.OrderDate = obj_order.OrderDate; tbl_order.OrderQuantity = obj_order.OrderQuantity; tbl_order.DiscountAmount = obj_order.DiscountAmount; tbl_order.DeliveryCharges = obj_order.DeliveryCharges; tbl_order.OrderAmount = obj_order.OrderAmount; tbl_order.Tax = obj_order.Tax; tbl_order.OrderDescription = obj_order.OrderDescription; tbl_order.OrderStatus = obj_order.OrderStatus; tbl_order.CustomerID = obj_order.CustomerID; db.tbl_OrderInfos.InsertOnSubmit(tbl_order); db.SubmitChanges(); } return(obj_order); }
public OrderInfo GetOrderByID(string OrderID) { OrderInfo obj_Order = new OrderInfo(); using (OnlineShoppingDataContext db = new OnlineShoppingDataContext()) { var data = db.sp_GetOrderByID(OrderID); foreach (var obj in data) { obj_Order.OrderID = obj.OrderID; obj_Order.OrderNo = obj.OrderNo; obj_Order.OrderDate = obj.OrderDate; obj_Order.CustomerID = obj.CustomerID; obj_Order.CustomerName = obj.CustomerName; obj_Order.OrderQuantity = obj.OrderQuantity; obj_Order.DeliveryCharges = obj.DeliveryCharges; obj_Order.EstDeliveryDate = obj.EstDeliveryDate; obj_Order.Tax = obj.Tax; obj_Order.OrderAmount = obj.OrderAmount; obj_Order.CustomerAddress = obj.CustomerAddress; obj_Order.CustomerAddress = obj.CustomerAddress; obj_Order.OrderDescription = obj.OrderDescription; obj_Order.OrderStatus = obj.OrderStatus; obj_Order.CustomerEmail = obj.CustomerEmail; obj_Order.CustomerMobile = obj.CustomerMobile; } } return(obj_Order); }
public void InsertCart(CartInfo obj_cart) { using (OnlineShoppingDataContext db = new OnlineShoppingDataContext()) { tbl_cart table_cart = (from a in db.tbl_carts where a.CustomerID == obj_cart.CustomerID && a.ProductID == obj_cart.ProductID select a).FirstOrDefault(); if (table_cart != null) { table_cart.Quantity = Convert.ToInt32(table_cart.Quantity) + obj_cart.Quantity; db.SubmitChanges(); } else { tbl_cart table_Cart = new tbl_cart(); Guid id = Guid.NewGuid(); table_Cart.CartID = id.ToString(); table_Cart.ProductID = obj_cart.ProductID; table_Cart.CustomerID = obj_cart.CustomerID; table_Cart.Quantity = obj_cart.Quantity; db.tbl_carts.InsertOnSubmit(table_Cart); db.SubmitChanges(); } } }
public DataTable GetAllOrderDetailByOrderID(string OrderID) { DataTable dt = new DataTable(); dt.Columns.Add("OrderID", typeof(string)); dt.Columns.Add("ProductID", typeof(string)); dt.Columns.Add("ProductName", typeof(string)); dt.Columns.Add("ProductImage", typeof(byte[])); dt.Columns.Add("Quantity", typeof(int)); dt.Columns.Add("DiscountAmount", typeof(decimal)); dt.Columns.Add("ProductPrice", typeof(decimal)); dt.Columns.Add("TotalPrice", typeof(decimal)); using (OnlineShoppingDataContext db = new OnlineShoppingDataContext()) { var data = db.sp_GetAllOrderDetailByOrderID(OrderID); foreach (var obj in data) { DataRow dr = dt.NewRow(); dr["OrderID"] = obj.OrderID; dr["ProductID"] = obj.ProductID; dr["ProductName"] = obj.ProductName; dr["ProductImage"] = obj.ProductImage.ToArray(); dr["Quantity"] = obj.Quantity; dr["DiscountAmount"] = obj.DiscountAmount; dr["ProductPrice"] = obj.ProductPrice; dr["TotalPrice"] = obj.TotalPrice; dt.Rows.Add(dr); } } return(dt); }
public void InsertOrderDetail(string OrderID, List <OrderDetail> lst_OrderDetail) { using (OnlineShoppingDataContext db = new OnlineShoppingDataContext()) { foreach (OrderDetail obj_OrderDetail in lst_OrderDetail) { tbl_OrderDetail tbl_detail = (from a in db.tbl_OrderDetails where a.ProductID == obj_OrderDetail.ProductID && a.OrderID == OrderID select a).FirstOrDefault(); if (tbl_detail != null) { tbl_detail.Quantity = Convert.ToInt32(tbl_detail.Quantity) + obj_OrderDetail.Quantity; db.SubmitChanges(); } else { tbl_OrderDetail tbl_orderdetail = new tbl_OrderDetail(); tbl_orderdetail.OrderID = OrderID.ToString(); tbl_orderdetail.ProductID = obj_OrderDetail.ProductID; tbl_orderdetail.Quantity = obj_OrderDetail.Quantity; tbl_orderdetail.Price = obj_OrderDetail.Price; tbl_orderdetail.DiscountAmount = obj_OrderDetail.DiscountAmount; db.tbl_OrderDetails.InsertOnSubmit(tbl_orderdetail); db.SubmitChanges(); } } } }
public List <Product> GetAllProductsByName(string ProductName) { List <Product> lst_products = new List <Product>(); using (OnlineShoppingDataContext db = new OnlineShoppingDataContext()) { //var data = (from a in db.tbl_Products where a.ProductName like '*/12/*' orderby a.ProductName select a).ToList(); var data = (from p in db.tbl_Products where SqlMethods.Like(p.ProductName, "%" + ProductName + "%") select p).ToList(); foreach (var obj in data) { Product obj_product = new Product(); obj_product.ProductID = obj.ProductID; obj_product.ProductName = obj.ProductName; obj_product.ProductCategory = obj.ProductCategory; obj_product.ProductPrice = obj.ProductPrice; obj_product.ProductDescription = obj.ProductDescription; obj_product.ProductImage = obj.ProductImage.ToArray(); lst_products.Add(obj_product); } } return(lst_products); }
public string InsertWishlist(Wishlist obj_wishlist) { string result = ""; using (OnlineShoppingDataContext db = new OnlineShoppingDataContext()) { tbl_Wishlist table_wish = (from a in db.tbl_Wishlists where a.CustomerID == obj_wishlist.CustomerID && a.ProductID == obj_wishlist.ProductID select a).FirstOrDefault(); if (table_wish != null) { result = "You already added to wishlist."; } else { tbl_Wishlist table_Wishlist = new tbl_Wishlist(); Guid id = Guid.NewGuid(); table_Wishlist.WishlistID = id.ToString(); table_Wishlist.ProductID = obj_wishlist.ProductID; table_Wishlist.CustomerID = obj_wishlist.CustomerID; table_Wishlist.AddedDate = obj_wishlist.AddedDate; db.tbl_Wishlists.InsertOnSubmit(table_Wishlist); db.SubmitChanges(); result = "Successfully added to the wishlist."; } } return(result); }
public List <DeliMan> GetAllDeliMan() { List <DeliMan> lst_DeliMan = new List <DeliMan>(); using (OnlineShoppingDataContext db = new OnlineShoppingDataContext()) { var data = (from a in db.tbl_DeliMans select a).ToList(); foreach (var obj in data) { DeliMan obj_DeliMan = new DeliMan(); obj_DeliMan.DeliManID = obj.DeliManID; obj_DeliMan.DeliMan_Name = obj.DeliMan_Name; obj_DeliMan.DeliMan_Mobile = obj.DeliMan_Mobile; obj_DeliMan.DeliMan_Email = obj.DeliMan_Email; obj_DeliMan.DeliMan_NRC = obj.DeliMan_NRC; obj_DeliMan.DeliMan_Address = obj.DeliMan_Address; obj_DeliMan.DeliMan_Password = obj.DeliMan_Password; obj_DeliMan.DeliGroupID = obj.DeliGroupID; lst_DeliMan.Add(obj_DeliMan); } } return(lst_DeliMan); }
public DataTable GetAllWishlistByCustomer(string customerID) { DataTable dt = new DataTable(); dt.Columns.Add("WishlistID", typeof(string)); dt.Columns.Add("ProductID", typeof(string)); dt.Columns.Add("ProductName", typeof(string)); dt.Columns.Add("ProductImage", typeof(byte[])); dt.Columns.Add("ProductPrice", typeof(string)); dt.Columns.Add("AddedDate", typeof(string)); dt.Columns.Add("CustomerID", typeof(string)); dt.Columns.Add("CustomerName", typeof(string)); dt.Columns.Add("CustomerAddress", typeof(string)); using (OnlineShoppingDataContext db = new OnlineShoppingDataContext()) { var data = db.sp_GetAllWishlistByCustomer(customerID); foreach (var obj in data) { DataRow dr = dt.NewRow(); dr["WishlistID"] = obj.WishlistID; dr["ProductID"] = obj.ProductID; dr["ProductName"] = obj.ProductName; dr["ProductImage"] = obj.ProductImage.ToArray(); dr["ProductPrice"] = obj.ProductPrice; dr["AddedDate"] = String.Format("{0:dd-MMM-yyyy}", obj.AddedDate); dr["CustomerID"] = obj.CustomerID; dr["CustomerName"] = obj.CustomerName; dr["CustomerAddress"] = obj.CustomerAddress; dt.Rows.Add(dr); } } return(dt); }
public void InsertDeliItem(DeliItem obj_DeliITem) { Guid id = Guid.NewGuid(); using (OnlineShoppingDataContext db = new OnlineShoppingDataContext()) { tbl_DeliItemID tbl_deliItem = new tbl_DeliItemID(); tbl_deliItem.DeliItemID = id.ToString(); tbl_deliItem.OrderID = obj_DeliITem.OrderID; tbl_deliItem.Status = obj_DeliITem.Status; tbl_deliItem.EstDeliveryDate = obj_DeliITem.EstDeliveryDate; tbl_deliItem.CreatedDate = obj_DeliITem.CreatedDate; tbl_deliItem.UpdatedDate = obj_DeliITem.UpdatedDate; tbl_deliItem.OrderNo = obj_DeliITem.OrderNo; tbl_deliItem.OrderAmount = obj_DeliITem.OrderAmount; tbl_deliItem.Tax = obj_DeliITem.Tax; tbl_deliItem.DiscountAmount = obj_DeliITem.DiscountAmount; tbl_deliItem.DeliveryCharges = obj_DeliITem.DeliveryCharges; tbl_deliItem.OrderQuantity = obj_DeliITem.OrderQuantity; tbl_deliItem.CustomerName = obj_DeliITem.CustomerName; tbl_deliItem.CustomerMobile = obj_DeliITem.CustomerMobile; tbl_deliItem.CustomerAddress = obj_DeliITem.CustomerAddress; tbl_deliItem.OrderDescription = obj_DeliITem.OrderDescription; db.tbl_DeliItemIDs.InsertOnSubmit(tbl_deliItem); db.SubmitChanges(); } }
public void DeleteCart(string cartID) { using (OnlineShoppingDataContext db = new OnlineShoppingDataContext()) { var table_cart = (from a in db.tbl_carts where a.CartID == cartID select a).FirstOrDefault(); db.tbl_carts.DeleteOnSubmit(table_cart); db.SubmitChanges(); } }
public void DeleteWishlist(string wilshlistID) { using (OnlineShoppingDataContext db = new OnlineShoppingDataContext()) { var table_wilshlist = (from a in db.tbl_Wishlists where a.WishlistID == wilshlistID select a).FirstOrDefault(); db.tbl_Wishlists.DeleteOnSubmit(table_wilshlist); db.SubmitChanges(); } }
public byte[] GetProductImagebyID(string productID) { byte[] pimage; using (OnlineShoppingDataContext db = new OnlineShoppingDataContext()) { tbl_Product table_product = (from a in db.tbl_Products where a.ProductID == productID select a).FirstOrDefault(); pimage = table_product.ProductImage.ToArray(); } return(pimage); }
public void UpdateCart(CartInfo obj_cart) { using (OnlineShoppingDataContext db = new OnlineShoppingDataContext()) { tbl_cart table_cart = (from a in db.tbl_carts where a.CartID == obj_cart.CartID select a).FirstOrDefault(); if (table_cart != null) { table_cart.Quantity = obj_cart.Quantity; db.SubmitChanges(); } } }
public void UpdateProduct(Product obj_product) { using (OnlineShoppingDataContext db = new OnlineShoppingDataContext()) { tbl_Product tbl_product = (from a in db.tbl_Products where a.ProductID == obj_product.ProductID //&& a.ProductName == obj_product.ProductName select a).FirstOrDefault(); tbl_product.ProductDescription = obj_product.ProductDescription; db.SubmitChanges(); } }
public void UpdateDeliMan(DeliItem obj_DeliItem) { using (OnlineShoppingDataContext db = new OnlineShoppingDataContext()) { tbl_DeliItemID table_DeliItem = (from a in db.tbl_DeliItemIDs where a.OrderID == obj_DeliItem.OrderID select a).FirstOrDefault(); if (table_DeliItem != null) { table_DeliItem.DeliManID = obj_DeliItem.DeliManID; db.SubmitChanges(); } } }
public void UpdateOrderStatus(OrderInfo obj_orderInfo) { using (OnlineShoppingDataContext db = new OnlineShoppingDataContext()) { tbl_OrderInfo table_orderinfo = (from a in db.tbl_OrderInfos where a.OrderID == obj_orderInfo.OrderID select a).FirstOrDefault(); if (table_orderinfo != null) { table_orderinfo.OrderStatus = obj_orderInfo.OrderStatus; table_orderinfo.EstDeliveryDate = obj_orderInfo.EstDeliveryDate; db.SubmitChanges(); } } }
public void DeleteAllCartByCustomerID(string customerID) { using (OnlineShoppingDataContext db = new OnlineShoppingDataContext()) { var table_carts = (from a in db.tbl_carts where a.CustomerID == customerID select a).ToList(); foreach (var obj in table_carts) { tbl_cart table_cart = (from a in db.tbl_carts where a.CartID == obj.CartID select a).FirstOrDefault(); db.tbl_carts.DeleteOnSubmit(table_cart); db.SubmitChanges(); } } }
public string CreateOrderNo() { int i_OrderCount = 0; string orderNo = ""; using (OnlineShoppingDataContext db = new OnlineShoppingDataContext()) { i_OrderCount = (from order in db.tbl_OrderInfos select order).Count(); } i_OrderCount += 1; orderNo = i_OrderCount.ToString("D6"); return(orderNo); }
public Decimal GetDiscountByProductID(string productID) { decimal discountAmount = 0; using (OnlineShoppingDataContext db = new OnlineShoppingDataContext()) { var data = db.sp_GetDiscountByProductID(productID); foreach (var obj in data) { discountAmount = Convert.ToDecimal(obj.DiscountAmount); } } return(discountAmount); }
public Wishlist GetWishlistByID(string wishlistID) { Wishlist obj_Wishlist = new Wishlist(); using (OnlineShoppingDataContext db = new OnlineShoppingDataContext()) { tbl_Wishlist table_wishlist = (from a in db.tbl_Wishlists where a.WishlistID == wishlistID select a).FirstOrDefault(); obj_Wishlist.WishlistID = table_wishlist.WishlistID; obj_Wishlist.ProductID = table_wishlist.ProductID; obj_Wishlist.CustomerID = table_wishlist.CustomerID; obj_Wishlist.AddedDate = table_wishlist.AddedDate; } return(obj_Wishlist); }
public string GetTownshipByCustomerID(string customerID) { string customerTownship = ""; using (OnlineShoppingDataContext db = new OnlineShoppingDataContext()) { tbl_Customer cus = (from a in db.tbl_Customers where a.CustomerID == customerID select a).FirstOrDefault(); if (cus != null) { customerTownship = cus.CustomerTownship; } } return(customerTownship); }
public DataTable GetAllOrderInfo() { DataTable dt = new DataTable(); dt.Columns.Add("OrderID", typeof(string)); dt.Columns.Add("OrderNo", typeof(string)); dt.Columns.Add("OrderDate", typeof(DateTime)); dt.Columns.Add("EstDeliveryDate", typeof(string)); dt.Columns.Add("CustomerID", typeof(string)); dt.Columns.Add("CustomerName", typeof(string)); dt.Columns.Add("OrderQuantity", typeof(int)); dt.Columns.Add("OrderAmount", typeof(decimal)); dt.Columns.Add("CustomerAddress", typeof(string)); dt.Columns.Add("OrderDescription", typeof(string)); dt.Columns.Add("OrderStatus", typeof(string)); using (OnlineShoppingDataContext db = new OnlineShoppingDataContext()) { var data = db.sp_GetAllOrderInfo(); foreach (var obj in data) { DataRow dr = dt.NewRow(); dr["OrderID"] = obj.OrderID; dr["OrderNo"] = obj.OrderNo; dr["OrderDate"] = obj.OrderDate; if (obj.EstDeliveryDate != null) { dr["EstDeliveryDate"] = Convert.ToDateTime(obj.EstDeliveryDate).ToString("dd-MMM-yyyy"); } else { dr["EstDeliveryDate"] = ""; } dr["CustomerID"] = obj.CustomerID; dr["CustomerName"] = obj.CustomerName; dr["OrderQuantity"] = obj.OrderQuantity; dr["OrderAmount"] = obj.OrderAmount; dr["CustomerAddress"] = obj.CustomerAddress; dr["OrderDescription"] = obj.OrderDescription; dr["OrderStatus"] = obj.OrderStatus; dt.Rows.Add(dr); } } return(dt); }
public void InsertProduct(Product obj_product) { using (OnlineShoppingDataContext db = new OnlineShoppingDataContext()) { tbl_Product tbl_product = new tbl_Product(); Guid id = Guid.NewGuid(); tbl_product.ProductID = id.ToString(); tbl_product.ProductName = obj_product.ProductName; tbl_product.ProductCategory = obj_product.ProductCategory; tbl_product.ProductPrice = obj_product.ProductPrice; tbl_product.ProductImage = obj_product.ProductImage; tbl_product.ProductDescription = obj_product.ProductDescription; db.tbl_Products.InsertOnSubmit(tbl_product); db.SubmitChanges(); } }
public void InsertCustomer(Customer obj_customer) { using (OnlineShoppingDataContext db = new OnlineShoppingDataContext()) { tbl_Customer tbl_customer = new tbl_Customer(); Guid id = Guid.NewGuid(); tbl_customer.CustomerID = id.ToString(); tbl_customer.CustomerName = obj_customer.CustomerName; tbl_customer.CustomerEmail = obj_customer.CustomerEmail; tbl_customer.CustomerMobile = obj_customer.CustomerMobile; tbl_customer.CustomerAddress = obj_customer.CustomerAddress; tbl_customer.CustomerTownship = obj_customer.CustomerTownship; tbl_customer.CustomerPassword = obj_customer.CustomerPassword; tbl_customer.IsAdmin = Convert.ToBoolean(obj_customer.IsAdmin); db.tbl_Customers.InsertOnSubmit(tbl_customer); db.SubmitChanges(); } }
public Customer CheckCustomerLogin(string name, string password) { Customer obj_customer = new Customer(); using (OnlineShoppingDataContext db = new OnlineShoppingDataContext()) { tbl_Customer cus = (from a in db.tbl_Customers where a.CustomerName == name && a.CustomerPassword == password select a).FirstOrDefault(); if (cus != null) { obj_customer.CustomerID = cus.CustomerID; obj_customer.CustomerName = cus.CustomerName; obj_customer.CustomerEmail = cus.CustomerEmail; obj_customer.CustomerMobile = cus.CustomerMobile; obj_customer.CustomerAddress = cus.CustomerAddress; obj_customer.CustomerPassword = cus.CustomerPassword; obj_customer.IsAdmin = Convert.ToBoolean(cus.IsAdmin); } } return(obj_customer); }
public DataTable GetAllTownship() { DataTable dt_township = new DataTable(); dt_township.Columns.Add("Township", typeof(string)); dt_township.Columns.Add("DeliFees", typeof(decimal)); using (OnlineShoppingDataContext db = new OnlineShoppingDataContext()) { var data = (from a in db.tbl_Deli_Fees orderby a.Township select a).ToList(); foreach (var obj in data) { DataRow dr = dt_township.NewRow(); dr["Township"] = obj.Township; dr["DeliFees"] = obj.Deli_Fees; dt_township.Rows.Add(dr); } } return(dt_township); }
public DeliMan GetDeliManBy_Name_Mobile(string DeliManName, string DeliManMobile) { DeliMan obj_DeliMan = new DeliMan(); using (OnlineShoppingDataContext db = new OnlineShoppingDataContext()) { tbl_DeliMan deliMan = (from a in db.tbl_DeliMans where a.DeliMan_Name == DeliManName && a.DeliMan_Mobile == DeliManMobile select a).FirstOrDefault(); if (deliMan != null) { obj_DeliMan.DeliManID = deliMan.DeliManID; obj_DeliMan.DeliMan_Name = deliMan.DeliMan_Name; obj_DeliMan.DeliMan_Mobile = deliMan.DeliMan_Mobile; obj_DeliMan.DeliMan_Email = deliMan.DeliMan_Email; obj_DeliMan.DeliMan_NRC = deliMan.DeliMan_NRC; obj_DeliMan.DeliMan_Address = deliMan.DeliMan_Address; obj_DeliMan.DeliMan_Password = deliMan.DeliMan_Password; obj_DeliMan.DeliGroupID = deliMan.DeliGroupID; } } return(obj_DeliMan); }
public ActionResult Login(user user) { OnlineShoppingDataContext db = new OnlineShoppingDataContext(); user match = (from x in db.users where (user.email.Equals(x.email) && user.password.Equals(x.password)) select x).FirstOrDefault(); if (match == null) { ViewBag.errMessage = "Invalid Login"; return(View()); } else { HttpCookie cookie = new HttpCookie("user"); cookie["userid"] = match.userID; Response.Cookies.Add(cookie); FormsAuthentication.SetAuthCookie(user.email, false); return(RedirectToAction("index", "Home")); } }