Esempio n. 1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string _res = string.Empty;

            using (var ctx = new RachnaDBContext())
            {
                int   productId     = Convert.ToInt32(hdnOrderId.Value);
                Order _productOrder = new Order();
                _productOrder = ctx.Orders.ToList().Where(m => m.Order_Id == productId).FirstOrDefault();

                if (_productOrder.Order_Status != eOrderStatus.Rejected.ToString())
                {
                    if (_productOrder.Order_Status != ddlSorderStatus.Text)
                    {
                        if (_productOrder.Order_Status ==
                            eOrderStatus.Approved.ToString() &&
                            ddlSorderStatus.Text == eOrderStatus.Placed.ToString())
                        {
                            Page.ClientScript.RegisterStartupScript(this.GetType(), "Order", "new Messi('update failed because, order status is lower then current.', { title: 'Failed!! ' });", true);
                        }
                        else if (_productOrder.Order_Status ==
                                 eOrderStatus.Packed.ToString() &&
                                 (ddlSorderStatus.Text == eOrderStatus.Placed.ToString() ||
                                  ddlSorderStatus.Text == eOrderStatus.Approved.ToString() ||
                                  ddlSorderStatus.Text == eOrderStatus.Packed.ToString()))
                        {
                            Page.ClientScript.RegisterStartupScript(this.GetType(), "Order", "new Messi('update failed because, order status is lower then current.', { title: 'Failed!! ' });", true);
                        }
                        else if (_productOrder.Order_Status == eOrderStatus.Shipped.ToString() &&
                                 (ddlSorderStatus.Text == eOrderStatus.Placed.ToString() ||
                                  ddlSorderStatus.Text == eOrderStatus.Approved.ToString()))
                        {
                            Page.ClientScript.RegisterStartupScript(this.GetType(), "Order", "new Messi('update failed because, order status is lower then current.', { title: 'Failed!! ' });", true);
                        }
                        else if (ddlSorderStatus.Text == eOrderStatus.Placed.ToString() ||
                                 ddlSorderStatus.Text == eOrderStatus.Approved.ToString() ||
                                 ddlSorderStatus.Text == eOrderStatus.Packed.ToString() ||
                                 ddlSorderStatus.Text == eOrderStatus.Shipped.ToString())
                        {
                            Page.ClientScript.RegisterStartupScript(this.GetType(), "Order", "new Messi('update failed because, order status is lower then current.', { title: 'Failed!! ' });", true);
                        }
                        else
                        {
                            _productOrder.Order_Status     = ddlSorderStatus.Text;
                            ctx.Entry(_productOrder).State = EntityState.Modified;
                            ctx.SaveChanges();

                            var            adminId      = Convert.ToInt32(Session[ConfigurationSettings.AppSettings["AdminSession"].ToString()]);
                            Administrators _adm         = ctx.Administrator.Where(m => m.Administrators_Id == adminId).FirstOrDefault();
                            OrderHistory   _orderCancel = new OrderHistory();
                            _orderCancel.Order_Id = Convert.ToInt32(hdnOrderId.Value);
                            _orderCancel.OrderHistory_Description = txtOrderDescription.Text;
                            _orderCancel.OrderHistory_Status      = ddlSorderStatus.Text;
                            _orderCancel.OrderHistory_CreatedDate = DateTime.Now;
                            _orderCancel.OrderHistory_UpdatedDate = DateTime.Now;
                            _orderCancel.Administrators_Id        = _adm.Administrators_Id;
                            _orderCancel.Store_Id = _adm.Store_Id;

                            ctx.OrderHistories.Add(_orderCancel);
                            ctx.SaveChanges();

                            if (pnlDeleveryTeam.Visible == true)
                            {
                                OrderDelivery OrderDelivery = new OrderDelivery()
                                {
                                    Order_Id          = _productOrder.Order_Id,
                                    Administrators_Id = Convert.ToInt32(Session[ConfigurationSettings.AppSettings["AdminSession"].ToString()].ToString()),
                                    TeamId            = Convert.ToInt32(ddlDelieveryTeam.SelectedValue.ToString()),
                                    Comment           = txtOrderDescription.Text,
                                    Status            = eOrderDeliveryStatus.InTransist.ToString(),
                                    Store_Id          = _productOrder.Store_Id,
                                    Customer_Id       = _productOrder.Customer_Id,
                                    DateCreated       = DateTime.Now,
                                    DateUpdated       = DateTime.Now
                                };

                                ctx.OrderDelivery.Add(OrderDelivery);
                                ctx.SaveChanges();
                            }

                            Customers _cust = ctx.Customer.ToList().Where(m => m.Customer_Id == Convert.ToInt32(_productOrder.Customer_Id)).FirstOrDefault();

                            string productUrl = "http://rachnateracotta.com/product/index?id=" + _productOrder.Product_Id;
                            _res = _res + "<tr style='border: 1px solid black;'><td style='border: 1px solid black;'><img src='" + _productOrder.Product_Banner + "' width='100' height='100'/></td>"
                                   + "<td style='border: 1px solid black;'><a href='" + productUrl + "'>" + _productOrder.Product_Title + "</a></td><td style='border: 1px solid black;'> Total Quantity :" + _productOrder.Order_Qty + " </td><td style='border: 1px solid black;'> " + _productOrder.Order_Price + " </td></tr>";

                            if (Convert.ToBoolean(ConfigurationSettings.AppSettings["IsEmailEnable"]))
                            {
                                string host = string.Empty;
                                host = "<table style='width:100%'>" + _res + "</ table >";
                                string body = MailHelper.CustomerOrderProcessed(host, (_cust.Customers_FullName), txtOrderDescription.Text);
                                MailHelper.SendEmail(_cust.Customers_EmailId, "Success!!! " + txtOrderDescription.Text + " Rachna Teracotta Estore.", body, "Rachna Teracotta Order" + txtOrderDescription.Text);
                            }

                            Response.Redirect("/adminvendor/salesmanagement/vorderdetail.aspx?orderId=" + hdnOrderId.Value + "&requesttype=view-order-detail.html");
                        }
                    }
                    else
                    {
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "Order", "new Messi('update failed because, order status is same as current.', { title: 'Failed!! ' });", true);
                    }
                }
                else
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "Order", "new Messi('update failed because, order status is not valid.', { title: 'Failed!! ' });", true);
                }
            }
        }
        protected void btnAddToFeature_Click(object sender, EventArgs e)
        {
            string _res = string.Empty;

            using (var ctx = new RachnaDBContext())
            {
                int   productId     = Convert.ToInt32(hdnOrderId.Value);
                int   delOrderId    = Convert.ToInt32(hdnDelId.Value);
                Order _productOrder = new Order();
                _productOrder = ctx.Orders.ToList().Where(m => m.Order_Id == productId).FirstOrDefault();
                OrderDelivery OrderDelivery = ctx.OrderDelivery.Include("Order").Where(m => m.Order_Delivery_Id == delOrderId).FirstOrDefault();


                _productOrder.Order_Status     = ddlSorderStatus.Text;
                ctx.Entry(_productOrder).State = EntityState.Modified;
                ctx.SaveChanges();

                OrderDelivery.Status           = ddlSorderStatus.Text;
                ctx.Entry(OrderDelivery).State = EntityState.Modified;
                ctx.SaveChanges();

                OrderHistory OrderHistory = new OrderHistory();
                OrderHistory.Order_Id = Convert.ToInt32(hdnOrderId.Value);
                OrderHistory.OrderHistory_Description = txtOrderDescription.Text;
                OrderHistory.OrderHistory_Status      = ddlSorderStatus.Text;
                OrderHistory.OrderHistory_CreatedDate = DateTime.Now;
                OrderHistory.OrderHistory_UpdatedDate = DateTime.Now;
                OrderHistory.Administrators_Id        = OrderDelivery.Administrators_Id;
                OrderHistory.Store_Id = OrderDelivery.Store_Id;

                ctx.OrderHistories.Add(OrderHistory);
                ctx.SaveChanges();

                Customers _cust = ctx.Customer.ToList().Where(m => m.Customer_Id == Convert.ToInt32(_productOrder.Customer_Id)).FirstOrDefault();

                string productUrl = "http://rachnateracotta.com/product/index?id=" + _productOrder.Product_Id;
                _res = _res + "<tr style='border: 1px solid black;'><td style='border: 1px solid black;'><img src='" + _productOrder.Product_Banner + "' width='100' height='100'/></td>"
                       + "<td style='border: 1px solid black;'><a href='" + productUrl + "'>" + _productOrder.Product_Title + "</a></td><td style='border: 1px solid black;'> Total Quantity :" + _productOrder.Order_Qty + " </td><td style='border: 1px solid black;'> " + _productOrder.Order_Price + " </td></tr>";

                if (Convert.ToBoolean(ConfigurationSettings.AppSettings["IsEmailEnable"]))
                {
                    string host = string.Empty;
                    host = "<table style='width:100%'>" + _res + "</ table >";
                    string body = MailHelper.CustomerOrderProcessed(host, (_cust.Customers_FullName), txtOrderDescription.Text);
                    MailHelper.SendEmail(_cust.Customers_EmailId, "Success!!! " + txtOrderDescription.Text + " Rachna Teracotta Estore.", body, "Rachna Teracotta Order" + txtOrderDescription.Text);
                }

                if (OrderDelivery.Status == eOrderDeliveryStatus.DelveryCompleted.ToString())
                {
                    Product Product = bProduct.List().Where(m => m.Product_Id == OrderDelivery.Order.Product_Id).FirstOrDefault();
                    int     qty     = (Product.Product_Qty - OrderDelivery.Order.Order_Qty);
                    Product.Product_Qty         = qty;
                    Product.Product_UpdatedDate = DateTime.Now;
                    Product.Administrators_Id   = 1;

                    bProduct.Update(Product);
                }

                Response.Redirect("/admindelivery/deliveryhome.aspx?id=200&requesttype=view-order-detail.html");
            }
        }