protected void Check_Login(object sender, EventArgs e) { string user = account.Text; string hash = password.Text; if (!string.IsNullOrEmpty(user) && !string.IsNullOrEmpty(hash)) { string sqlstr = "select id from sys_user where account = " + myDatabase.qo(user) + " and hash =" + myDatabase.qo(hash); String user_name = myDatabase.getSingleData(0, sqlstr).Trim(); if (user_name == "") { DialogClass.MessageSimple("帳號不存在或密碼錯誤"); } else { Session["user_id"] = account.Text.Trim(); Session["user_name"] = user_name; Session["password"] = password.Text.Trim(); Response.Redirect("~/HandServer"); } } else { DialogClass.MessageSimple("請輸入帳號或密碼"); } }
protected void Delete_User(object sender, EventArgs e) { Button delButton = (Button)sender; String user_id = (string)delButton.CommandArgument; string sqlStr = "delete sys_user where id = " + myDatabase.qo(user_id); myDatabase.execSQL(sqlStr); DialogClass.MessageSimple("刪除成功"); User_View(sender, e); }
protected void Submit_Order(object sender, EventArgs e) { if (addItems.Rows.Count > 0) { if (DialogClass.MessageChickSimple("確定完成結帳?", MessageBoxButton.OKCancel)) { string user_id = Session["user_name"].ToString(); string sqlstr = " Declare @Form_No int;"; //sqlstr += " Begin Tran"; sqlstr += " select @Form_No = isnull(max(order_id), 0) + 1 "; sqlstr += " from order_form;"; sqlstr += " insert into order_form (order_id, created_id,status,create_time,cust_sex, cust_age) values("; sqlstr += " @Form_No," + myDatabase.qo(user_id) + ",17,getDate(),"; sqlstr += myDatabase.qo(cust_Sex.SelectedValue.ToString()) + ","; sqlstr += myDatabase.qo(cust_Age.SelectedValue.ToString()) + ");"; sqlstr += " insert into order_detail (order_id, prod_id,qty,sugur_type,ice_type) values"; for (int i = 0; i < addItems.Rows.Count; i++) { DataRow row = addItems.Rows[i]; string prod_id = row["prod_id"].ToString(); string qty = row["qty"].ToString(); string suger_id = row["suger_id"].ToString(); string ice_id = row["ice_id"].ToString(); sqlstr += "( @Form_No," + myDatabase.qo(prod_id) + "," + myDatabase.qo(qty) + "," + myDatabase.qo(suger_id) + "," + myDatabase.qo(ice_id) + ")"; if (i + 1 == addItems.Rows.Count) { sqlstr += ";"; } else { sqlstr += ","; } } myDatabase.execSQL(sqlstr); addItems.Rows.Clear(); Show_Grid(); DialogClass.MessageSimple("訂單已送出"); } } else { DialogClass.MessageSimple("請選擇欲結帳的商品"); } }
protected void Save_User(object sender, EventArgs e) { string id = Session["edit_user_id"].ToString(); string sqlStr = ""; if (string.IsNullOrEmpty(id)) { sqlStr = " insert sys_user (account,hash,name,position,mobile,address,email,post_time) values(" + myDatabase.qo(account.Text) + "," + myDatabase.qo(hash.Text) + "," + myDatabase.qo(name.Text) + "," + myDatabase.qo(position.Text) + "," + myDatabase.qo(mobile.Text) + "," + myDatabase.qo(address.Text) + "," + myDatabase.qo(email.Text) + ", getDate() )"; myDatabase.execSQL(sqlStr); DialogClass.MessageSimple("新增成功"); Response.Redirect("~/SysUser"); } else { sqlStr = " update sys_user " + " set account = " + myDatabase.qo(account.Text) + "," + " hash = " + myDatabase.qo(hash.Text) + "," + " name = " + myDatabase.qo(name.Text) + "," + " position = " + myDatabase.qo(position.Text) + "," + " mobile = " + myDatabase.qo(mobile.Text) + "," + " address = " + myDatabase.qo(address.Text) + "," + " email = " + myDatabase.qo(email.Text) + "where id = " + myDatabase.qo(id); Response.Write(sqlStr); myDatabase.execSQL(sqlStr); DialogClass.MessageSimple("更新成功"); Response.Redirect("~/SysUser"); } }