public RequestedQuote GetData(string id) { RequestedQuote Data = new RequestedQuote(); string cs = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString; using (MySqlConnection con = new MySqlConnection(cs)) { con.Open(); MySqlCommand cmd = new MySqlCommand("Sp_GetUserDetails", con); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@_id", id); MySqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { Data.PhoneNumber = rdr["PhoneNumber"].ToString(); Data.Email = rdr["Email"].ToString(); } return Data; } }
public void insert(RequestedQuote quote) { string cs = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString; using (MySqlConnection con = new MySqlConnection(cs)) { con.Open(); MySqlCommand cmd = new MySqlCommand("Sp_AddRequestedQuote", con); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("_UserId", quote.User_Id); cmd.Parameters.AddWithValue("_Email", quote.Email); cmd.Parameters.AddWithValue("_PhoneNumber", quote.PhoneNumber); cmd.Parameters.AddWithValue("_Location", quote.product.Loc); cmd.Parameters.AddWithValue("_type", quote.product.Type); cmd.Parameters.AddWithValue("_finish", quote.product.Finish); cmd.Parameters.AddWithValue("_Gauge", quote.product.Gauge); cmd.Parameters.AddWithValue("_width", quote.product.Width); cmd.Parameters.AddWithValue("_wtnet", quote.product.WTNET); cmd.Parameters.AddWithValue("_NOOFPCS", quote.product.NOOFPCS); cmd.ExecuteNonQuery(); } }
public ActionResult Index(int? page, int? Id, string sortOrder, string Pages, Inventory pro) { string submit = Request["submit"]; ViewBag.Pages = Pages; ViewBag.LocSortParm = String.IsNullOrEmpty(sortOrder) ? "Loc_desc" : ""; ViewBag.TypeSortParm = sortOrder == "Type" ? "Type_desc" : "Type"; ViewBag.FinishSortParm = sortOrder == "Finish" ? "Finish_desc" : "Finish"; ViewBag.GaugeSortParm = sortOrder == "Gauge" ? "Gauge_desc" : "Gauge"; ViewBag.WidthSortParm = sortOrder == "Width" ? "Width_desc" : "Width"; ViewBag.WTNETSortParm = sortOrder == "WTNET" ? "WTNET_desc" : "WTNET"; ViewBag.NOOFPCSSortParm = sortOrder == "NOOFPCS" ? "NOOFPCS_desc" : "NOOFPCS"; pro.ProductList = pro.ProductsList().ToList(); pro.ProductList = pro.ProductList.Where(a => a.Loc.ToUpper().Contains(string.IsNullOrEmpty(pro.Loc) ? a.Loc : pro.Loc.ToUpper())). Where(a => a.Type.ToUpper().Contains(string.IsNullOrEmpty(pro.Type) ? a.Type : pro.Type.ToUpper())). Where(a => a.Finish.ToUpper().Contains(string.IsNullOrEmpty(pro.Finish) ? a.Finish : pro.Finish.ToUpper())). Where(a => a.Gauge.ToUpper().Contains(string.IsNullOrEmpty(pro.Gauge) ? a.Gauge : pro.Gauge.ToUpper())). Where(a => a.Width.ToUpper().Contains(string.IsNullOrEmpty(pro.Width) ? a.Width : (pro.Width.ToUpper()))). Where(a => a.WTNET.ToUpper().Contains(string.IsNullOrEmpty(pro.WTNET) ? a.WTNET : (pro.WTNET.ToUpper()))).ToList(); if (Id.HasValue) { RequestedQuote quote = new RequestedQuote(); quote = quote.GetData(User.Identity.GetUserId()); quote.User_Id = User.Identity.GetUserId(); quote.product = new Inventory(); quote.product = quote.product.productDetails(Id.Value); quote.insert(quote); var smtpClient = new SmtpClient(); var message = new MailMessage("*****@*****.**", "*****@*****.**") { Subject = "Requested Quote" + quote.product.Loc, Body = "User Name " + User.Identity.GetUserName() + Environment.NewLine + "Phone Nubmer :" + quote.PhoneNumber + Environment.NewLine + "Ip Adderss:" + Request.ServerVariables["REMOTE_ADDR"] }; smtpClient.Send(message); } switch (sortOrder) { case "Loc_desc": pro.ProductList = pro.ProductList.OrderByDescending(s => s.Loc).ToList(); break; case "Finish": pro.ProductList = pro.ProductList.OrderBy(s => s.Finish).ToList(); break; case "Finish_desc": pro.ProductList = pro.ProductList.OrderByDescending(s => s.Finish).ToList(); break; case "Gauge": pro.ProductList = pro.ProductList.OrderBy(s => s.Gauge).ToList(); break; case "Gauge_desc": pro.ProductList = pro.ProductList.OrderByDescending(s => s.Gauge).ToList(); break; case "Type": pro.ProductList = pro.ProductList.OrderBy(s => s.Type).ToList(); break; case "Type_desc": pro.ProductList = pro.ProductList.OrderByDescending(s => s.Type).ToList(); break; case "Width": pro.ProductList = pro.ProductList.OrderBy(s => s.Width).ToList(); break; case "Width_desc": pro.ProductList = pro.ProductList.OrderByDescending(s => s.Width).ToList(); break; case "WTNET": pro.ProductList = pro.ProductList.OrderBy(s => s.WTNET).ToList(); break; case "WTNET_desc": pro.ProductList = pro.ProductList.OrderByDescending(s => s.WTNET).ToList(); break; case "NOOFPCS": pro.ProductList = pro.ProductList.OrderBy(s => s.NOOFPCS).ToList(); break; case "NOOFPCS_desc": pro.ProductList = pro.ProductList.OrderByDescending(s => s.NOOFPCS).ToList(); break; default: pro.ProductList = pro.ProductList.OrderBy(s => s.Loc).ToList(); break; } List<SelectListItem> listitems = new List<SelectListItem>(); listitems.Add(new SelectListItem { Text = "10 items ", Value = "10" }); listitems.Add(new SelectListItem { Text = "20 items ", Value = "20" }); listitems.Add(new SelectListItem { Text = "30 items ", Value = "30" }); listitems.Add(new SelectListItem { Text = "40 items ", Value = "40" }); ViewBag.ListItems = listitems; if (string.IsNullOrEmpty(Pages)) { pro.IPagedProductsList = pro.ProductList.ToPagedList(page ?? 1, 10); return View(pro); } else { pro.IPagedProductsList = pro.ProductList.ToPagedList(page ?? 1, Convert.ToInt32(Pages)); return View(pro); } }