Exemplo n.º 1
0
        public ActionResult AddressAndPayment(OrderViewModel ovm)
        {
            var cart = ShoppingCart.GetCart(this.HttpContext);

            tblOrder tb = new tblOrder();

            tb.Username        = Session["username"].ToString();
            tb.Firstname       = ovm.Firstname;
            tb.Lastname        = ovm.Lastname;
            tb.Address         = ovm.Address;
            tb.Phone           = ovm.Phone;
            tb.Total           = cart.GetTotal();
            tb.OrderDate       = Convert.ToDateTime(DateTime.Today.ToShortDateString());
            tb.DeliveredStatus = "Pending";

            db.tblOrders.Add(tb);
            db.SaveChanges();

            List <tblCart> lst = cart.GetCartItems();

            foreach (var item in lst)
            {
                tblOrderDetail tbord = new tblOrderDetail();
                tbord.OrderId   = tb.OrderId;
                tbord.ProductId = item.ProductId;
                tbord.Quantity  = item.Count;
                tbord.UnitPrice = item.tblProduct.SellingPrice;
                db.tblOrderDetails.Add(tbord);
                db.SaveChanges();
            }


            ViewBag.Message = "Your Ordered Done Successfully, It Takes 2/3 Hours In Our working Days";
            return(View());
        }
