public ActionResult AddProduct(Models.ProductInfo product) { DB.DB mydb = new DB.DB("SQLAdmin", "admin1234"); DB.IProduct ip = new DB.Impl_Product(mydb.Connection); ip.AddNewProduct(product.Name, product.PTID, product.Price, product.Note, product.Stock, product.State, product.Pic); return(RedirectToAction("ManageProduct")); }
public ActionResult ManageProduct() { #region 列出商品 System.Text.StringBuilder sb = new System.Text.StringBuilder(); DB.DB mydb = new DB.DB(); DB.IProduct ip = new DB.Impl_Product(mydb.Connection); DataTable tt = ip.GetProducts(); if (tt != null) { foreach (DataRow r in tt.Rows) { sb.Append("<tr>"); sb.Append(string.Format("<td align=\"center\"><a style=\"text-decoration:underline\" href=\"/Admin/Product?pid={0}\">{1}</a></td>", r["proID"].ToString(), r["proID"].ToString())); sb.Append(string.Format("<td align=\"center\">{0}</td>", r["proName"].ToString())); sb.Append(string.Format("<td align=\"center\">{0}</td>", r["PTID"].ToString())); sb.Append(string.Format("<td align=\"center\">{0}</td>", r["proPrice"].ToString())); sb.Append(string.Format("<td align=\"center\">{0}</td>", r["proStock"].ToString())); sb.Append(string.Format("<td align=\"center\">{0}</td>", r["proState"].ToString())); sb.Append(string.Format("<td align=\"center\">{0}</td>", r["proPic"].ToString())); sb.Append(string.Format("<td>{0}</td>", r["proNote"].ToString())); sb.Append("</tr>"); } } ViewData["products"] = sb.ToString(); #endregion return(View()); }
public ActionResult AdminValidLoginProcess(Models.LoginInfo li) { if (li.Phone == null) { return(RedirectToAction("AdminIndex", new { msg = "請輸入帳號" })); } if (li.PW == null) { return(RedirectToAction("AdminIndex", new { msg = "請輸入密碼" })); } DB.DB mydb = new DB.DB(); DB.IAdmin ia = new DB.Impl_Admin(mydb.Connection); if (ia.CheckLogin(li.Phone, li.PW)) { Session.Add("Login", li.Phone); Session.Add("LoginType", "a"); HttpCookie hc = Request.Cookies["ReUrl"]; if (hc == null) { return(RedirectToAction("Index", "Home")); } else { return(Redirect(hc.Value)); } } else { return(RedirectToAction("AdminIndex", new { msg = "登入失敗!帳號或密碼有誤!" })); } }
public ActionResult ManageOrder() { #region 列出訂單 System.Text.StringBuilder sb = new System.Text.StringBuilder(); DB.DB mydb = new DB.DB(); DB.IOrder io = new DB.Impl_Order(mydb.Connection); DataTable tt = io.GetOrderInfo(); if (tt != null) { foreach (DataRow r in tt.Rows) { sb.Append("<tr>"); sb.Append(string.Format("<td align=\"center\">{0}</td>", r["orderID"].ToString())); sb.Append(string.Format("<td align=\"center\">{0}</td>", r["custID"].ToString())); sb.Append(string.Format("<td align=\"center\">{0}</td>", r["rcptName"].ToString())); sb.Append(string.Format("<td align=\"center\">{0}</td>", r["rcptPhone"].ToString())); sb.Append(string.Format("<td>{0}</td>", r["rcptAddr"].ToString())); sb.Append(string.Format("<td>{0}</td>", r["DTName"].ToString())); sb.Append(string.Format("<td>{0}</td>", r["Shipping"].ToString())); sb.Append(string.Format("<td>{0}</td>", r["orderState"].ToString())); sb.Append(string.Format("<td>{0}</td>", r["orderNote"].ToString())); sb.Append(string.Format("<td>{0}</td>", r["orderTime"].ToString())); sb.Append("</tr>"); } } ViewData["orderList"] = sb.ToString(); #endregion return(View()); }
public ActionResult ValidLoginProcess(Models.LoginInfo li) { if (li.Phone == null) { return(RedirectToAction("Index", new { msg = "請輸入手機號碼" })); } if (li.PW == null) { return(RedirectToAction("Index", new { msg = "請輸入密碼" })); } DB.DB mydb = new DB.DB(); DB.ICustomer ic = new DB.Impl_Customer(mydb.Connection); if (ic.CheckLogin(li.Phone, li.PW)) { Session.Add("Login", li.Phone); Session.Add("LoginType", "c"); // 取出User原先瀏覽的網頁 HttpCookie hc = Request.Cookies["ReUrl"]; if (hc == null) { return(RedirectToAction("Index", "Home")); } else { return(Redirect(hc.Value)); } } else { return(RedirectToAction("Index", new { msg = "登入失敗!手機號碼或密碼有誤!" })); } }
public ActionResult OrderDetail(int?oid) { if (oid == null) { RedirectToAction("Index"); } #region 列出訂單明細 System.Text.StringBuilder sb = new System.Text.StringBuilder(); DB.DB mydb = new DB.DB(); DB.IOrder io = new DB.Impl_Order(mydb.Connection); DataTable tt = io.GetOrderDetail(oid.Value); int totalPrice = 0; if (tt != null) { foreach (DataRow r in tt.Rows) { totalPrice += (int)r["proPrice"] * (int)r["quantity"]; sb.Append("<tr>"); sb.Append(string.Format("<td>{0}</td>", r["proName"].ToString())); sb.Append(string.Format("<td>{0}</td>", r["proPrice"].ToString())); sb.Append(string.Format("<td>{0}</td>", r["quantity"].ToString())); sb.Append("</tr>"); } } ViewData["orderID"] = oid.ToString(); ViewData["totalPrice"] = totalPrice.ToString(); ViewData["orderDetailList"] = sb.ToString(); #endregion return(View()); }
public string CheckPhone(string phone) { if (phone.Length != 10 || phone.Substring(0, 2) != "09") { return("l"); } for (int i = 2; i < 10; i++) { if (phone[i] > '9' || phone[i] < '0') { return("l"); } } DB.DB mydb = new DB.DB(); DB.ICustomer ic = new DB.Impl_Customer(mydb.Connection); bool ans = ic.CheckPhoneDuplicate(phone); if (ans) { return("t"); } else { return("f"); } }
public ActionResult ChageOrderState(Models.Order order) { DB.DB mydb = new DB.DB("SQLAdmin", "admin1234"); DB.IOrder io = new DB.Impl_Order(mydb.Connection); io.UpdateOrder(order.orderID, order.orderState); return(RedirectToAction("ManageOrder")); }
// GET: Customer public ActionResult Index() { #region 列出訂單 System.Text.StringBuilder sb = new System.Text.StringBuilder(); DB.DB mydb = new DB.DB(); DB.IOrder io = new DB.Impl_Order(mydb.Connection); DataTable tt = io.GetOrderInfoByCustPhone(Session["Login"].ToString()); if (tt != null) { foreach (DataRow r in tt.Rows) { sb.Append("<tr>"); sb.Append(string.Format("<td align=\"center\"><a style=\"text-decoration:underline\" href=\"/Customer/OrderDetail?oid={0}\">{1}</a></td>", r["orderID"].ToString(), r["orderID"].ToString())); sb.Append(string.Format("<td align=\"center\">{0}</td>", r["rcptName"].ToString())); sb.Append(string.Format("<td align=\"center\">{0}</td>", r["rcptPhone"].ToString())); sb.Append(string.Format("<td>{0}</td>", r["rcptAddr"].ToString())); sb.Append(string.Format("<td>{0}</td>", r["DTName"].ToString())); sb.Append(string.Format("<td>{0}</td>", r["Shipping"].ToString())); sb.Append(string.Format("<td>{0}</td>", r["orderState"].ToString())); sb.Append(string.Format("<td>{0}</td>", r["orderNote"].ToString())); sb.Append(string.Format("<td>{0}</td>", r["orderTime"].ToString())); sb.Append("</tr>"); } } ViewData["orderList"] = sb.ToString(); #endregion return(View()); }
public ActionResult Product(int?pid) { if (pid == null) { pid = 1; } DB.DB mydb = new DB.DB(); DB.IProduct ip = new DB.Impl_Product(mydb.Connection); Dictionary <string, object> dp = ip.GetSingleProduct(pid.Value); if (dp == null || (int)dp["proState"] == 0) { RedirectToAction("Product"); } Models.ProductInfo pi = new Models.ProductInfo(); pi.ID = (int)dp["proID"]; pi.Name = dp["proName"].ToString(); pi.PTName = dp["PTName"].ToString(); pi.Note = dp["proNote"].ToString(); pi.Price = Convert.ToInt32(dp["proPrice"]); pi.Stock = Convert.ToInt32(dp["proStock"]); pi.Pic = dp["proPic"].ToString(); ViewData["proTypes"] = Session["proTypes"]; return(View(pi)); }
public ActionResult AddNewMember(Models.MemberInfo mi) { DB.DB mydb = new DB.DB("SQLAdmin", "admin1234"); DB.ICustomer ic = new DB.Impl_Customer(mydb.Connection); ic.AddNewMember(mi.Phone, mi.PW, mi.Name, mi.Email); return(RedirectToAction("Index", "Login", new { msg = "成功加入會員,請登入!" })); }
/// <summary> /// Create parameter list for the results on a cycle /// </summary> /// <param name="mkey">The multiplicity parameters used to select the specific results. There can be more than one such results set per cycle.</param> public void GenParamList(Multiplicity mkey) { GenParamList(); // ^ does the basic INCC5 and new LM cycle stuff // now add the mkey stuff Table = "cycles"; MultiplicityCountingRes pmcr = null; QCTestStatus status = QCTestStatus.None; if (CountingAnalysisResults.HasMultiplicity) { try { pmcr = (MultiplicityCountingRes)CountingAnalysisResults[mkey]; status = qcstatus[mkey].status; } catch (Exception) // mkey not found happens when a param is changed on a VSR that is not reflected back to the default [0] SR { logger?.TraceEvent(LogLevels.Warning, 7832, "Cycle status not set in DB, mkey mismatch: " + mkey.ToString()); } } if (pmcr == null) { pmcr = new MultiplicityCountingRes(); // null results } ps.Add(new DBParamEntry("scaler1", pmcr.Scaler1.v)); ps.Add(new DBParamEntry("scaler2", pmcr.Scaler2.v)); ps.Add(new DBParamEntry("reals_plus_acc", pmcr.RASum)); ps.Add(new DBParamEntry("acc", pmcr.ASum)); ps.Add(new DBParamEntry("mult_reals_plus_acc", pmcr.RAMult)); ps.Add(new DBParamEntry("mult_acc", pmcr.NormedAMult)); ps.Add(new DBParamEntry("scaler1_rate", pmcr.Scaler1Rate.v)); ps.Add(new DBParamEntry("scaler2_rate", pmcr.Scaler2Rate.v)); ps.Add(new DBParamEntry("doubles_rate", pmcr.RawDoublesRate.v)); ps.Add(new DBParamEntry("triples_rate", pmcr.RawTriplesRate.v)); ps.Add(new DBParamEntry("multiplicity_mult", pmcr.multiplication)); ps.Add(new DBParamEntry("multiplicity_alpha", pmcr.multiAlpha)); ps.Add(new DBParamEntry("multiplicity_efficiency", pmcr.efficiency)); ps.Add(new DBParamEntry("mass", pmcr.mass)); ps.Add(new DBParamEntry("status", (int)status)); { // la super hack-a-whack DB.DB db = new DB.DB(true); if (db.TableHasColumn(Table, "mult_acc_un")) { ps.Add(new DBParamEntry("mult_acc_un", pmcr.UnAMult)); } } }
public ActionResult UpdatePW(Models.MemberInfo Mi) { if (!CheckLI(Session["Login"].ToString(), Mi.oldPW)) { return(RedirectToAction("ChangePW", new { msg = "無效的舊密碼!" })); } else if (Mi.oldPW == Mi.PW) { return(RedirectToAction("ChangePW", new { msg = "新舊密碼不能相同!" })); } DB.DB mydb = new DB.DB("SQLAdmin", "admin1234"); DB.ICustomer ic = new DB.Impl_Customer(mydb.Connection); ic.ChangePassword(Session["Login"].ToString(), Mi.PW); return(RedirectToAction("ChangePW", new { msg = "密碼變更成功!" })); }
public ActionResult AddToCart(int?pid) { if (pid == null) { return(RedirectToAction("Index", "Home")); } HashSet <Models.CartItem> myCart = null; if (Session["Cart"] == null) { myCart = new HashSet <Models.CartItem>(); } else { myCart = Session["Cart"] as HashSet <Models.CartItem>; } Models.CartItem ci = new Models.CartItem(); ci.ID = pid.Value; if (myCart.Contains(ci)) { return(RedirectToAction("Index")); } DB.DB mydb = new DB.DB(); DB.IProduct ip = new DB.Impl_Product(mydb.Connection); Dictionary <string, object> pp = ip.GetSingleProduct(pid.Value); if (pp == null) { return(RedirectToAction("Index", "Home")); } ci.ID = Convert.ToInt32(pp["proID"]); ci.Name = pp["proName"].ToString(); ci.Stock = Convert.ToInt32(pp["proStock"]); ci.Quantity = 1; ci.Price = Convert.ToInt32(pp["proPrice"]); myCart.Add(ci); Session["Cart"] = myCart; return(RedirectToAction("Index")); }
public ActionResult PlaceOrder(Models.Order order) { if (Session["Cart"] == null) { return(RedirectToAction("Index", "Home")); } DB.DB mydb = new DB.DB(); DB.ICustomer ic = new DB.Impl_Customer(mydb.Connection); order.custID = ic.GetCustIDByPhone(Session["Login"].ToString()); DB.DB mydb2 = new DB.DB("SQLAdmin", "admin1234"); DB.IOrder io = new DB.Impl_Order(mydb2.Connection); order.orderID = io.AddNewOrder(order.custID, order.rcptName, order.rcptPhone, order.rcptAddr, order.DTID, order.Shipping, order.orderNote); HashSet <Models.CartItem> myCart = Session["Cart"] as HashSet <Models.CartItem>; List <Dictionary <string, object> > items = new List <Dictionary <string, object> >(); foreach (Models.CartItem ii in myCart) { Dictionary <string, object> temp = new Dictionary <string, object>(); temp["proID"] = ii.ID; temp["Quantity"] = ii.Quantity; items.Add(temp); } DB.DB mydb3 = new DB.DB("SQLAdmin", "admin1234"); DB.IOrder io2 = new DB.Impl_Order(mydb3.Connection); bool finish = io2.AddCartItems(order.orderID, items); if (finish) { return(RedirectToAction("FinishOrder", new { msg = "已完成訂單!請至個人中心查看!" })); } else { return(RedirectToAction("FinishOrder", new { msg = "訂單失敗!請重新下訂貨聯絡客服!" })); } }
public ActionResult ProductType(int?type, int?page) { if (page == null) { page = 1; } if (type == null) { type = 0; } DB.DB mydb = new DB.DB("SQLAdmin", "admin1234"); DB.IProduct ip = new DB.Impl_Product(mydb.Connection); DataTable tt = ip.GetProductListByType(type.Value); if (tt == null) { tt = new DataTable(); } int count = tt.Rows.Count; int totalPage = 1; if (count > 5) { totalPage = (int)Math.Ceiling(count / 5.0); } if (page > totalPage) { return(RedirectToAction("ProductType", new { type })); } List <Models.ProductInfo> ps = new List <Models.ProductInfo>(); foreach (DataRow r in tt.Rows) { int countID = Convert.ToInt32(r["countID"]); if (countID <= 5 * (page.Value - 1) || countID > 5 * page.Value) { continue; } Models.ProductInfo pi = new Models.ProductInfo(); pi.ID = (int)r["proID"]; pi.Name = r["proName"].ToString(); pi.Note = r["proNote"].ToString(); pi.PTName = r["PTName"].ToString(); pi.Price = Convert.ToInt32(r["proPrice"]); pi.Stock = Convert.ToInt32(r["proStock"]); pi.Pic = r["proPic"].ToString(); ps.Add(pi); } //頁碼 System.Text.StringBuilder sb2 = new System.Text.StringBuilder(); for (int i = 1; i <= totalPage; i++) { if (i == page.Value) { sb2.Append(i).Append(" "); } else { sb2.Append(string.Format("<a style=\"text-decoration:underline\" href='{0}'>{1}</a> ", Url.Action("ProductType", new { type, page = i }), i)); } } ViewData["PageLink"] = sb2.ToString(); ViewData["proTypes"] = Session["proTypes"]; return(View(ps)); }
// GET: Home public ActionResult Index() { #region 光顧數量 //記錄光顧數量 string path = Server.MapPath("~/App_Data/VisitCount.txt"); string text = System.IO.File.ReadAllText(path); int nn = int.Parse(text) + 1; System.IO.File.WriteAllText(path, nn.ToString()); //印出光顧數量 System.Text.StringBuilder sb1 = new System.Text.StringBuilder(); for (int i = 1; i <= 5 - nn.ToString().Length; i++) { sb1.Append("<img src='/images/number/0.gif' />"); } for (int i = 0; i < nn.ToString().Length; i++) { sb1.Append(string.Format("<img src='/images/number/{0}.gif' />", nn.ToString().Substring(i, 1))); } ViewData["VisitNum"] = sb1.ToString(); #endregion #region 列出商品 DB.DB mydb = new DB.DB(); DB.IProduct ip = new DB.Impl_Product(mydb.Connection); DataTable tt = ip.GetProductList(); List <Models.ProductInfo> ps = new List <Models.ProductInfo>(); if (tt != null) { foreach (DataRow r in tt.Rows) { Models.ProductInfo pi = new Models.ProductInfo(); pi.ID = (int)r["proID"]; pi.Name = r["proName"].ToString(); pi.PTName = r["PTName"].ToString(); pi.Pic = r["proPic"].ToString(); ps.Add(pi); } } #endregion #region 列出分類 if (Session["proTypes"] == null) { System.Text.StringBuilder sb2 = new System.Text.StringBuilder(); sb2.Append("<table>"); DB.DB mydb2 = new DB.DB(); DB.IProduct ip2 = new DB.Impl_Product(mydb2.Connection); DataTable tt2 = ip2.GetProductType(); if (tt2 != null) { foreach (DataRow r in tt2.Rows) { sb2.Append(string.Format("<tr><td><a style=\"text-align:center\" href=\"/Home/ProductType?type={0}\">", r["PTID"].ToString())); sb2.Append(string.Format("<img src='/images/shop/{0}' />", r["PTPic"].ToString())); sb2.Append("</a></td></tr>"); } } sb2.Append("</table>"); Session["proTypes"] = sb2.ToString(); } ViewData["proTypes"] = Session["proTypes"]; #endregion return(View(ps)); }
/// <summary> /// Create parameter list for the results on a cycle /// </summary> /// <param name="mkey">The multiplicity parameters used to select the specific results. There can be more than one such results set per cycle.</param> public void GenParamList(Multiplicity mkey) { GenParamList(); // ^ does the basic INCC5 and new LM cycle stuff // now add the mkey stuff Table = "cycles"; MultiplicityCountingRes pmcr = null; QCTestStatus status = QCTestStatus.None; if (CountingAnalysisResults.HasMultiplicity) try { pmcr = (MultiplicityCountingRes)CountingAnalysisResults[mkey]; status = qcstatus[mkey].status; } catch (Exception) // mkey not found happens when a param is changed on a VSR that is not reflected back to the default [0] SR { logger.TraceEvent(LogLevels.Warning, 7832, "Cycle status not set in DB, mkey mismatch: " + mkey.ToString()); } if (pmcr == null) pmcr = new MultiplicityCountingRes(); // null results ps.Add(new DBParamEntry("scaler1", pmcr.Scaler1.v)); ps.Add(new DBParamEntry("scaler2", pmcr.Scaler2.v)); ps.Add(new DBParamEntry("reals_plus_acc", pmcr.RASum)); ps.Add(new DBParamEntry("acc", pmcr.ASum)); ps.Add(new DBParamEntry("mult_reals_plus_acc", pmcr.RAMult)); ps.Add(new DBParamEntry("mult_acc", pmcr.NormedAMult)); ps.Add(new DBParamEntry("scaler1_rate", pmcr.Scaler1Rate.v)); ps.Add(new DBParamEntry("scaler2_rate", pmcr.Scaler2Rate.v)); ps.Add(new DBParamEntry("doubles_rate", pmcr.RawDoublesRate.v)); ps.Add(new DBParamEntry("triples_rate", pmcr.RawTriplesRate.v)); ps.Add(new DBParamEntry("multiplicity_mult", pmcr.multiplication)); ps.Add(new DBParamEntry("multiplicity_alpha", pmcr.multiAlpha)); ps.Add(new DBParamEntry("multiplicity_efficiency", pmcr.efficiency)); ps.Add(new DBParamEntry("mass", pmcr.mass)); ps.Add(new DBParamEntry("status", (int)status)); { // la super hack-a-whack DB.DB db = new DB.DB(true); if (db.TableHasColumn(Table,"mult_acc_un")) ps.Add(new DBParamEntry("mult_acc_un", pmcr.UnAMult)); } }
public bool CheckLI(string phone, string pw) { DB.DB mydb = new DB.DB(); DB.ICustomer ic = new DB.Impl_Customer(mydb.Connection); return(ic.CheckLogin(phone, pw)); }