public void ApplicationSetUp()
        {
            using (var context = new RachnaDBContext())
            {
                context.Store.AddOrUpdate(
                    p => p.Store_Name,
                    new Stores
                {
                    StoreCode         = "RT1STRECODE2",
                    Store_Name        = "Rachna Teracotta EStore",
                    Store_Logo        = "content/noimage.png",
                    Store_Url         = ConfigurationSettings.AppSettings["CurrentDomain"].ToString(),
                    Store_Status      = eStatus.Active.ToString(),
                    Store_CreatedDate = DateTime.Now,
                    Store_UpdatedDate = DateTime.Now
                }
                    );

                context.SaveChanges();

                context.Invitation.AddOrUpdate(
                    p => p.Invitation_EmailId,
                    new Invitations
                {
                    Store_Id               = context.Store.Where(m => m.Store_Name == "Rachna Teracotta EStore").FirstOrDefault().Store_Id,
                    Invitation_Code        = "RT1INVTCODE2",
                    Invitation_EmailId     = "*****@*****.**",
                    Invitation_CreatedDate = DateTime.Now,
                    Invitation_Status      = eStatus.InActive.ToString(),
                    Role = eRole.Super.ToString(),
                    Invitation_UpdatedDate = DateTime.Now
                }
                    );

                context.SaveChanges();

                context.Administrator.AddOrUpdate(
                    p => p.EmailId,
                    new Administrators
                {
                    Invitation_Id       = context.Invitation.Where(m => m.Invitation_EmailId == "*****@*****.**").FirstOrDefault().Invitation_Id,
                    AdminCode           = "RT1ADMCODE2",
                    FullName            = "System",
                    EmailId             = "*****@*****.**",
                    Phone               = "9999999999",
                    Description         = "rachnateracotta admin description should be here",
                    Photo               = "content/noimage.png",
                    Password            = PasswordProtect.Encrypt("Admin@123"),
                    Admin_Status        = eStatus.Active.ToString(),
                    Admin_Role          = eRole.Super.ToString(),
                    Admin_CreatedDate   = DateTime.Now,
                    Admin_UpdatedDate   = DateTime.Now,
                    Admin_Login_Attempt = 0,
                    Store_Id            = context.Store.Where(m => m.Store_Name == "Rachna Teracotta EStore").FirstOrDefault().Store_Id,
                }
                    );

                context.SaveChanges();

                context.Customer.AddOrUpdate(
                    p => p.Customers_FullName,
                    new Customers
                {
                    CustomerCode            = "RT1CUSTCODE2",
                    CustomerType            = eCustomerType.guest.ToString(),
                    Customers_FullName      = "Rachna Guest",
                    Customers_EmailId       = "*****@*****.**",
                    Customers_Phone         = "5656789098",
                    Customers_Description   = "Rachna Guest",
                    Customers_Login_Attempt = 0,
                    Customers_Password      = PasswordProtect.Encrypt("Aadmin@123"),
                    Customers_Photo         = "content/noimage.png",
                    IsEmailVerified         = 1,
                    Customers_CreatedDate   = DateTime.Now,
                    Customers_UpdatedDate   = DateTime.Now,
                    Customers_Status        = eStatus.Active.ToString()
                }
                    );

                context.SaveChanges();

                context.PaymentMethod.AddOrUpdate(
                    p => p.Title,
                    new PaymentMethod
                {
                    Title       = "Cash On Delivery",
                    Description = "Cash on delivery (COD), sometimes called collect on delivery, is the sale of goods by mail order where payment is made on delivery rather than in advance.",
                    Status      = eStatus.Active.ToString(),
                    DateCreated = DateTime.Now,
                    DateUpdated = DateTime.Now
                },
                    new PaymentMethod
                {
                    Title       = "Net Banking",
                    Description = "You can pay your order payment through net banking facility of various bank accounts.",
                    Status      = eStatus.InActive.ToString(),
                    DateCreated = DateTime.Now,
                    DateUpdated = DateTime.Now
                },
                    new PaymentMethod
                {
                    Title       = "Credit/Debit Card",
                    Description = "You can pay your order payment through credit/debit card facility of various bank accounts.",
                    Status      = eStatus.InActive.ToString(),
                    DateCreated = DateTime.Now,
                    DateUpdated = DateTime.Now
                }
                    );

                context.SaveChanges();

                context.PaymentMethod.AddOrUpdate(
                    p => p.Title,
                    new PaymentMethod
                {
                    Title       = "Cash On Delivery",
                    Description = "Cash on delivery (COD), sometimes called collect on delivery, is the sale of goods by mail order where payment is made on delivery rather than in advance.",
                    Status      = eStatus.Active.ToString(),
                    DateCreated = DateTime.Now,
                    DateUpdated = DateTime.Now
                },
                    new PaymentMethod
                {
                    Title       = "Net Banking",
                    Description = "You can pay your order payment through net banking facility of various bank accounts.",
                    Status      = eStatus.InActive.ToString(),
                    DateCreated = DateTime.Now,
                    DateUpdated = DateTime.Now
                },
                    new PaymentMethod
                {
                    Title       = "Credit/Debit Card",
                    Description = "You can pay your order payment through credit/debit card facility of various bank accounts.",
                    Status      = eStatus.InActive.ToString(),
                    DateCreated = DateTime.Now,
                    DateUpdated = DateTime.Now
                }
                    );

                context.SaveChanges();

                context.DeliveryMethod.AddOrUpdate(
                    p => p.Title,
                    new DeliveryMethod
                {
                    Title       = "By Rachna Team",
                    Description = "Rachna Teracotta takes whole responsibility to deliever to the ordered product.",
                    Status      = eStatus.Active.ToString(),
                    DateCreated = DateTime.Now,
                    DateUpdated = DateTime.Now
                },
                    new DeliveryMethod
                {
                    Title       = "By Courier",
                    Description = "Other Courier Team takes responsibility to deliver the ordered product.",
                    Status      = eStatus.Active.ToString(),
                    DateCreated = DateTime.Now,
                    DateUpdated = DateTime.Now
                }
                    );

                context.SaveChanges();

                context.Pages.AddOrUpdate(
                    p => p.Title,
                    new Pages
                {
                    Title             = "Home",
                    Description       = "Home",
                    Status            = eStatus.Active.ToString(),
                    DateCreated       = DateTime.Now,
                    DateUpdated       = DateTime.Now,
                    Administrators_Id = context.Administrator.Where(m => m.EmailId == "*****@*****.**").FirstOrDefault().Administrators_Id,
                },
                    new Pages
                {
                    Title             = "Offers",
                    Description       = "Offers",
                    Status            = eStatus.Active.ToString(),
                    DateCreated       = DateTime.Now,
                    DateUpdated       = DateTime.Now,
                    Administrators_Id = context.Administrator.Where(m => m.EmailId == "*****@*****.**").FirstOrDefault().Administrators_Id,
                }
                    );

                context.SaveChanges();

                context.RMenu.AddOrUpdate(
                    p => p.Title,
                    new RMenu
                {
                    Title             = "Home",
                    MenuType          = eMenu.Header.ToString(),
                    Page_Id           = 1,
                    Status            = eStatus.Active.ToString(),
                    DateCreated       = DateTime.Now,
                    DateUpdated       = DateTime.Now,
                    Administrators_Id = context.Administrator.Where(m => m.EmailId == "*****@*****.**").FirstOrDefault().Administrators_Id,
                },
                    new RMenu
                {
                    Title             = "Offers",
                    MenuType          = eMenu.Header.ToString(),
                    Page_Id           = 2,
                    Status            = eStatus.Active.ToString(),
                    DateCreated       = DateTime.Now,
                    DateUpdated       = DateTime.Now,
                    Administrators_Id = context.Administrator.Where(m => m.EmailId == "*****@*****.**").FirstOrDefault().Administrators_Id,
                }
                    );

                context.SaveChanges();
            }
        }
        public ActionResult SubmitOrder(string addressId, string paymentType)
        {
            int          custId         = Convert.ToInt32(Session["UserKey"]);
            Customers    _cust          = bCustomer.List().Where(m => m.Customer_Id == custId).FirstOrDefault();
            int          custAdrId      = Convert.ToInt32(addressId);
            int          selPaymentType = Convert.ToInt32(paymentType);
            List <Carts> _cart          = _mcartmdl.GetCarts().Where(m => m.Customer_Id == custId && m.Cart_Status == eCartStatus.Open.ToString()).ToList();
            string       _res           = string.Empty;

            foreach (var item in _cart)
            {
                Product _prd = context.Product.Where(m => m.Product_Id == item.Product_Id).FirstOrDefault();

                Order Orders = new Order()
                {
                    Order_Price          = item.Cart_Price,
                    Order_Qty            = item.Cart_Qty,
                    Order_Size           = item.Cart_Size,
                    Order_Status         = eOrderStatus.Placed.ToString(),
                    Product_Id           = item.Product_Id,
                    Product_Banner       = item.Product_Banner,
                    Product_Price        = item.Product_Price,
                    Product_Title        = item.Product_Title,
                    Customer_Id          = item.Customer_Id,
                    Customer_Name        = item.Customer_Name,
                    CustomerAddress_Id   = custAdrId,
                    Payment_Method_Id    = selPaymentType,
                    Order_Date           = DateTime.Now,
                    Order_Delievery_Date = DateTime.Now.AddDays(_prd.Product_Delivery_Time),
                    Store_Id             = _prd.Store_Id,
                    Order_UpdateDate     = DateTime.Now
                };

                int maxBnrCusAdrAdminId = 1;
                if (context.Orders.ToList().Count > 0)
                {
                    maxBnrCusAdrAdminId = context.Orders.Max(m => m.Order_Id);
                }
                maxBnrCusAdrAdminId = (maxBnrCusAdrAdminId == 1 && context.Orders.ToList().Count > 0) ? (maxBnrCusAdrAdminId + 1) : maxBnrCusAdrAdminId;
                Orders.Order_Code   = "ORDRACH" + maxBnrCusAdrAdminId + "TERA" + (maxBnrCusAdrAdminId + 1);
                context.Orders.Add(Orders);
                context.SaveChanges();

                Administrators _adm           = context.Administrator.Where(m => m.EmailId == "*****@*****.**").FirstOrDefault();
                OrderHistory   OrderHistories = new OrderHistory()
                {
                    Order_Id                 = Orders.Order_Id,
                    OrderHistory_Status      = eOrderStatus.Placed.ToString(),
                    OrderHistory_Description = "Order Submitted successfully on " + DateTime.Now.ToString("D").ToString(),
                    OrderHistory_CreatedDate = DateTime.Now,
                    OrderHistory_UpdatedDate = DateTime.Now,
                    Administrators_Id        = _adm.Administrators_Id,
                    Store_Id                 = Orders.Store_Id
                };

                context.OrderHistories.Add(OrderHistories);
                context.SaveChanges();

                Carts _carts = _mcartmdl.GetCarts().Where(m => m.Cart_Id == item.Cart_Id).FirstOrDefault();
                _mcartmdl.DeleteCartByCartId(_carts);

                string productUrl = "http://rachnateracotta.com/product/index?id=" + item.Product_Id;
                _res = _res + "<tr style='border: 1px solid black;'><td style='border: 1px solid black;'><img src='" + ConfigurationSettings.AppSettings["DomainUrl"].ToString() + item.Product_Banner + "' width='100' height='100'/></td>"
                       + "<td style='border: 1px solid black;'><a href='" + productUrl + "'>" + item.Product_Title + "</a></td><td style='border: 1px solid black;'> Total Quantity :" + item.Cart_Qty + " </td><td style='border: 1px solid black;'> " + item.Cart_Price + " </td></tr>";
            }
            if (Convert.ToBoolean(ConfigurationSettings.AppSettings["IsEmailEnable"]))
            {
                string host = string.Empty;
                host = "<table style='width:100%'>" + _res + "</ table >";
                string body = MailHelper.CustomerOrderPlaced(host, (_cust.Customers_FullName));
                MailHelper.SendEmail(_cust.Customers_EmailId, "Success!!! You Order Placed In Rachna Teracotta Estore.", body, "Rachna Teracotta Order Placed");
            }
            return(Json("success", JsonRequestBehavior.AllowGet));
        }
        protected void btnAddToFeature_Click(object sender, EventArgs e)
        {
            List <ProductFeatures> _features = context.ProductFeature.ToList();

            if (_features.Where(m => m.Product_Feature_Type == Rachna.Teracotta.Project.Source.Entity.eProductFeature.Best.ToString()).Count() > 4 && ddlFeature.Text == Rachna.Teracotta.Project.Source.Entity.eProductFeature.Best.ToString())
            {
                pnlProduct.Visible = false;
                pnlErrorMessage.Attributes.Remove("class");
                pnlErrorMessage.Attributes["class"] = "alert alert-danger alert-dismissable";
                pnlErrorMessage.Visible             = true;
                lblMessage.Text = "There are already 5 items found for selected feature type. If you want to continue please delete the existing item";
            }
            else if (_features.Where(m => m.Product_Feature_Type == eProductFeature.Featured.ToString()).Count() > 4 && ddlFeature.Text == eProductFeature.Featured.ToString())
            {
                pnlProduct.Visible = false;
                pnlErrorMessage.Attributes.Remove("class");
                pnlErrorMessage.Attributes["class"] = "alert alert-danger alert-dismissable";
                pnlErrorMessage.Visible             = true;
                lblMessage.Text = "There are already 5 items found for selected feature type. If you want to continue please delete the existing item";
            }
            else if (_features.Where(m => m.Product_Feature_Type == eProductFeature.Latest.ToString()).Count() > 4 && ddlFeature.Text == eProductFeature.Latest.ToString())
            {
                pnlProduct.Visible = false;
                pnlErrorMessage.Attributes.Remove("class");
                pnlErrorMessage.Attributes["class"] = "alert alert-danger alert-dismissable";
                pnlErrorMessage.Visible             = true;
                lblMessage.Text = "There are already 5 items found for selected feature type. If you want to continue please delete the existing item";
            }
            else if (_features.Where(m => m.Product_Feature_Type == eProductFeature.Top.ToString()).Count() > 4 && ddlFeature.Text == eProductFeature.Top.ToString())
            {
                pnlProduct.Visible = false;
                pnlErrorMessage.Attributes.Remove("class");
                pnlErrorMessage.Attributes["class"] = "alert alert-danger alert-dismissable";
                pnlErrorMessage.Visible             = true;
                lblMessage.Text = "There are already 5 items found for selected feature type. If you want to continue please delete the existing item";
            }
            else if (_features.Where(m => m.Product_Feature_Type == eProductFeature.Hot.ToString()).Count() > 4 && ddlFeature.Text == eProductFeature.Hot.ToString())
            {
                pnlProduct.Visible = false;
                pnlErrorMessage.Attributes.Remove("class");
                pnlErrorMessage.Attributes["class"] = "alert alert-danger alert-dismissable";
                pnlErrorMessage.Visible             = true;
                lblMessage.Text = "There are already 5 items found for selected feature type. If you want to continue please delete the existing item";
            }
            else if (_features.Where(m => m.Product_Feature_Type == eProductFeature.OurChoice.ToString()).Count() > 4 && ddlFeature.Text == eProductFeature.OurChoice.ToString())
            {
                pnlProduct.Visible = false;
                pnlErrorMessage.Attributes.Remove("class");
                pnlErrorMessage.Attributes["class"] = "alert alert-danger alert-dismissable";
                pnlErrorMessage.Visible             = true;
                lblMessage.Text = "There are already 5 items found for selected feature type. If you want to continue please delete the existing item";
            }
            else
            {
                ProductFeatures ProductFeature = new ProductFeatures()
                {
                    Product_Id                  = Convert.ToInt32(lblId.Text),
                    Product_Feature_Type        = ddlFeature.Text,
                    Administrators_Id           = Convert.ToInt32(Session[ConfigurationSettings.AppSettings["AdminSession"].ToString()].ToString()),
                    Product_Feature_CreatedDate = DateTime.Now,
                    Product_Feature_UpdatedDate = DateTime.Now
                };

                int maxAdminId = 1;
                if (context.ProductFeature.ToList().Count > 0)
                {
                    maxAdminId = context.ProductFeature.Max(m => m.Product_Feature_Id);
                }
                ProductFeature.Product_Feature_Code = "PRDFETRACH" + maxAdminId + "TERA" + (maxAdminId + 1);
                context.ProductFeature.Add(ProductFeature);
                context.SaveChanges();

                pnlErrorMessage.Attributes.Remove("class");
                pnlErrorMessage.Attributes["class"] = "alert alert-success alert-dismissable";
                pnlErrorMessage.Visible             = true;
                lblMessage.Text    = "Selected Product Added to the feature list Successfully.";
                pnlProduct.Visible = false;
                LoadDetail();
            };
        }
        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");
            }
        }
