private void ini() { if (UID != null && !UID.Equals(String.Empty)) { string sql = "select * from t_lunpic where id=" + UID; DataTable dt = AccessDb.Execute(sql).Tables[0]; if (dt != null) { this.link1.NavigateUrl = dt.Rows[0]["ppic"].ToString(); this.link1.Target = "_blank"; this.txt_title.Text = dt.Rows[0]["ptitle"].ToString(); this.txt_url.Text = dt.Rows[0]["purl"].ToString(); this.txt_sort.Text = dt.Rows[0]["psort"].ToString(); string isShow = dt.Rows[0]["PIsShow"].ToString(); if (isShow.ToLower() == "false") { this.drp_isUse.SelectedIndex = 1; } else { this.drp_isUse.SelectedIndex = 0; } } } }
protected void DGList_DeleteCommand(object source, DataGridCommandEventArgs e) { int nowRow = int.Parse(e.Item.Cells[0].Text); try { string sql = "delete from t_plat where id=" + nowRow.ToString(); AccessDb.ExecuteNonQuery(sql); if (e.Item.Cells[6] != null && e.Item.Cells[6].Text.Length > 0) { string filePath = Page.Server.MapPath(@"~\" + e.Item.Cells[6].Text); if (File.Exists(filePath)) { File.Delete(filePath); } } JS.Alert("删除成功"); } catch (Exception ex) { JS.Alert("删除失败:" + ex); } showgrid(source, e); }
//Single Store Order History User Interface //Displays userId, total cost, data/time, amount of pizzas, type of pizza, size, and crust for each order public static void singlestoreUI() { Console.WriteLine($"Store ID: {Location.Id}"); Console.WriteLine($"Store Address: {Location.Locat}"); Console.WriteLine(); Console.WriteLine("UserId Total Date/Time Amount of Pizzas Type of Pizza Size Crust"); Console.WriteLine("-----------------------------------------------------------------------------------------"); Entity db = AccessDb.acc(); //Singleton used to access data var records = Repository.GetRecordsReverse(db); decimal monthTotal = 0; foreach (var rec in records) { if (rec.LocatId == Location.Id) // runs through records table and displays only order information from that location { decimal?value = rec.Total; decimal total = value ?? 0; total = Math.Round(total, 2); Console.WriteLine(String.Format("{0,4} {1,9:C} {2,22} {3,7} {4,-12} {5,-7} {6,-10}" , rec.UserId, total, rec.DateT, rec.AmountP, rec.PizzaType, rec.Size, rec.Crust)); monthTotal = total + monthTotal; } } Console.WriteLine(); Console.WriteLine($"Total Month Sales: ${monthTotal}"); Console.WriteLine(); Console.WriteLine("Press any key to return to store locations"); Console.ReadKey(); storelocationUI(); // returns to locations options }
protected void Page_Load(object sender, EventArgs e) { this.Button1.Attributes.Add("onclick", "return conf();"); CheckLogin.checkAll(); if (!IsPostBack) { string sql = "select * from t_3th where id="; string tit = ""; switch (UID) { case "interface": tit = "地图API管理"; sql += "1"; break; case "use": tit = "应用管理"; sql += "2"; break; case "source": tit = "资源管理"; sql += "3"; break; } this.Label1.Text = tit; DataTable dt = AccessDb.Execute(sql).Tables[0]; this.txt_url.Text = dt.Rows[0]["purl"].ToString(); } }
static public bool checkDT() //checks if last order meets time and date conditions for current order { DateTime now = DateTime.Now; Entity db = AccessDb.acc(); var records = Repository.GetRecordsReverse(db); foreach (var rec in records) // { if (rec.UserId == PCustomer.Id && rec.LocatId == Location.Id) { TimeSpan interval = now - rec.DateT; // Timespan struct to calculate the interval between the two dates. if (interval.TotalDays < 1) // If totaldays less than 1, does not allow purchace { Console.WriteLine("Must wait 24 hours before next purchase at this location"); Console.WriteLine($"Last order here on {rec.DateT}"); return(false); } } else if (rec.UserId == PCustomer.Id) { TimeSpan interval = now - rec.DateT; // Timespan struct to calculate the interval between the two dates. if (interval.TotalHours < 2) // If totalhours less than 2, does not allow purchace { Console.WriteLine("Must wait 2 hours before next purchase in general"); Console.WriteLine($"Last order on {rec.DateT}"); return(false); } } } return(true); }
public MainForm() { InitializeComponent(); _taskList = new List <GeneratorTask>(); _dataBase = new AccessDb(); }
//Order History User Interface //Displays total order history of user //total, date/time, amount of pizzas, type of pizza, size, crust, and location for each order public static void historyUI() { while (true) { string address; Console.Clear(); Console.WriteLine("Order History"); Console.WriteLine(); Console.WriteLine(" Total Date/Time Amount of Pizzas Type of Pizza Size Crust Location"); Console.WriteLine("-----------------------------------------------------------------------------------------------------------------"); Entity db = AccessDb.acc(); //Singleton used to access data var records = Repository.GetRecordsReverse(db); foreach (var rec in records) { if (rec.UserId == PCustomer.Id) // runs through record and check if user id matches foreign key in records, then displays history { TypeChange type = new TypeChange(); address = type.returnLocation(rec.LocatId); decimal?value = rec.Total; decimal total = value ?? 0; total = Math.Round(total, 2); Console.WriteLine(String.Format("{0,5:C} {1,22} {2,7} {3,-12} {4,-6} {5,-11} {6,0}" , total, rec.DateT, rec.AmountP, rec.PizzaType, rec.Size, rec.Crust, address)); } } Console.WriteLine(); Console.WriteLine("Press any key to return to other options"); Console.ReadKey(); optionsUI(); break; } }
/// <summary> /// 设置数据库对象,并将该连接内容显示在界面控件上。 /// </summary> /// <param name="db"></param> public void SetDb(IDb db) { this.m_Db = db as AccessDb; this.txtFileName.Text = this.m_Db.FileName; this.txtPassword.Text = this.m_Db.Password; }
private void showgrid(object sender, System.EventArgs e) { DataTable mydt = null; mydt = AccessDb.Execute("select * from t_news where ptype='" + typ + "' order by id desc").Tables[0]; DGList.DataSource = mydt; DataTable dt = new DataTable(); try { DGList.DataBind(); MyPage1.init(mydt.Rows.Count); } catch { if ((DGList.CurrentPageIndex - 1) >= 0) { DGList.CurrentPageIndex = DGList.CurrentPageIndex - 1; } DGList.DataBind(); MyPage1.init(mydt.Rows.Count); } }
private void editIni() { string sql = "select * from t_sample where id=" + UID; DataTable dt = AccessDb.Execute(sql).Tables[0]; if (dt.Rows.Count == 0) { JS.Alert("读数据失败"); Response.End(); } else { _dr = dt.Rows[0]; } this.txt_title.Text = DR["ptitle"].ToString(); this.txt_Url.Text = DR["purl"].ToString(); this.content2.Value = DR["pcontent"].ToString(); this.HyperLink1.NavigateUrl = DR["ppic"].ToString(); this.HyperLink1.Target = "_blank"; this.txt_DateTime.Value = DR["pdate"].ToString(); if (DR["ppic"].ToString().Trim() != "") { this.HyperLink1.Text = "点击查看"; } else { this.HyperLink1.Text = "---"; } }
public double calculateCostCustom(int amount, string pizzaSize, string toppings, int pizzaId) // amount of pizzas, size of crust, and size of pizza(s) { int toppn = 0; // check how many toppings are in the string foreach (char c in toppings) { if (c == ',') { toppn++; } } int totalToppings = toppn * 1; Entity db = AccessDb.acc(); var pizzas = Repository.GetPizza(db); foreach (var pie in pizzas) // finds the pizza of choice and checks the menu in the database for standard price { if (pie.Id == pizzaId) { switch (pizzaSize) { case "small": decimal?value = pie.Small; decimal value2 = value ?? 0; pizzaPrice = Convert.ToDouble(value2); break; case "medium": decimal?value3 = pie.Med; decimal value4 = value3 ?? 0; pizzaPrice = Convert.ToDouble(value4); break; case "large": decimal?value5 = pie.Large; decimal value6 = value5 ?? 0; pizzaPrice = Convert.ToDouble(value6); break; default: Console.WriteLine("Shouldn't Happen"); break; } } } // Calculating total with tax total = (total + (pizzaPrice * amount)) + totalToppings; taxTotal = (total * tax); total = taxTotal + total; total = Math.Round((Double)total, 2); return(total); }
public static AccessDb getAccDb() { if (s_obj == null) { s_obj = new AccessDb(); } return(s_obj); }
private void editNoPic() { string title = this.txt_title.Text; if (title == null | title.Length <= 0) { JS.Alert("题目不能为空!"); return; } if (title.Length >= 255) { JS.Alert("题目过长!"); return; } string url = this.txt_Url.Text; if (url == null | url.Length <= 0) { JS.Alert("地址不能为空!"); return; } if (url.Length >= 255) { JS.Alert("地址过长!"); return; } string content = content2.Value; string strDateTime = this.txt_DateTime.Value; string sqlEdit = "update t_sample set ptitle=@ptitle,pcontent=@pcontent , purl=@url, pdate=@pdate where id=" + UID; ArrayList insertValue = new ArrayList(); OleDbParameter ptitle = new OleDbParameter("@ptitle", OleDbType.VarChar); ptitle.Value = title; insertValue.Add(ptitle); OleDbParameter pcontent = new OleDbParameter("@pcontent", OleDbType.LongVarWChar); pcontent.Value = content; insertValue.Add(pcontent); OleDbParameter purl = new OleDbParameter("@purl", OleDbType.VarChar); purl.Value = url; insertValue.Add(purl); OleDbParameter pdate = new OleDbParameter("@pdate", OleDbType.Date); pdate.Value = strDateTime; insertValue.Add(pdate); int p = AccessDb.ExecuteNon(sqlEdit, ref insertValue); JS.Alert("修改成功!"); }
public void count_dmt_stud() { AccessDb dbcon = new AccessDb(); DataSet ds = dbcon.execDataTable("SELECT count(*) as `total` from personal where `course`='DMTE'"); if (dbcon.ds.Tables[0].Rows.Count > 0) { lbl_dmt_count.Text = dbcon.ds.Tables[0].Rows[0]["total"].ToString(); } }
protected void Create_Click(object sender, EventArgs e) { try { var userId = 0; var user = new User { FirstName = txtFirstName.Text.Trim(), LastName = txtLastName.Text.Trim(), LastName2 = txtLastName2.Text.Trim(), Email = txtEmail.Text.Trim(), Country = ddlCountry.SelectedValue, Username = txtUsername.Text.Trim(), Password = txtPassword.Text.Trim(), PasswordAge = Convert.ToInt32(txtAge.Text.Trim()), Age = Convert.ToInt32(ddlExpiration.SelectedValue), UserId = 0, PasswordLastSet = DateTime.Today, Active = false }; user.GenerateCode(user); userId = AccessDb.AddUser(user); switch (userId) { case -1: errorMessage.Text = "User Could not be created, Username is already in use"; break; case -2: errorMessage.Text = "User Could not be created, Email Address is already in use"; break; default: errorMessage.Text = "User registered, Confirm email to activate account"; StringWriter writer = new StringWriter(); Server.Execute("Email.aspx", writer); string html = writer.ToString(); var ae = new ActivationEmail(); ae.SendActivationEmail(user, html); AccessDb.AddActivation(user); break; } ClientScript.RegisterStartupScript(GetType(), "alert", "alert('" + errorMessage.Text + "');", true); CleanFields(); } catch (Exception) { throw; } }
private void edit() { string title = this.txt_title.Text; if (title == null || title.Length <= 0) { JS.Alert("题目不能为空!"); return; } if (title.Length >= 255) { JS.Alert("题目过长!"); return; } string content = content2.Value; if (content == null || content.Length <= 0) { JS.Alert("内容不能为空!"); return; } string FilePath = ""; FilePath = File1.Value; if (FilePath.Length > 0) { FilePath = FileUp.meUpfile(this.File1, @"~\file\", true); FilePath = FilePath.Substring(FilePath.IndexOf('\\') + 1); } string sqlEdit = "update t_plat set ptitle=@ptitle,pcontent=@pcontent ,purl=@purl where id=" + UID; ArrayList insertValue = new ArrayList(); OleDbParameter ptitle = new OleDbParameter("@ptitle", OleDbType.VarChar); ptitle.Value = title; insertValue.Add(ptitle); OleDbParameter pcontent = new OleDbParameter("@pcontent", OleDbType.LongVarWChar); pcontent.Value = content; insertValue.Add(pcontent); OleDbParameter purl = new OleDbParameter("@purl", OleDbType.LongVarWChar); purl.Value = FilePath; insertValue.Add(purl); int p = AccessDb.ExecuteNon(sqlEdit, ref insertValue); JS.Alert("修改成功!"); }
private void ini() { string sql = "select * from t_about where pname='padv'"; DataTable dt = AccessDb.Execute(sql).Tables[0]; if (dt.Rows.Count == 0) { JS.Alert("发生错误"); Response.End(); } this.content2.Value = dt.Rows[0]["pcontent"].ToString(); }
protected void DGList_DeleteCommand(object source, DataGridCommandEventArgs e) { int nowRow = int.Parse(e.Item.Cells[0].Text); string sql = "delete from t_programs where id=" + nowRow.ToString(); AccessDb.ExecuteNonQuery(sql); JS.Alert("删除成功"); showgrid(source, e); }
private void DGList_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { try { AccessDb.ExecuteNonQuery("delete from t_user where id=" + int.Parse(e.Item.Cells[0].Text)); JS.Alert("删除成功"); } catch (Exception ex) { JS.Alert("删除失败:" + ex); } showgrid(source, e); }
protected void Button1_Click(object sender, EventArgs e) { string content = content2.Value; string sql = "update t_about_top set pcontent=@pcontent where pname='s2'"; ArrayList insertValue = new ArrayList(); OleDbParameter pcontent = new OleDbParameter("@pcontent", OleDbType.LongVarWChar); pcontent.Value = content; insertValue.Add(pcontent); int p = AccessDb.ExecuteNon(sql, ref insertValue); JS.Alert("修改成功!"); }
private void ini() { string sql = "select * from t_const where pname='zhitong'"; DataTable dt = AccessDb.Execute(sql).Tables[0]; if (dt.Rows.Count == 0) { Response.Write("请先填写"); } else { this.content2.Value = dt.Rows[0]["pcontent"].ToString(); } }
public string returnLocation(int?locationID) // converts location ID to location Address for user history view { string locAddress = "Location Unknown"; Entity db = AccessDb.acc(); var locations = Repository.GetLocations(db); foreach (var loc in locations) { if (loc.Id == locationID) { locAddress = loc.Locat; } } return(locAddress); }
private bool updatSql(string pic, string title, string url, int sort, bool IsShow, string id) { string sql = "update t_lunpic set ppic=@ppic,ptitle=@ptitle , purl=@purl ,psort=@psort,PIsShow=@PIsShow where ID=@pid"; ArrayList insertValue = new ArrayList(); OleDbParameter ppic = new OleDbParameter("@ppic", OleDbType.VarChar); ppic.Value = pic; insertValue.Add(ppic); OleDbParameter ptitle = new OleDbParameter("@ptitle", OleDbType.VarChar); ptitle.Value = title; insertValue.Add(ptitle); OleDbParameter purl = new OleDbParameter("@purl", OleDbType.VarChar); purl.Value = url; insertValue.Add(purl); OleDbParameter psort = new OleDbParameter("@psort", OleDbType.Integer); psort.Value = sort; insertValue.Add(psort); OleDbParameter PIsShow = new OleDbParameter("@PIsShow", OleDbType.Boolean); PIsShow.Value = IsShow; insertValue.Add(PIsShow); OleDbParameter pid = new OleDbParameter("@pid", OleDbType.VarChar); pid.Value = id; insertValue.Add(pid); int p = AccessDb.ExecuteNon(sql, ref insertValue); if (p == 1) { return(true); } else { return(false); } }
//Employee Login User Interface //prompts employee user to login //checks if username and password entered is present in the database public static void empLoginUI() { while (true) { Console.Clear(); string Id; string passWord; Console.WriteLine("Store Login"); Console.Write("Username: "******"Password: "******"Invalid Username or Password"); Console.WriteLine("Press 'b' to return to last page or any other key to try again"); ConsoleKeyInfo key; key = Console.ReadKey(); Console.WriteLine(); switch (key.Key) { case ConsoleKey.B: MainUI.startupUI(); break; default: empLoginUI(); break; } } }
protected void DGList_DeleteCommand(object source, DataGridCommandEventArgs e) { int nowRow = int.Parse(e.Item.Cells[0].Text); string sql = "delete from t_frind where id=" + nowRow.ToString(); AccessDb.ExecuteNonQuery(sql); try { JS.Alert("删除成功"); } catch (Exception ex) { JS.Alert("删除失败:" + ex); } showgrid(source, e); }
protected void but_save_Click(object sender, EventArgs e) { string sql = "insert into t_frind(ptitle,purl,ptype) values('{0}','{1}','{2}')"; string title = this.txt_title.Text; string type = this.DropDownList1.SelectedValue; string url = this.txt_url.Text; sql = string.Format(sql, title, url, type); AccessDb.ExecuteNonQuery(sql); JS.Alert("添加成功"); this.txt_title.Text = ""; this.txt_url.Text = ""; showgrid(null, null); }
private void editIni() { string sql = "select * from t_interface where id=" + UID; DataTable dt = AccessDb.Execute(sql).Tables[0]; if (dt.Rows.Count == 0) { JS.Alert("读数据失败"); Response.End(); } else { _dr = dt.Rows[0]; } this.txt_title.Text = DR["ptitle"].ToString(); this.content2.Value = DR["pcontent"].ToString(); }
//Login User Interface //prompts user to login //checks if username and password entered is present in the database public static void loginUI() { while (true) { Console.Clear(); string userName; string passWord; Console.WriteLine("Welcome to Marquez's Pizzaria"); Console.Write("Username: "******"Password: "******"Invalid Username or Password"); Console.WriteLine("Press 'b' to return to last page or any other key to try again"); ConsoleKeyInfo key; key = Console.ReadKey(); Console.WriteLine(); switch (key.Key) { case ConsoleKey.B: MainUI.startupUI(); break; default: loginUI(); break; } } }
protected void but_save_Click(object sender, EventArgs e) { int sort = 0; try { sort = int.Parse(this.txt_sort.Text); } catch { JS.Alert("请输入整数!"); return; } if (this.txt_title.Text.Length >= 255) { JS.Alert("栏目名称过长,请重新输入!"); return; } if (ViewState["pk"] != null) { //edit string sql = "update t_programs set ptitle='{0}' ,purl='{1}',pstate={2}, picurl='{3}',psort={4} where id=" + ViewState["pk"].ToString(); sql = string.Format(sql, this.txt_title.Text, this.txt_url.Text, this.drp_isUse.SelectedValue == "是" ? "True" : "False", "", sort.ToString()); AccessDb.ExecuteNonQuery(sql); JS.Alert("修改成功"); ViewState["pk"] = null; //this.txt_title.Enabled = true; } else { //tianjia string sql = "insert into t_programs(ptitle,purl,pstate,picurl,psort) values('{0}','{1}',{2},'{3}',{4})"; sql = string.Format(sql, this.txt_title.Text, this.txt_url.Text, this.drp_isUse.SelectedValue == "是" ? "True" : "False", "", sort); AccessDb.ExecuteNonQuery(sql); JS.Alert("添加成功"); } this.txt_title.Text = ""; this.txt_url.Text = ""; txt_sort.Text = ""; this.drp_isUse.SelectedIndex = 0; showgrid(null, null); }
private void show() { string sql = "select * from t_news where id=" + UID; DataTable dt = AccessDb.Execute(sql).Tables[0]; dr = dt.Rows[0]; if (dr["purl"] != null && dr["purl"].ToString().Length > 0) { string FilePath = dr["purl"].ToString(); FilePath = FilePath.Substring(FilePath.LastIndexOf('\\') + 1); this.SpFile.InnerHtml = "附件: <a href=\"" + dr["purl"].ToString() + "\" title=\"" + FilePath + "\">" + FilePath + " </a>"; } else { this.SpFile.InnerHtml = ""; } }