Exemplo n.º 2
0
        private void btnremove_Click(object sender, EventArgs e)
        {
            tblOrderDetail orderdetails = new tblOrderDetail();

            orderdetails.OrderID = txtOrderID.Text;
            orderdetails.ProdID  = cmbProductID.Text;
            if (cmbProductID.Text != "" && txtProductName.Text != "" && txtQuantityOrder.Text != "")
            {
                DialogResult result = MessageBox.Show
                                          (" Are you sure you want to remove?", " Confirmation",
                                          MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (result == DialogResult.Yes)
                {
                    if (txtOrderID.Text == orderdetails.OrderID && cmbProductID.Text == orderdetails.ProdID)
                    {
                        clsrepository.delete(orderdetails);
                    }
                    dgvOrderDetails.Rows.Remove(dgvOrderDetails.CurrentRow);
                    cmbProductID.SelectedItem = null;
                    txtProductName.Clear();
                    txtQuantityOrder.Clear();
                }
            }
            else
            {
                MessageBox.Show("Please choose what you want to remove!", "NOTE", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public ActionResult Checkout()
        {
            if (Session["customerName"] == null && Session["customerID"] == null)
            {
                return(RedirectToAction("Login", "Customer"));
            }

            float       totalPrice = 0;
            int         VendorID   = 0;
            List <Cart> cart_list  = Session["my_cart"] != null ? (List <Cart>)Session["my_cart"] : new List <Cart>();

            tblOrder order = new tblOrder();
            List <tblOrderDetail> orderDetailList = new List <tblOrderDetail>();

            foreach (var item in cart_list)
            {
                tblOrderDetail orderDetails = new tblOrderDetail();

                orderDetails.productID         = item.productID;
                orderDetails.productTotalPrice = item.productTotalPrice;
                orderDetails.productUnitPrice  = item.productUnitPrice;
                orderDetails.productQty        = item.productQty;

                VendorID = item.vendorID;

                orderDetailList.Add(orderDetails);

                totalPrice += item.productTotalPrice;
            }

            int         custID   = Convert.ToInt32(Session["customerID"]);
            tblCustomer customer = db.tblCustomers.Where(x => x.customerID == custID).FirstOrDefault();

            order.vendorID              = VendorID;
            order.orderStatus           = 1;
            order.customerID            = Convert.ToInt32(Session["customerID"]);
            order.totalOrderPrice       = totalPrice;
            order.orderDelieveryAddress = customer.customerAddress;
            order.orderPlacedTime       = DateTime.Now;
            order.tblOrderDetails       = orderDetailList;

            db.tblOrders.Add(order);
            db.SaveChanges();

            int orderID = order.orderID;

            foreach (tblOrderDetail order_det in order.tblOrderDetails)
            {
                order_det.orderID         = orderID;
                db.Entry(order_det).State = EntityState.Modified;
            }
            db.SaveChanges();

            Session.Remove("my_cart");

            return(RedirectToAction("DashBoard", "Customer"));
        }
Exemplo n.º 4
0
        private void txtOrderID_TextChanged(object sender, EventArgs e)
        {
            tblOrderDetail order = new tblOrderDetail();

            order.OrderID = txtOrderID.Text;
            if (txtOrderID.Text == order.OrderID)
            {
                dgvProductDetails.DataSource = db.sp_view_OrderDetails(txtOrderID.Text);
            }
        }
        public IHttpActionResult GettblOrderDetail(int id)
        {
            tblOrderDetail tblOrderDetail = db.tblOrderDetails.Find(id);

            if (tblOrderDetail == null)
            {
                return(NotFound());
            }

            return(Ok(tblOrderDetail));
        }
        private void btnview_Click(object sender, EventArgs e)
        {
            db = new db_MiletecDataContext();
            tblOrderDetail orders = new tblOrderDetail();

            orders.OrderID = orderID;
            if (orderID == orders.OrderID)
            {
                dvgviewdetails.DataSource = db.sp_view_OrderDetails(orderID);
            }
        }
        public ActionResult AddProduct(int idOrder, int idPro)
        {
            var tblorderdetail = new tblOrderDetail();

            tblorderdetail.IdOrder    = idOrder;
            tblorderdetail.IdProducts = idPro;
            tblorderdetail.DateCreate = DateTime.Now;
            db.tblOrderDetails.Add(tblorderdetail);
            db.SaveChanges();
            Session.Remove("Cart");
            Session["Cart"] = null;
            return(Json(tblorderdetail));
        }
Exemplo n.º 8
0
        public ActionResult ProcessOrder(FormCollection frc)
        {
            List <CartViewModel> LstCrt = (List <CartViewModel>)Session[StrCart];
            //1. save the order

            //Generate
            Random x = new Random();
            long   GeneratedOrderName = x.Next(0, 1000);

            tblOrder orders = new tblOrder()
            {
                //OrderName = GeneratedOrderName.ToString()+ "0.00" + GeneratedOrderName.ToString(),
                OrderName         = "ORDER" + GeneratedOrderName.ToString(),
                CustomerFirstName = frc["billing_first_name"],
                CustomerLastName  = frc["billing_last_name"],
                CompanyName       = frc["billing_company"],
                Country           = frc["billing_country"],
                Street            = frc["billing_address_1"],
                Apartment         = frc["billing_address_2"],
                Town        = frc["billing_city"],
                State       = frc["billing_state"],
                ZIP         = frc["billing_postcode"],
                Phone       = frc["billing_phone"],
                Email       = frc["billing_email"],
                OrderNote   = frc["order_comments"],
                OrderDate   = DateTime.UtcNow,
                PaymentType = "Cash",
                Status      = "Processing"
            };

            db.tblOrders.Add(orders);
            db.SaveChanges();
            //2. save the order values
            foreach (CartViewModel cartItem in LstCrt)
            {
                tblOrderDetail orderDetail = new tblOrderDetail()
                {
                    OrderId   = orders.OrderId,
                    ProductId = cartItem.Product.ProductId,
                    Price     = cartItem.Product.Price.ToString(),
                    Quantity  = cartItem.Quantity.ToString()
                };
                db.tblOrderDetails.Add(orderDetail);
                db.SaveChanges();
            }

            //3. Remove Shopping cart session
            Session.Remove(StrCart);
            return(View("OrderSuccess"));
        }
        public IHttpActionResult DeletetblOrderDetail(int id)
        {
            tblOrderDetail tblOrderDetail = db.tblOrderDetails.Find(id);

            if (tblOrderDetail == null)
            {
                return(NotFound());
            }

            db.tblOrderDetails.Remove(tblOrderDetail);
            db.SaveChanges();

            return(Ok(tblOrderDetail));
        }
        private void GenerateOrder()
        {
            try
            {
                _newOrder                  = new tblOrder();
                _newOrder.IsActive         = true;
                _newOrder.OrderTime        = DateTime.Now;
                _newOrder.UserID           = App.Current.CurrentUser.Username;
                _newOrder.CustomerID       = SPViewModel.CustomerOV.CurrentSelectedCustomer.CustomerID;
                _newOrder.OrderDescription = SPViewModel.OrderDescription;
                _newOrder.TotalPrice       = SPViewModel.MedicineOV.MedicineCost;
                _newOrder.PurchasePrice    = SPViewModel.MedicineOV.PaidAmount;
                foreach (OrderDetailOV vo in SPViewModel.CustomerOrderDetailItemSource)
                {
                    tblOrderDetail oD = new tblOrderDetail()
                    {
                        IsActive     = true,
                        Quantity     = Convert.ToDouble(vo.Quantity),
                        TotalPrice   = vo.TotalPrice,
                        UnitPrice    = vo.UnitPrice,
                        MedicineID   = vo.MedicineID,
                        PromoPercent = vo.PromoPercent,
                        UnitBidPrice = vo.UnitBidPrice
                    };
                    _newOrder.tblOrderDetails.Add(oD);
                }
            }
            catch (Exception e)
            {
                App.Current.ShowApplicationMessageBox("Không thể tạo hóa đơn mới, vui lòng liên hệ CSKH!",
                                                      HPSolutionCCDevPackage.netFramework.AnubisMessageBoxType.Default,
                                                      HPSolutionCCDevPackage.netFramework.AnubisMessageImage.Info,
                                                      OwnerWindow.MainScreen,
                                                      "Lỗi!!");
                SPViewModel.ButtonCommandOV.IsInstantiateNewOrderButtonRunning = false;
            }

            _previousDebt = SPViewModel.MedicineOV.DebtCost;

            _createNewOrderQueryObserver = new SQLQueryCustodian(GenerateOrderCallback,
                                                                 null,
                                                                 typeof(MSW_SP_InstantiateNewOrderAction));
            DbManager.Instance.ExecuteQueryAsync(SQLCommandKey.ADD_NEW_CUSTOMER_ORDER_CMD_KEY,
                                                 PharmacyDefinitions.ADD_NEW_CUSTOMER_ORDER_DELAY_TIME,
                                                 _createNewOrderQueryObserver,
                                                 _newOrder);
        }
Exemplo n.º 11
0
        private void UpdateCustomerOderDetails()
        {
            // Cập nhật lại order detail trong order của customer dựa theo thay đổi (OrderDetailOV)
            // từ phía người dùng
            foreach (tblOrderDetail orderDetail in CBPViewModel.CurrentCustomerOrder.tblOrderDetails)
            {
                var tempList = CBPViewModel.CurrentOrderDetails.Where(ov => ov.OrderDetailID == orderDetail.OrderDetailID).ToList();
                if (tempList.Count > 0)
                {
                    orderDetail.Quantity   = tempList.First().Quantity;
                    orderDetail.TotalPrice = tempList.First().TotalPrice;
                }
                else
                {
                    orderDetail.IsActive = false;
                }
            }

            // Thêm mới order detail trong OrderDetailOV vào trong order của customer
            foreach (OrderDetailOV ov in CBPViewModel.CurrentOrderDetails)
            {
                if (ov.OrderDetailID == -1)
                {
                    var newOD = new tblOrderDetail()
                    {
                        IsActive     = true,
                        Quantity     = Convert.ToDouble(ov.Quantity),
                        TotalPrice   = ov.TotalPrice,
                        UnitPrice    = ov.UnitPrice,
                        MedicineID   = ov.MedicineID,
                        PromoPercent = ov.PromoPercent,
                        UnitBidPrice = ov.UnitBidPrice
                    };
                    CBPViewModel.CurrentCustomerOrder.tblOrderDetails.Add(newOD);
                    CBPViewModel.CurrentCustomerOrder.TotalPrice += newOD.TotalPrice;
                }
            }

            CBPViewModel.CurrentCustomerOrder.PurchasePrice = CBPViewModel.MedicineOV.PaidAmount;
        }
Exemplo n.º 12
0
        private SQLQueryResult AddNewCustomerOrderDetail(PharmacyDBContext appDBContext, object[] paramaters)
        {
            SQLQueryResult result = new SQLQueryResult(null, MessageQueryResult.Non);

            try
            {
                switch (handle)
                {
                case SINGLE_HANDLER:
                    tblOrderDetail newOrder = paramaters[0] as tblOrderDetail;
                    appDBContext.tblOrderDetails.Add(newOrder);
                    appDBContext.SaveChanges();
                    result = new SQLQueryResult(newOrder, MessageQueryResult.Done, "Thêm chi tiết đơn hàng thành công!");
                    break;

                case MULTI_HANDLER:
                    var newOrders = paramaters[0] as IEnumerable <tblOrderDetail>;
                    appDBContext.tblOrderDetails.AddRange(newOrders);
                    appDBContext.SaveChanges();
                    result = new SQLQueryResult(newOrders, MessageQueryResult.Done, "Thêm chi tiết đơn hàng thành công!");
                    break;

                default:
                    break;
                }
            }
            catch (DbEntityValidationException e)
            {
                HandleDbEntityValidationException(e);
                result = new SQLQueryResult(null, MessageQueryResult.Aborted, "Lỗi thêm chi tiết đơn hàng!");
            }
            catch (Exception e)
            {
                result = new SQLQueryResult(null, MessageQueryResult.Aborted, "Lỗi thêm chi tiết đơn hàng!");
                ShowErrorMessageBox(e);
            }

            return(result);
        }
Exemplo n.º 13
0
        public IHttpActionResult PosttblFeedback(int orderID, FeedbackDTO dto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            tblFeedback feedback = new tblFeedback
            {
                toyID   = dto.toyID,
                content = dto.content,
                cusID   = dto.cusID,
                status  = 0
            };

            db.tblFeedbacks.Add(feedback);
            tblOrderDetail ordDetail = db.tblOrderDetails.FirstOrDefault(detail => detail.id == orderID && detail.toyID == dto.toyID);

            ordDetail.isFeedback = true;
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = dto.id }, dto));
        }
Exemplo n.º 14
0
        public int CreateOrder(tblOrder order)
        {
            decimal orderTotal = 0;

            var cartItems = GetCartItem();

            // Iterate over the items in the cart,
            // adding the order details for each
            foreach (var item in cartItems)
            {
                var orderDetail = new tblOrderDetail
                {
                    ProductId = item.ProductId,
                    OrderId   = order.OrderId,
                    UnitPrice = item.tblProduct.Price,
                    Quantity  = item.Count
                };
                // Set the order total of the shopping cart
                orderTotal += (decimal)(item.Count * item.tblProduct.Price);

                Context.tblOrderDetails.Add(orderDetail);

                //int? Quantity = orderDetail.Quantity;
                //Quantity = Quantity - 1;
                //if(Quantity == 0)
                //{
                //    break;
                //}
            }
            // Set the order's total to the orderTotal count
            order.Total = orderTotal;

            // Save the order
            Context.SaveChanges();
            // Empty the shopping cart
            EmptyCart();
            // Return the OrderId as the confirmation number
            return(order.OrderId);
        }
Exemplo n.º 15
0
        public bool AddOrder(tblOrder order, tblOrderDetail orderDetail, tblOrder_Shipping orderShipping)
        {
            try
            {
                web365db.tblOrder.Add(order);

                orderShipping.OrderID = order.ID;

                web365db.tblOrder_Shipping.Add(orderShipping);

                orderDetail.OrderID = order.ID;

                web365db.tblOrderDetail.Add(orderDetail);

                var result = web365db.SaveChanges();

                return(result > 0);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Exemplo n.º 16
0
        public IHttpActionResult PosttblOrderDetail(IEnumerable <OrderDetailDTO> listDetail)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            foreach (OrderDetailDTO item in listDetail)
            {
                tblOrderDetail ordDetail = new tblOrderDetail
                {
                    isFeedback = false,
                    name       = item.name,
                    orderID    = item.orderID,
                    price      = item.price,
                    quantity   = item.quantity,
                    toyID      = item.toyID
                };
                db.tblOrderDetails.Add(ordDetail);
            }
            db.SaveChanges();

            return(StatusCode(HttpStatusCode.Created));
        }
        public ActionResult CreateOrd(string Name, string Address, string DateByy, string Mobile, string Email, string Description)
        {
            var      Sopping = (clsGiohang)Session["giohang"];
            tblOrder order   = new tblOrder();

            order.Name        = Name;
            order.Address     = Address;
            order.DateByy     = DateTime.Parse(DateByy);
            order.Mobile      = Mobile;
            order.Email       = Email;
            order.Description = Description;
            order.Active      = false;
            order.Tolar       = Sopping.CartTotal;
            db.tblOrders.Add(order);
            db.SaveChanges();

            tblOrderDetail orderdetail = new tblOrderDetail();
            var            MaxOrd      = db.tblOrders.OrderByDescending(p => p.id).Take(1).ToList();
            int            idOrder     = MaxOrd[0].id;

            for (int i = 0; i < Sopping.CartItem.Count; i++)
            {
                orderdetail.idProduct = Sopping.CartItem[i].id;
                orderdetail.Name      = Sopping.CartItem[i].Name;
                orderdetail.Price     = Sopping.CartItem[i].Price;
                orderdetail.Quantily  = Sopping.CartItem[i].Ord;
                orderdetail.SumPrice  = Sopping.CartItem[i].SumPrice;
                orderdetail.idOrder   = idOrder;
                db.tblOrderDetails.Add(orderdetail);
                db.SaveChanges();
            }
            //Send mail cho khách

            tblConfig config = db.tblConfigs.First();
            // Gmail Address from where you send the mail
            var fromAddress = config.UserEmail;
            // any address where the email will be sending
            var toAddress = config.Email;
            //Password of your gmail address
            string fromPassword = config.PassEmail;
            // Passing the values and make a email formate to display
            string subject = "Đơn hàng mới từ";
            string body    = "From: " + Name + "\n";

            body += "Tên khách hàng: " + Name + "\n";
            body += "Địa chỉ: " + Address + "\n";
            body += "Điện thoại: " + Mobile + "\n";
            body += "Email: " + Email + "\n";
            body += "Nội dung: \n" + Description + "\n";
            body += "THÔNG TIN ĐƠN ĐẶT HÀNG \n";
            ////string OrderId = clsConnect.sqlselectOneString("select max(idOrder) as MaxID from [Order]");

            //insert vao bang OrderDetail

            for (int i = 0; i < Sopping.CartItem.Count; i++)
            {
                body += "Tên sản phẩm : " + Sopping.CartItem[i].Name + "\n";
                body += "Đơn giá  :" + Sopping.CartItem[i].Price.ToString().Replace(",", "") + "\n";
                body += "Số lượng : " + Sopping.CartItem[i].Ord + "\n";
            }
            body += "Tổng giá trị đơn hàng là " + Sopping.CartTotal;
            var smtp = new System.Net.Mail.SmtpClient();

            {
                smtp.Host           = config.Host;
                smtp.Port           = int.Parse(config.Port.ToString());
                smtp.EnableSsl      = true;
                smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
                smtp.Credentials    = new NetworkCredential(fromAddress, fromPassword);
                smtp.Timeout        = int.Parse(config.Timeout.ToString());
            }
            smtp.Send(fromAddress, toAddress, subject, body);


            Session["Status"] = "<script>$(document).ready(function(){ alert('Bạn đã đặt hàng thành công !') });</script>";
            return(RedirectToAction("OrderIndex"));
        }
Exemplo n.º 18
0
        public ActionResult Command(FormCollection collection, string tag)
        {
            if (collection["btnorder"] != null)
            {
                try
                {
                    string   Name        = collection["Name"];
                    string   Address     = collection["Address"];
                    string   DateByy     = collection["DateByy"];
                    string   Mobile      = collection["Mobile"];
                    string   Mobiles     = collection["Mobiles"];
                    string   Email       = collection["Email"];
                    string   Name1       = collection["Name1"];
                    string   Address1    = collection["Address"];
                    string   Mobile1     = collection["Mobile1"];
                    string   Mobile1s    = collection["Mobile1s"];
                    string   Email1      = collection["Email1"];
                    string   rdtt        = collection["rdtt"];
                    string   rdvc        = collection["rdvc"];
                    string   NameCP      = collection["NameCP"];
                    string   AddressCP   = collection["AddressCP"];
                    string   MST         = collection["MST"];
                    string   Description = collection["Description"];
                    var      Sopping     = (clsGiohang)Session["giohang"];
                    tblOrder order       = new tblOrder();
                    order.Name          = Name;
                    order.Name1         = Name1;
                    order.Address       = Address;
                    order.Address1      = Address1;
                    order.DateByy       = DateTime.Now;
                    order.Mobile        = Mobile;
                    order.Mobile1       = Mobile1;
                    order.Mobiles       = Mobiles;
                    order.Mobile1s      = Mobile1s;
                    order.TypePay       = int.Parse(rdtt);
                    order.Email1        = Email1;
                    order.Email         = Email;
                    order.NameCP        = NameCP;
                    order.AddressCP     = AddressCP;
                    order.MST           = MST;
                    order.TypePay       = int.Parse(rdtt);
                    order.TypeTransport = int.Parse(rdvc);
                    order.Status        = false;
                    order.Description   = Description;
                    order.Active        = true;

                    tblOrderDetail orderdetail = new tblOrderDetail();
                    var            MaxOrd      = db.tblOrders.OrderByDescending(p => p.id).Take(1).ToList();
                    int            idOrder     = 1;

                    if (MaxOrd.Count > 0)
                    {
                        idOrder = MaxOrd[0].id;
                    }
                    for (int i = 0; i < Sopping.CartItem.Count; i++)
                    {
                        orderdetail.idProduct = Sopping.CartItem[i].id;
                        orderdetail.Name      = Sopping.CartItem[i].Name;
                        orderdetail.Price     = Sopping.CartItem[i].Price;
                        orderdetail.Quantily  = Sopping.CartItem[i].Ord;
                        orderdetail.SumPrice  = Sopping.CartItem[i].SumPrice;
                        orderdetail.idOrder   = idOrder;
                        db.tblOrderDetails.Add(orderdetail);
                        db.SaveChanges();
                    }
                    tblConfig config       = db.tblConfigs.First();
                    var       fromAddress  = config.UserEmail;
                    var       toAddress    = config.Email;
                    var       orders       = db.tblOrders.OrderByDescending(p => p.id).Take(1).ToList();
                    string    fromPassword = config.PassEmail;
                    string    ararurl      = Request.Url.ToString();
                    var       listurl      = ararurl.Split('/');
                    string    urlhomes     = "";
                    for (int i = 0; i < listurl.Length - 2; i++)
                    {
                        if (i > 0)
                        {
                            urlhomes += "/" + listurl[i];
                        }
                        else
                        {
                            urlhomes += listurl[i];
                        }
                    }
                    order.Tolar = Sopping.CartTotal;
                    db.tblOrders.Add(order);
                    db.SaveChanges();
                    string subject   = "Đơn hàng mới từ " + urlhomes + "";
                    string chuoihtml = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\"><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /><title>Thông tin đơn hàng</title></head><body style=\"background:#f2f2f2; font-family:Arial, Helvetica, sans-serif\"><div style=\"width:750px; height:auto; margin:5px auto; background:#FFF; border-radius:5px; overflow:hidden\">";
                    chuoihtml += "<div style=\"width:100%; height:40px; float:left; margin:0px; background:#1c7fc4\"><span style=\"font-size:14px; line-height:40px; color:#FFF; margin:auto 20px; float:left\">" + DateTime.Now.Date + "</span><span style=\"font-size:14px; line-height:40px; float:right; margin:auto 20px; color:#FFF; text-transform:uppercase\">Hotline : " + config.Hotline1 + "</span></div>";
                    chuoihtml += "<div style=\"width:100%; height:auto; float:left; margin:0px\"><div style=\"width:35%; height:100%; margin:0px; float:left\"><a href=\"/\" title=\"\"><img src=\"" + urlhomes + "" + config.Logo + "\" alt=\"Logo\" style=\"margin:8px; display:block; max-height:95% \" /></a></div><div style=\"width:60%; height:100%; float:right; margin:0px; text-align:right\"><span style=\"font-size:18px; margin:20px 5px 5px 5px; display:block; color:#ff5a00; text-transform:uppercase\">" + config.Name + "</span><span style=\"display:block; margin:5px; color:#515151; font-size:13px; text-transform:uppercase\">Lớn nhất - Chính hãng - Giá rẻ nhất việt nam</span> </div>  </div>";
                    chuoihtml += "<span style=\"text-align:center; margin:10px auto; font-size:20px; color:#000; font-weight:bold; text-transform:uppercase; display:block\">Thông tin đơn hàng</span>";
                    chuoihtml += " <div style=\"width:90%; height:auto; margin:10px auto; background:#f2f2f2; padding:15px\">";
                    chuoihtml += "<p style=\"font-size:14px; color:#464646; margin:5px 20px\">Đơn hàng từ website : <span style=\"color:#1c7fc4\">" + urlhomes + "</span></p>";
                    chuoihtml += "<p style=\"font-size:14px; color:#464646; margin:5px 20px\">Ngày gửi đơn hàng : <span style=\"color:#1c7fc4\">Vào lúc " + DateTime.Now.Hour + " giờ " + DateTime.Now.Minute + " phút ( ngày " + DateTime.Now.Day + " tháng " + DateTime.Now.Month + " năm " + DateTime.Now.Year + ") </span></p>";
                    chuoihtml += "<p style=\"font-size:14px; color:#464646; margin:5px 20px\">Mã đơn hàng : <span style=\"color:#1c7fc4\">" + idOrder + " </span></p>";
                    chuoihtml += "<p style=\"font-size:14px; color:#1b1b1b; margin:5px 20px; text-decoration:underline; text-transform:uppercase\">Danh sách sản phẩm : </p>";
                    chuoihtml += "<table style=\"width:100%; height:auto; margin:10px auto; background:#FFF; border:1px\" border=\"0\">";
                    chuoihtml += " <tr style=\" background:#1c7fc4; color:#FFF; text-align:center; line-height:25px; font-size:12px\">";

                    chuoihtml += "<td>STT</td>";
                    chuoihtml += "<td>Tên sản phẩm</td>";
                    chuoihtml += "<td>Đơn giá (vnđ)</td>";
                    chuoihtml += "<td>Số lượng</td>";
                    chuoihtml += "<td>Thành tiền (vnđ)</td>";
                    chuoihtml += "</tr>";

                    for (int i = 0; i < Sopping.CartItem.Count; i++)
                    {
                        chuoihtml += "<tr style=\"line-height:20px; font-size:13px; color:#000; text-indent:5px; border-bottom:1px dashed #cecece; margin:1px 0px;\">";
                        chuoihtml += "<td style=\"text-align:center; width:7%\">" + i + "</td>";
                        chuoihtml += "<td style=\"width:45%\">" + Sopping.CartItem[i].Name + "</td>";
                        int gia = Convert.ToInt32(Sopping.CartItem[i].Price.ToString());
                        chuoihtml += "<td style=\"text-align:center; width:15%\">" + gia.ToString().Replace(",", "") + "</td>";
                        chuoihtml += "<td style=\"text-align:center; width:10%\">" + Sopping.CartItem[i].Ord + "</td>";
                        float thanhtien = Sopping.CartItem[i].Price * Sopping.CartItem[i].Ord;
                        chuoihtml += "<td style=\"text-align:center; font-weight:bold\">" + thanhtien.ToString().Replace(",", "") + "</td>";
                        chuoihtml += " </tr>";
                    }
                    chuoihtml += "<tr style=\"font-size:12px; font-weight:bold\">";
                    chuoihtml += "<td colspan=\"4\" style=\"text-align:right\">Tổng giá trị đơn hàng : </td>";
                    chuoihtml += "<td style=\"font-size:14px; color:#F00\">" + Sopping.CartTotal + " vnđ</td>";
                    chuoihtml += " </tr>";
                    chuoihtml += "</table>";
                    chuoihtml += "<div style=\" width:100%; margin:15px 0px\">";
                    chuoihtml += "<div style=\"width:100%; height:auto; float:left; margin:0px; border:1px solid #d5d5d5\">";
                    chuoihtml += "<div style=\" width:100%; height:30px; float:left; background:#1c7fc4; font-size:12px; color:#FFF; text-indent:15px; line-height:30px\">    	Thông tin người gửi     </div>";

                    chuoihtml += "<div style=\"width:100%; height:auto; float:left\">";
                    chuoihtml += "<p style=\"font-size:12px; margin:5px 10px\">Họ và tên :<span style=\"font-weight:bold\"> " + Name + "</span></p>";
                    chuoihtml += "<p style=\"font-size:12px; margin:5px 10px\">Địa chỉ :<span style=\"font-weight:bold\"> " + Address + "</span></p>";
                    chuoihtml += "<p style=\"font-size:12px; margin:5px 10px\">Điện thoại :<span style=\"font-weight:bold\"> " + Mobile + " - " + Mobiles + "</span></p>";
                    chuoihtml += "<p style=\"font-size:12px; margin:5px 10px\">Email :<span style=\"font-weight:bold\">" + Email + "</span></p>";
                    if (rdtt == "1")
                    {
                        chuoihtml += "<p style=\"font-size:12px; margin:5px 10px\">Hình thức thanh toán :<span style=\"font-weight:bold\">Chuyển hàng thu tiền tại nhà</span></p>";
                    }
                    if (rdtt == "2")
                    {
                        chuoihtml += "<p style=\"font-size:12px; margin:5px 10px\">Hình thức thanh toán :<span style=\"font-weight:bold\">Nhận hàng và thanh toán tại Ariston</span></p>";
                    }
                    if (rdtt == "3")
                    {
                        chuoihtml += "<p style=\"font-size:12px; margin:5px 10px\">Hình thức thanh toán :<span style=\"font-weight:bold\">Chuyển khoản ATM & Ngân hàng</span></p>";
                    }
                    if (rdtt == "4")
                    {
                        chuoihtml += "<p style=\"font-size:12px; margin:5px 10px\">Hình thức thanh toán :<span style=\"font-weight:bold\">Thanh toán visa, mastercard</span></p>";
                    }
                    if (rdvc == "1")
                    {
                        chuoihtml += "<p style=\"font-size:12px; margin:5px 10px\">Thời gian giao hàng :<span style=\"font-weight:bold\">Bất kể giờ nào</span></p>";
                    }
                    if (rdvc == "2")
                    {
                        chuoihtml += "<p style=\"font-size:12px; margin:5px 10px\">Thời gian giao hàng :<span style=\"font-weight:bold\">Trong giờ hàng chính</span></p>";
                    }
                    if (rdvc == "3")
                    {
                        chuoihtml += "<p style=\"font-size:12px; margin:5px 10px\">Thời gian giao hàng :<span style=\"font-weight:bold\">Ngoài giờ hành chính</span></p>";
                    }

                    chuoihtml += "</div>";
                    chuoihtml += "</div>";
                    if (Name1 != null)
                    {
                        chuoihtml += "<div style=\" width:100%; height:30px; float:left; background:#1c7fc4; font-size:12px; color:#FFF; text-indent:15px; line-height:30px\">    	Người nhận hàng   </div>";

                        chuoihtml += "<div style=\"width:100%; height:auto; float:left\">";
                        chuoihtml += "<p style=\"font-size:12px; margin:5px 10px\">Họ và tên :<span style=\"font-weight:bold\"> " + Name1 + "</span></p>";
                        chuoihtml += "<p style=\"font-size:12px; margin:5px 10px\">Địa chỉ :<span style=\"font-weight:bold\"> " + Address1 + "</span></p>";
                        chuoihtml += "<p style=\"font-size:12px; margin:5px 10px\">Điện thoại :<span style=\"font-weight:bold\"> " + Mobile1 + " - " + Mobile1s + "</span></p>";
                        chuoihtml += "<p style=\"font-size:12px; margin:5px 10px\">Email :<span style=\"font-weight:bold\">" + Email1 + "</span></p>";
                        chuoihtml += "</div>";
                        chuoihtml += "</div>";
                    }
                    if (NameCP != null)
                    {
                        chuoihtml += "<div style=\" width:100%; height:30px; float:left; background:#1c7fc4; font-size:12px; color:#FFF; text-indent:15px; line-height:30px\">    	Thông tin yêu cầu hóa đơn  </div>";

                        chuoihtml += "<div style=\"width:100%; height:auto; float:left\">";
                        chuoihtml += "<p style=\"font-size:12px; margin:5px 10px\">Tên công ty :<span style=\"font-weight:bold\"> " + NameCP + "</span></p>";
                        chuoihtml += "<p style=\"font-size:12px; margin:5px 10px\">Địa chỉ :<span style=\"font-weight:bold\"> " + AddressCP + "</span></p>";
                        chuoihtml += "<p style=\"font-size:12px; margin:5px 10px\">MST:<span style=\"font-weight:bold\"> " + MST + "</span></p>";
                        chuoihtml += "</div>";
                        chuoihtml += "</div>";
                    }
                    chuoihtml += "<div style=\"width:90%; height:auto; margin:10px auto; border:1px solid #d5d5d5\">";
                    chuoihtml += "<div style=\" width:100%; height:30px; float:left; background:#1c7fc4; font-size:12px; color:#FFF; text-indent:15px; line-height:30px\">   	Yêu cầu của người gửi       </div>";
                    chuoihtml += " <div style=\"width:100%; height:auto; float:left\">";
                    chuoihtml += "<p style=\"font-size:12px; margin:5px 10px; font-weight:bold; color:#F00\"> - " + Description + "</p>";
                    chuoihtml += "</div>";
                    chuoihtml += "</div>";
                    var listo = db.tblOrders.OrderByDescending(p => p.id).Take(1).ToList();
                    chuoihtml += " <a href=\"" + urlhomes + "/Orderad/ActiveOrder?id=" + listo[0].id + "\" title=\"\" style=\"padding:5px; color:#FFF; background:#F00; display:inline-block; text-align:center; margin:10px auto\">Đã check thông tin >></a>";
                    chuoihtml += "</div>";


                    chuoihtml += "<div style=\"width:100%; height:auto; float:left; margin:0px\">";
                    chuoihtml += "<hr style=\"width:80%; height:1px; background:#d8d8d8; margin:20px auto 10px auto\" />";
                    chuoihtml += "<p style=\"font-size:12px; text-align:center; margin:5px 5px\">" + config.Address1 + "</p>";
                    chuoihtml += "<p style=\"font-size:12px; text-align:center; margin:5px 5px\">Điện thoại : " + config.Mobile1 + " - " + config.Hotline1 + "</p>";
                    chuoihtml += " <p style=\"font-size:12px; text-align:center; margin:5px 5px; color:#ff7800\">Thời gian mở cửa : Từ 7h30 đến 18h30 hàng ngày (làm cả thứ 7, chủ nhật). Khách hàng đến trực tiếp xem hàng giảm thêm giá.</p>";
                    chuoihtml += "</div>";
                    chuoihtml += "<div style=\"clear:both\"></div>";
                    chuoihtml += " </div>";
                    chuoihtml += " <div style=\"width:100%; height:40px; float:left; margin:0px; background:#1c7fc4\">";
                    chuoihtml += "<span style=\"font-size:12px; text-align:center; color:#FFF; line-height:40px; display:block\">Copyright (c) 2002 – 2015 Ariston VIET NAM. All Rights Reserved</span>";
                    chuoihtml += " </div>";
                    chuoihtml += "</div>";
                    chuoihtml += "</body>";
                    chuoihtml += "</html>";
                    string body = chuoihtml;

                    var smtp = new System.Net.Mail.SmtpClient();
                    {
                        smtp.Host           = config.Host;
                        smtp.Port           = int.Parse(config.Port.ToString());
                        smtp.EnableSsl      = true;
                        smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
                        smtp.Credentials    = new NetworkCredential(fromAddress, fromPassword);
                        smtp.Timeout        = int.Parse(config.Timeout.ToString());
                    }
                    using (var message = new MailMessage(fromAddress, toAddress)
                    {
                        Subject = subject,
                        Body = body,
                        IsBodyHtml = true,
                    })
                    {
                        smtp.Send(message);
                    }


                    Session["Status"] = "<script>$(document).ready(function(){ alert('Bạn đã đặt hàng thành công !') });</script>";
                    return(RedirectToAction("OrderIndex"));
                }
                catch (Exception ex)
                {
                    Session["Status"] = "<script>$(document).ready(function(){ alert('Bạn đã đặt hàng thành công " + ex.Message + "!') });</script>";
                    return(RedirectToAction("OrderIndex"));
                }
            }
            return(RedirectToAction("OrderIndex"));
        }
Exemplo n.º 19
0
        public ActionResult PaymentAndOrderInfo(FormCollection values)
        {
            string paymentId = Session["paymentId"].ToString();

            OrderVM orderVM = new OrderVM();

            TryUpdateModel(orderVM);

            tblOrder order = new tblOrder();

            order.Username   = User.Identity.Name;
            order.FirstName  = orderVM.FirstName;
            order.LastName   = orderVM.LastName;
            order.Address    = orderVM.Address;
            order.City       = orderVM.City;
            order.State      = orderVM.State;
            order.postalCode = orderVM.postalCode;
            order.Country    = orderVM.Country;
            order.Phone      = orderVM.Phone;
            order.Email      = User.Identity.Name;
            //order.Total = orderVM.Total;
            order.OrderDate = orderVM.OrderDate;


            if (paymentId != null)
            {
                //string payerID = Session["payerId"].ToString();
                //Mapper.Map<OrderVM, tblOrder>(orderVM);

                order.OrderDate     = DateTime.Now;
                order.PaymentTranID = paymentId;
                order.Total         = Convert.ToDecimal(Session["payment_amt"]);

                order.HasBeenShipped = false;

                //Save Order
                uow.Context.tblOrders.Add(order);
                //uow.GenericRepository<tblOrder>().Add(order);
                uow.Context.SaveChanges();

                List <tblCart> myOrderList = (List <tblCart>)Session["cart"];

                // Add OrderDetail information to the DB for each product purchased.
                for (int i = 0; i < myOrderList.Count; i++)
                {
                    // Create a new OrderDetail object.
                    var myOrderDetail = new tblOrderDetail();
                    myOrderDetail.OrderId   = order.OrderId;
                    myOrderDetail.ProductId = Convert.ToInt32(Session["productID"]);
                    myOrderDetail.Quantity  = Convert.ToInt32(Session["quantity"]);
                    myOrderDetail.UnitPrice = Convert.ToDecimal(Session["eachprodprice"]);

                    // Add OrderDetail to DB.
                    uow.Context.tblOrderDetails.Add(myOrderDetail);
                    uow.Context.SaveChanges();
                }

                return(RedirectToAction("OrderComplete", new { id = order.OrderId }));
            }
            return(View("FailureView"));
        }
Exemplo n.º 20
0
        private void SyncOrderItems(SalesOrder salesOrder, tblOrder tblOrder)
        {
            var detailsToDelete = tblOrder.tblOrderDetails.ToList();

            var nowODetail = DateTime.UtcNow.ConvertUTCToLocal().RoundMillisecondsForSQL();
            var oDetail    = OldContext.tblOrderDetails.Any() ? OldContext.tblOrderDetails.Max(o => o.ODetail) : nowODetail;

            if (oDetail < nowODetail)
            {
                oDetail = nowODetail;
            }

            var nowEntryDate  = DateTime.UtcNow.ConvertUTCToLocal().RoundMillisecondsForSQL();
            var lastEntryDate = OldContext.tblStagedFGs.Select(f => f.EntryDate).DefaultIfEmpty(nowEntryDate).Max();

            if (lastEntryDate < nowEntryDate)
            {
                lastEntryDate = nowEntryDate;
            }

            foreach (var orderItem in salesOrder.SalesOrderItems)
            {
                var detail = detailsToDelete.FirstOrDefault(d => d.ODetail == orderItem.ODetail);
                if (detail != null)
                {
                    detailsToDelete.Remove(detail);
                }
                else
                {
                    oDetail = oDetail.AddSeconds(1);
                    detail  = new tblOrderDetail
                    {
                        ODetail      = oDetail,
                        s_GUID       = Guid.NewGuid(),
                        tblStagedFGs = new EntityCollection <tblStagedFG>()
                    };
                    tblOrder.tblOrderDetails.Add(detail);
                    orderItem.ODetail = detail.ODetail;
                    _commitNewContext = true;
                }

                var product   = OldContextHelper.GetProduct(orderItem.InventoryPickOrderItem.Product.ProductCode);
                var packaging = OldContextHelper.GetPackaging(orderItem.InventoryPickOrderItem.PackagingProduct);
                var treatment = OldContextHelper.GetTreatment(orderItem.InventoryPickOrderItem);

                detail.OrderNum        = orderItem.Order.InventoryShipmentOrder.MoveNum.Value;
                detail.ProdID          = product.ProdID;
                detail.PkgID           = packaging.PkgID;
                detail.Quantity        = orderItem.InventoryPickOrderItem.Quantity;
                detail.TrtmtID         = treatment.TrtmtID;
                detail.Price           = (decimal?)orderItem.PriceBase;
                detail.FreightP        = (decimal?)orderItem.PriceFreight;
                detail.TrtnmntP        = (decimal?)orderItem.PriceTreatment;
                detail.WHCostP         = (decimal?)orderItem.PriceWarehouse;
                detail.Rebate          = (decimal?)orderItem.PriceRebate;
                detail.KDetailID       = orderItem.ContractItem == null ? null : orderItem.ContractItem.KDetailID;
                detail.CustProductCode = orderItem.InventoryPickOrderItem.CustomerProductCode;
                detail.CustLot         = orderItem.InventoryPickOrderItem.CustomerLotCode;

                SyncPickedItems(tblOrder, orderItem, ref lastEntryDate, detail);
            }

            foreach (var detail in detailsToDelete)
            {
                foreach (var staged in detail.tblStagedFGs)
                {
                    OldContext.tblStagedFGs.DeleteObject(staged);
                }
                OldContext.tblOrderDetails.DeleteObject(detail);
            }
        }
Exemplo n.º 21
0
        private void SyncPickedItems(tblOrder tblOrder, SalesOrderItem orderItem, ref DateTime lastEntryDate, tblOrderDetail detail)
        {
            var stagedToDelete = detail.tblStagedFGs.ToDictionary(s => s.EntryDate);

            foreach (var picked in orderItem.PickedItems ?? new List <SalesOrderPickedItem>())
            {
                tblStagedFG staged;
                if (picked.PickedInventoryItem.DetailID != null && stagedToDelete.TryGetValue(picked.PickedInventoryItem.DetailID.Value, out staged))
                {
                    stagedToDelete.Remove(staged.EntryDate);
                }
                else
                {
                    lastEntryDate = lastEntryDate.AddSeconds(1);
                    staged        = new tblStagedFG
                    {
                        EntryDate = lastEntryDate,
                        s_GUID    = Guid.NewGuid()
                    };
                    detail.tblStagedFGs.Add(staged);
                    picked.PickedInventoryItem.DetailID = staged.EntryDate;
                    _commitNewContext = true;
                }

                var packaging = OldContextHelper.GetPackaging(picked.PickedInventoryItem.PackagingProduct);
                var treatment = OldContextHelper.GetTreatment(picked.PickedInventoryItem);

                staged.OrderNum        = tblOrder.OrderNum;
                staged.ODetail         = detail.ODetail;
                staged.Lot             = LotNumberParser.BuildLotNumber(picked.PickedInventoryItem);
                staged.TTypeID         = (int?)TransType.Batching; //To match logic found in Access (apnd_PickProdTemp) - RI 2016-3-15
                staged.PkgID           = packaging.PkgID;
                staged.Quantity        = picked.PickedInventoryItem.Quantity;
                staged.NetWgt          = packaging.NetWgt;
                staged.TtlWgt          = picked.PickedInventoryItem.Quantity * packaging.NetWgt;
                staged.LocID           = picked.PickedInventoryItem.CurrentLocation.LocID.Value;
                staged.TrtmtID         = treatment.TrtmtID;
                staged.EmployeeID      = picked.PickedInventoryItem.PickedInventory.EmployeeId;
                staged.CustProductCode = picked.PickedInventoryItem.CustomerProductCode;
                staged.CustLot         = picked.PickedInventoryItem.CustomerLotCode;

                staged.AstaCalc = null;
                var asta = picked.PickedInventoryItem.Lot.Attributes.FirstOrDefault(a => a.AttributeShortName == GlobalKeyHelpers.AstaAttributeNameKey.AttributeNameKey_ShortName);
                if (asta != null)
                {
                    var productionEnd = asta.AttributeDate;
                    if (picked.PickedInventoryItem.Lot.ChileLot != null && picked.PickedInventoryItem.Lot.ChileLot.Production != null && picked.PickedInventoryItem.Lot.ChileLot.Production.Results != null)
                    {
                        productionEnd = picked.PickedInventoryItem.Lot.ChileLot.Production.Results.ProductionEnd;
                    }
                    staged.AstaCalc = AstaCalculator.CalculateAsta(asta.AttributeValue, asta.AttributeDate, productionEnd, DateTime.UtcNow);
                }

                staged.LoBac = false;
                if (picked.PickedInventoryItem.Lot.ChileLot != null)
                {
                    staged.LoBac = picked.PickedInventoryItem.Lot.ChileLot.AllAttributesAreLoBac;
                }
            }

            foreach (var staged in stagedToDelete.Values)
            {
                OldContext.tblStagedFGs.DeleteObject(staged);
            }
        }
Exemplo n.º 22
0
        public JsonResult Save_Admin_Order_And_Detail(tblOrder[] oder, tblOrderDetail[] oderdetail, string Room)
        {
            var value = true;

            try
            {
                var id_tang = 1;
                var oderid  = oder[0].Id;
                var de      = db.tblOrderDetails.Where(x => x.OrderId == oderid).OrderByDescending(x => x.Id_tang).Take(1).ToArray();
                if (de.Any())
                {
                    id_tang = de[0].Id_tang + 1;
                }
                List <tblOrderDetail>     tonghop         = new List <tblOrderDetail>();
                List <tblStaffInEmployee> TongHopEmployee = new List <tblStaffInEmployee> {
                };
                var Oder = db.tblOrders.Find(oder[0].Id);
                Oder.LastDayCheckin  = oder[0].LastDayCheckin;
                Oder.LastHourCheckin = oder[0].LastHourCheckin;
                Oder.FirtDayCheckin  = oder[0].FirtDayCheckin;
                Oder.FirtHourCheckin = oder[0].FirtHourCheckin;
                Oder.Chay            = 1;
                Oder.NhanVienID      = Convert.ToInt32(Session["userid"]);
                foreach (var item in oderdetail)
                {
                    var detail = db.tblOrderDetails.Find(oder[0].Id, item.Id_tang);
                    if (detail == null)
                    {
                        var tail = new tblOrderDetail();
                        tail.Id_tang    = id_tang;
                        tail.EmployeeId = item.EmployeeId;
                        tail.TypeOder   = item.TypeOder;
                        tail.OrderId    = oder[0].Id;
                        tail.Money      = item.Money;
                        db.tblOrderDetails.Add(tail);
                        id_tang++;
                        if (item.TypeOder == "Employee")
                        {
                            var employee = db.tblStaffInEmployees.Find(Convert.ToInt32(item.EmployeeId));
                            if (employee != null)
                            {
                                employee.E_Status = 1;
                                TongHopEmployee.Add(employee);
                            }
                        }
                    }
                    else
                    {
                        if (item.TypeOder == "Employee")
                        {
                            var employee = db.tblStaffInEmployees.Find(Convert.ToInt32(item.EmployeeId));
                            if (employee != null)
                            {
                                employee.E_Status = 1;
                                TongHopEmployee.Add(employee);
                            }
                        }
                        detail.EmployeeId = item.EmployeeId;
                        detail.TypeOder   = item.TypeOder;
                        tonghop.Add(detail);
                    }
                }
                List <tblRoom> TongHopRoom = new List <tblRoom> {
                };
                var array_status           = Room.Split('|');
                for (var i = 0; i < array_status.Length; i++)
                {
                    var room = db.tblRooms.Find(Convert.ToInt32(array_status[i]));
                    if (room != null)
                    {
                        var tail = new tblOrderDetail();
                        tail.Id_tang    = id_tang;
                        tail.EmployeeId = Convert.ToInt32(array_status[i]);
                        tail.TypeOder   = "Room";
                        tail.Money      = 0;
                        tail.OrderId    = oder[0].Id;
                        db.tblOrderDetails.Add(tail);
                        room.R_Status = 1;
                        TongHopRoom.Add(room);
                        id_tang++;
                    }
                }
                var Id_oder_employee = db.tblOrderDetails.Where(x => x.OrderId == oderid && x.TypeOder == "Employee").ToList();
                if (Id_oder_employee.Any())
                {
                    foreach (var item2 in Id_oder_employee)
                    {
                        var update_status_id_employee = db.tblStaffInEmployees.Find(item2.EmployeeId);
                        update_status_id_employee.E_Status = 2;
                    }
                }
                db.SaveChanges();
            }
            catch (Exception)
            {
                value = false;
            }
            var data = new { success = value, message = "Your request has been successfully added,." };

            return(Json(data, JsonRequestBehavior.AllowGet));
        }
 public static void delete(tblOrderDetail t)
 {
     db = new db_MiletecDataContext();
     db.sp_DeleteOrderDetails(t.OrderID,t.ProdID);
 }
Exemplo n.º 24
0
        public ActionResult AddOrder(string name, string phone)
        {
            try
            {
                const string address = "Hà Nội";
                const string email   = "*****@*****.**";

                var order = new tblOrder()
                {
                    Address       = address,
                    CustomerName  = name,
                    Phone         = phone,
                    Email         = email,
                    DateCreated   = DateTime.Now,
                    DateUpdated   = DateTime.Now,
                    OrderStatusID = 1,
                    TotalCost     = decimal.Zero,
                    IsViewed      = false,
                    IsDeleted     = false
                };

                if (CustomerIdentity.Customer.IsLogged)
                {
                    order.CustomerID = CustomerIdentity.Customer.Info.ID;
                }

                var orderShipping = new tblOrder_Shipping()
                {
                    Address      = address,
                    CustomerName = name,
                    Phone        = phone,
                    Email        = email
                };

                var orderDetail = new tblOrderDetail()
                {
                    Price            = 0,
                    ProductID        = 155,
                    ProductVariantID = 303,
                    Quantity         = 1
                };

                orderRepositoryFE.AddOrder(order, orderDetail, orderShipping);

                return(Json(new
                {
                    error = false,
                    message = "Đặt hàng thành công !"
                }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                Elmah.ErrorLog.GetDefault(null).Log(new Elmah.Error(ex));
            }

            return(Json(new
            {
                error = true,
                message = "Đặt hàng không thành công. Bạn hãy thử lại !"
            }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 25
0
        public JsonResult Save_Oder(AddOder_View_To_Admin[] Oder, String Note, String CODE, int Id_Sale, int phantramgiam)
        {
            var value    = false;
            var O_number = "";

            try
            {
                var ordernew = new tblOrder();
                var layid    = (from O in db.tblOrders
                                where O.Id > 0
                                orderby O.Id descending
                                select new
                {
                    Id = O.Id
                }).Take(1).ToArray();

                if (layid.Any())
                {
                    ordernew.Id = layid[0].Id + 1;
                }
                else
                {
                    ordernew.Id = 1;
                }
                if (Id_Sale > 0)
                {
                    ordernew.Id_Code_sale = Id_Sale;
                }
                else
                {
                    ordernew.Id_Code_sale = 0;
                }
                if (phantramgiam > 0)
                {
                    ordernew.phantramgiam = phantramgiam;
                }
                else
                {
                    ordernew.phantramgiam = 0;
                }
                ordernew.DayNew     = DateTime.Now;
                ordernew.O_number   = CODE;
                O_number            = ordernew.O_number;
                ordernew.Note       = Note;
                ordernew.NhanVienID = 1;
                ordernew.Chay       = 0;
                db.tblOrders.Add(ordernew);
                var idtang = 1;
                foreach (var item in Oder)
                {
                    tblOrderDetail orderdetailnew = new tblOrderDetail();
                    if (item.ID > 0)
                    {
                        orderdetailnew.Id_tang    = idtang;
                        orderdetailnew.EmployeeId = item.ID;
                        orderdetailnew.Money      = item.money;
                        orderdetailnew.OrderId    = ordernew.Id;
                        orderdetailnew.TypeOder   = item.Type;
                        db.tblOrderDetails.Add(orderdetailnew);
                        idtang++;
                    }
                }
                db.SaveChanges();
                value = true;
            }
            catch (Exception)
            {
                value = false;
            }
            var data = new { success = value, O_number = O_number, message = "Your request has been successfully added,." };

            return(Json(data, JsonRequestBehavior.AllowGet));
        }