Esempio n. 5
0
        private void InsertExcelRecords(string FilePath)
        {
            List <Product> _products   = new List <Product>();
            var            csvData     = System.IO.File.ReadAllLines(FilePath).Skip(1);
            int            insertCount = 0;
            int            updateCount = 0;

            try
            {
                //Execute a loop over the rows.
                foreach (string row in csvData)
                {
                    if (!string.IsNullOrEmpty(row))
                    {
                        if (row != ",,,,,,,,,,,,,,,,")
                        {
                            _products.Add(new Product
                            {
                                Product_Id             = Convert.ToInt32(row.Split(',')[0]),
                                SubCategory_Id         = Convert.ToInt32(row.Split(',')[1]),
                                Product_Title          = row.Split(',')[2],
                                Product_Description    = row.Split(',')[3],
                                Product_Specification  = row.Split(',')[4],
                                Product_Qty            = Convert.ToInt32(row.Split(',')[5]),
                                Product_Qty_Alert      = Convert.ToInt32(row.Split(',')[6]),
                                Product_Delivery_Time  = Convert.ToInt32(row.Split(',')[7]),
                                Product_Max_Purchase   = Convert.ToInt32(row.Split(',')[8]),
                                Product_Mkt_Price      = Convert.ToDecimal(row.Split(',')[9]),
                                Product_Our_Price      = Convert.ToDecimal(row.Split(',')[10]),
                                Product_ShippingCharge = Convert.ToDecimal(row.Split(',')[11]),
                                Product_Has_Size       = Convert.ToBoolean(row.Split(',')[12].ToLower()),
                                Product_Size           = row.Split(',')[13],
                                Product_Avail_ZipCode  = row.Split(',')[14],
                                Product_Discount       = Convert.ToDecimal(row.Split(',')[15]),
                                Product_CreatedDate    = DateTime.Now,
                                Product_UpdatedDate    = DateTime.Now,
                                Product_Status         = eProductStatus.ReviewPending.ToString()
                            });
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }

            int            AdminId = Convert.ToInt32(Session[ConfigurationSettings.AppSettings["AdminSession"].ToString()].ToString());
            Administrators _admin  = context.Administrator.ToList().Where(m => m.Administrators_Id == AdminId).FirstOrDefault();

            foreach (var item in _products)
            {
                SubCategories _subCategory = context.SubCategory.Where(m => m.SubCategory_Id == item.SubCategory_Id).FirstOrDefault();
                item.Administrators_Id = _admin.Administrators_Id;
                item.Store_Id          = _admin.Store_Id;
                if (_subCategory != null)
                {
                    if (item.Product_Id == 0)
                    {
                        Product Product = new Product()
                        {
                            Store_Id               = _admin.Store_Id,
                            Product_Title          = item.Product_Title,
                            Product_Description    = item.Product_Description,
                            Product_Specification  = item.Product_Specification,
                            Administrators_Id      = _admin.Administrators_Id,
                            Product_Qty            = item.Product_Qty,
                            Product_Qty_Alert      = item.Product_Qty_Alert,
                            Product_Delivery_Time  = item.Product_Delivery_Time,
                            Product_Max_Purchase   = item.Product_Max_Purchase,
                            Product_Mkt_Price      = item.Product_Mkt_Price,
                            Product_Our_Price      = item.Product_Our_Price,
                            Product_ShippingCharge = item.Product_ShippingCharge,
                            Product_Has_Size       = item.Product_Has_Size,
                            Product_Size           = (item.Product_Has_Size == true) ? item.Product_Size : "No Size",
                            Product_Avail_ZipCode  = item.Product_Avail_ZipCode,
                            Product_Discount       = item.Product_Discount,
                            SubCategory_Id         = item.SubCategory_Id,
                            Product_CreatedDate    = item.Product_CreatedDate,
                            Product_UpdatedDate    = item.Product_UpdatedDate,
                            Product_Status         = item.Product_Status
                        };
                        try
                        {
                            int maxAdminId = 1;
                            if (context.Product.ToList().Count > 0)
                            {
                                maxAdminId = context.Product.Max(m => m.Product_Id);
                            }
                            maxAdminId          = (maxAdminId == 1 && context.Product.ToList().Count > 0) ? (maxAdminId + 1) : maxAdminId;
                            Product.ProductCode = "PRDTRACH" + maxAdminId + "TERA" + (maxAdminId + 1);
                            context.Product.Add(Product);
                            context.SaveChanges();

                            ProductHelper.CreateProductFlow(Product.Product_Id, Product.Product_Title, _admin.Administrators_Id, _admin.FullName, "New Product Created", Product.Product_Status);

                            item.Product_Id = Product.Product_Id;
                            insertCount     = insertCount + 1;
                            ProductBanners ProductBanner = new ProductBanners()
                            {
                                Product_Id                 = Product.Product_Id,
                                Administrators_Id          = Convert.ToInt32(Session[ConfigurationSettings.AppSettings["AdminSession"].ToString()].ToString()),
                                Product_Banner_Default     = 1,
                                Product_Banner_Photo       = "content/noimage.png",
                                Product_Banner_CreatedDate = DateTime.Now,
                                Product_Banner_UpdatedDate = DateTime.Now
                            };

                            int maxBnrAdminId = 1;
                            if (context.ProductBanner.ToList().Count > 0)
                            {
                                maxBnrAdminId = context.ProductBanner.Max(m => m.Product_Id);
                            }
                            maxBnrAdminId = (maxBnrAdminId == 1 && context.ProductBanner.ToList().Count > 0) ? (maxBnrAdminId + 1) : maxBnrAdminId;
                            ProductBanner.Product_BannerCode = "PRDBNRTRACH" + maxBnrAdminId + "TERA" + (maxBnrAdminId + 1);
                            context.ProductBanner.Add(ProductBanner);
                            context.SaveChanges();
                        }
                        catch
                        {
                        }
                    }
                    else
                    {
                        Product _product = context.Product.ToList().Where(m => m.Product_Id == item.Product_Id).FirstOrDefault();
                        if (_product != null)
                        {
                            _product.Store_Id               = _admin.Store_Id;
                            _product.Product_Title          = item.Product_Title;
                            _product.Product_Description    = item.Product_Description;
                            _product.Product_Specification  = item.Product_Specification;
                            _product.Administrators_Id      = _admin.Administrators_Id;
                            _product.Product_Qty            = item.Product_Qty;
                            _product.Product_Qty_Alert      = item.Product_Qty_Alert;
                            _product.Product_Delivery_Time  = item.Product_Delivery_Time;
                            _product.Product_Max_Purchase   = item.Product_Max_Purchase;
                            _product.Product_Mkt_Price      = item.Product_Mkt_Price;
                            _product.Product_Our_Price      = item.Product_Our_Price;
                            _product.Product_ShippingCharge = item.Product_ShippingCharge;
                            _product.Product_Size           = item.Product_Size;
                            _product.Product_Avail_ZipCode  = item.Product_Title;
                            _product.Product_Discount       = item.Product_Discount;
                            _product.SubCategory_Id         = item.SubCategory_Id;
                            _product.Product_UpdatedDate    = item.Product_UpdatedDate;
                            _product.Product_Status         = item.Product_Status;

                            try
                            {
                                updateCount = updateCount + 1;
                                context.Entry(_product).State = System.Data.Entity.EntityState.Modified;
                                context.SaveChanges();
                            }
                            catch
                            {
                            }
                        }
                        else
                        {
                            item.Product_Status = "Invalid Product Id";
                        }
                    }
                }
                else
                {
                    item.Product_Status = "Invalid Sub Category Id";
                }
            }
            pnlErrorMessage.Attributes.Remove("class");
            pnlErrorMessage.Attributes["class"] = "alert alert-success alert-dismissable";
            pnlErrorMessage.Visible             = true;
            lblMessage.Text = "We are done!! " + insertCount + " Products Inserted and " + updateCount + " Products Updated Successfully also we have dowloaded the updated excel. Please check your download folder.";

            DataTable dt = ConvertToDataTable(_products);

            Response.ClearContent();
            Response.Buffer = true;
            Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", "Products.xls"));
            Response.ContentType = "application/ms-excel";
            string str = string.Empty;

            foreach (DataColumn dtcol in dt.Columns)
            {
                Response.Write(str + dtcol.ColumnName);
                str = "\t";
            }
            Response.Write("\n");
            foreach (DataRow dr in dt.Rows)
            {
                str = "";
                for (int j = 0; j < dt.Columns.Count; j++)
                {
                    Response.Write(str + Convert.ToString(dr[j]));
                    str = "\t";
                }
                Response.Write("\n");
            }
            Response.End();
        }
Esempio n. 6
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() ||
                             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 (_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() ||
                                  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 if (_productOrder.Order_Status == eOrderStatus.Delevery.ToString() &&
                                 (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", "alert('update failed because, order status is lower then current');", 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("/administration/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);
                }
            }
        }