protected void Save_Button_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(NewPass.Text)) { if (NewPass.Text.Trim() == SurePass.Text.Trim()) { DataTable dt = Session["UserTable"] as DataTable; dt.Rows[0]["PassWord"] = NewPass.Text.Trim(); try { int k = DataBase.update("UserInfo", "UserRecID", dt); MessageTxt.Value = "密码修改成功!"; } catch (Exception) { MessageTxt.Value = "密码修改失败,请重试!"; } } else { MessageTxt.Value = "新密码与确认密码不符合,请重新输入!"; } } else { MessageTxt.Value = "新密码不能为空!"; } }
protected void AddStaff_But_OnClick(object sender, EventArgs e) { this.Timer1.Enabled = false; if (!string.IsNullOrEmpty(this.StaffName.Text) && !string.IsNullOrEmpty(this.StaffPass.Text) && !string.IsNullOrEmpty(this.StaffTel.Text)) { if (this.StaffPass.Text.Trim() == this.SureStaffPass.Text.Trim()) { string mySql = "select PhoneNumber from UserInfo where PhoneNumber='" + this.StaffTel.Text.Trim() + "'"; DataSet Sr = DataBase.RunDataSet(mySql); DataTable s = Sr.Tables[0]; if (s.Rows.Count > 0) { MessageTxt.Value = "此号码已存在!"; this.StaffTel.Text = ""; } else { string sqlconnection = "select * from UserInfo where 0=1"; DataSet mySet = DataBase.RunDataSet(sqlconnection); DataTable myTable = mySet.Tables[0]; DataRow myRow = myTable.NewRow(); myRow["UserName"] = this.StaffName.Text.Trim(); try { myRow["Sex"] = this.Sex.SelectedItem.Value; } catch (Exception) { } myRow["RegisterTime"] = System.DateTime.Now; myRow["PhoneNumber"] = this.StaffTel.Text.Trim(); myRow["UserRecID"] = 0; myRow["Password"] = this.StaffPass.Text.Trim(); myRow["UserType"] = 3; myTable.Rows.Add(myRow); try { DataBase.update("UserInfo", "UserRecID", myTable); this.Page.RegisterStartupScript("", "<script>alert('员工账号添加成功!');window.location.href= 'BossWeb.aspx'</script>"); this.StaffName.Text = ""; this.StaffTel.Text = ""; } catch (Exception) { throw; } } } else { MessageTxt.Value = "密码与确认密码不符合,请重新输入!"; } } else { MessageTxt.Value = "用户名或电话号码或密码不能为空!"; } }
//忘记密码时确定按钮 protected void OK_Click(object sender, EventArgs e) { phoneNumber = this.UserTel.Value.ToString().Trim(); if (String.IsNullOrEmpty(phoneNumber)) { MessageTxt.Value = "请输入电话号码!"; return; } if (String.IsNullOrEmpty(this.UserNewpassword.Value.ToString().Trim())) { MessageTxt.Value = "请输入密码!"; return; } else { if (this.Sure_Userpassword.Value.ToString().Trim() != this.UserNewpassword.Value.ToString().Trim()) { MessageTxt.Value = "两次输入密码不一致!"; return; } } if (MetarnetRegex.IsMobilePhone(phoneNumber)) { if (IsHaveSend && (IdentCode.Value.ToString().Trim() == SecurityCode.ToString())) //判断验证码是否正确 { string pass = this.UserNewpassword.Value.ToString().Trim(); DataSet ds = DataBase.RunDataSet("select * from UserInfo where PhoneNumber='" + phoneNumber + "'"); DataTable dt = ds.Tables[0]; dt.Rows[0]["Password"] = pass; int k = DataBase.update("UserInfo", "UserRecID", dt); if (k > 0) { MessageTxt.Value = "密码修改成功!"; //还原 IsHaveSend = false; SecurityCode = 0; return; } } else { MessageTxt.Value = "验证码不正确!"; return; } } else { MessageTxt.Value = "手机号格式不正确!"; return; } }
protected void Save_Button_Click(object sender, EventArgs e) { phoneNumber = this.UserTelNumber.Text.Trim(); DataTable dt = Session["UserTable"] as DataTable; dt.Rows[0]["College"] = this.UserCollge.Text.ToString(); dt.Rows[0]["Major"] = this.UserMajor.Text.ToString(); dt.Rows[0]["Email"] = this.UserQQMail.Text.ToString(); try { dt.Rows[0]["Sex"] = this.Sex.SelectedItem.Value; } catch (Exception) { } try { int k = DataBase.update("UserInfo", "UserRecID", dt); } catch (Exception) { } if (IsHaveSend) { if (IdentifyCode.Text.Trim() == SecurityCode.ToString()) //判断验证码是否正确 { dt.Rows[0]["PhoneNumber"] = this.UserTelNumber.Text.Trim(); try { int k = DataBase.update("UserInfo", "UserRecID", dt); //还原 IsHaveSend = false; SecurityCode = 0; return; } catch (Exception) { } } else { MessageTxt.Value = "验证码不正确,手机号未修改成功!";//这里manuInput.Text就是要弹出的信息 this.IdentifyCode.Text = ""; return; } } MessageTxt.Value = "修改成功!"; this.IdentifyCode.Text = ""; }
/// <summary> /// 注册 1,成功;2,用户名已存在;3,电话号码已存在 /// </summary> /// <param name="obj"></param> /// <returns></returns> public bool Register(EnUserInfo obj) { DataTable user = getDatable(obj); int key; try { key = DataBase.update("UserInfo", "UserRecID", user); return(true); } catch (Exception ex) { return(false); } }
protected void OrderBtu_Click(object sender, EventArgs e) { EnOrder en = Session["OrderInfo"] as EnOrder; CnOrders cn = new CnOrders(); DataTable dt = cn.getDataTable("select * from Orders where OrderNumber='" + en.orderNumber.Trim() + "'"); dt.Rows[0]["Coment"] = Coments.Text.Trim(); DataSet ds = DataBase.RunDataSet("select * from Doc where 0=1"); DataTable DocTable = ds.Tables[0]; try { dt.Rows[0]["OrderTypeID"] = int.Parse(SendMothedList.SelectedItem.Value.Trim()); dt.Rows[0]["AddressRecID"] = int.Parse(AddressList.SelectedItem.Value.Trim()); dt.Rows[0]["ToalPrice"] = this.Money.Text; int k = DataBase.update("Orders", "OrderNumber", dt); List <EnDoc> docslist = en.docs; foreach (var item in docslist) { DataRow dr = DocTable.NewRow(); dr["DocID"] = 0; dr["OrderNumber"] = en.orderNumber.Trim(); dr["Comment"] = Coments.Text.Trim(); dr["DocName"] = item.docName; dr["DocPath"] = item.docPath; dr["DocTypeID"] = item.docTypeID; dr["UploadTime"] = en.placeOrderTime; dr["TotalPages"] = item.totalPages; dr["PrintTypeID"] = item.printTypeID; DocTable.Rows.Add(dr); } int j = DataBase.update("Doc", "DocID", DocTable); this.Page.RegisterStartupScript("", "<script>alert('下单成功!');window.location.href= 'UserCenter.aspx'</script>"); } catch (Exception) { int k = DataBase.ExecuteNonQuery("delete Orders where OrderNumber='" + en.orderNumber + "'"); int l = DataBase.ExecuteNonQuery("delete Doc where OrderNumber='" + en.orderNumber + "'"); this.Page.RegisterStartupScript("", "<script>alert('下单失败!');window.location.href= 'UserCenter.aspx'</script>"); } }
protected void UserList_UpdateCommand(object source, DataListCommandEventArgs e) { this.Timer1.Enabled = false; string ID = this.UserList.DataKeys[e.Item.ItemIndex].ToString(); string mySql = "select UserRecID,UserName,Password,PhoneNumber from UserInfo where PhoneNumber='" + ID + "'"; DataSet MySet = DataBase.RunDataSet(mySql); DataTable MyTable = MySet.Tables[0]; try { MyTable.Rows[0]["UserName"] = ((TextBox)e.Item.FindControl("userText")).Text.Trim(); MyTable.Rows[0]["Password"] = ((TextBox)e.Item.FindControl("pwdText")).Text.Trim(); MyTable.Rows[0]["PhoneNumber"] = ((TextBox)e.Item.FindControl("phoneNumText")).Text.Trim(); DataBase.update("UserInfo", "UserRecID", MyTable); ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('更新成功!');window.location.href= 'BossWeb.aspx'", true); } catch (Exception) { throw; } }
protected void ModifyPass_But_Click(object sender, EventArgs e) { this.Timer1.Enabled = false; if (!string.IsNullOrEmpty(this.BusiNewPass.Text)) { if (this.BusiNewPass.Text.Trim() == this.SurePass.Text.Trim()) { DataTable dt = Session["UserTable"] as DataTable; dt.Rows[0]["Password"] = this.BusiNewPass.Text.Trim(); DataBase.update("UserInfo", "UserRecID", dt); ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('密码修改成功!');window.location.href= 'BossWeb.aspx'", true); } else { MessageTxt.Value = "新密码与确认密码不符合,请重新输入!"; } } else { MessageTxt.Value = "新密码不能为空!"; } }
protected void SureAdress_Click(object sender, EventArgs e) { DataTable dt = Session["UserTable"] as DataTable; string Sql = "select * from Address where UserRecID='" + dt.Rows[0]["UserRecID"].ToString() + "'"; DataSet ST = DataBase.RunDataSet(Sql); DataTable S = ST.Tables[0]; try { DataRow dr = S.NewRow(); dr["AddressRecID"] = 0; dr["UserRecID"] = dt.Rows[0]["UserRecID"].ToString(); dr["AddressName"] = this.AdressTex.Text.Trim(); dr["IsUsuallyAddress"] = "0"; S.Rows.Add(dr); int k = DataBase.update("Address", "AddressRecID", S); this.Page.RegisterStartupScript("", "<script>alert('增加成功!');window.location.href= 'Order.aspx'</script>"); } catch (Exception) { this.Page.RegisterStartupScript("", "<script>alert('增加失败!');window.location.href= 'Order.aspx'</script>"); this.SureAdress.Text = ""; } }
protected void SaveBtu_Click(object sender, EventArgs e) { int count, k, j, m, n; //修改打印类型每页单价 string Sql = "select * from PrintType "; DataSet ST = DataBase.RunDataSet(Sql); DataTable S = ST.Tables[0]; S.Rows[0]["SinglePagePrice"] = this.BWPrice.Text.Trim(); S.Rows[1]["SinglePagePrice"] = this.ColorPrice.Text.Trim(); try { k = DataBase.update("PrintType", "PrintTypeID", S); } catch (Exception) { throw; } //修改配送方式价格 string mySql = "select * from OrderType"; DataSet mySet = DataBase.RunDataSet(mySql); DataTable myTable = mySet.Tables[0]; myTable.Rows[0]["SendPrice"] = this.SendModePrice0.Text.Trim(); myTable.Rows[1]["SendPrice"] = this.SendModePrice1.Text.Trim(); myTable.Rows[2]["SendPrice"] = this.SendModePrice2.Text.Trim(); try { j = DataBase.update("OrderType", "OrderTypeID", myTable); } catch (Exception) { throw; } //修改电话号码、地址 DataTable dt = Session["UserTable"] as DataTable; dt.Rows[0]["PhoneNumber"] = this.PhoneNumberTXT.Text.Trim(); try { m = DataBase.update("UserInfo", "UserRecID", dt); } catch (Exception) { throw; } string SqlConnection = "select * from Address where UserRecID=" + dt.Rows[0]["UserRecID"].ToString(); DataSet myDataSet = DataBase.RunDataSet(SqlConnection); DataTable myDataTable = myDataSet.Tables[0]; myDataTable.Rows[0]["AddressName"] = this.AddressTXT.Text.Trim(); try { n = DataBase.update("Address", "AddressRecID", myDataTable); } catch (Exception) { throw; } count = k + j + m + n; if (count > 0) { this.Response.Write(" <script language=javascript>alert('修改成功!'); window.location.href= 'ShopManagement.aspx'</script> "); } else { MessageTxt.Value = "修改失败!"; } }
//增加、删除地址 protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e) { DataTable dt = Session["UserTable"] as DataTable; int i = Convert.ToInt32(dt.Rows[0]["UserRecID"]); string AdressNum = "select AddressName from Address where UserRecID=" + i; DataSet AdressN = DataBase.RunDataSet(AdressNum); if (e.CommandName.Equals("del")) { if (AdressN.Tables[0].Rows.Count > 1) { string mycon = "delete from Address where AddressName='" + e.CommandArgument + "'"; int k = DataBase.ExecuteNonQuery(mycon); if (k > 0) { MessageTxt.Value = "删除成功!"; } Response.Redirect("UserCenter.aspx"); } else { MessageTxt.Value = "必须要有一个地址!删除失败!"; } } if (e.CommandName == "insert") { TextBox tbx = (TextBox)e.Item.FindControl("UserAdressAdd"); if (tbx.Text != "") { if (AdressN.Tables[0].Rows.Count < 3) { for (int k = 0; k < AdressN.Tables[0].Rows.Count; k++) { if (tbx.Text != AdressN.Tables[0].Rows[k]["AddressName"].ToString()) { string sql = "select * from Address where 0=1"; DataSet AdressForm = DataBase.RunDataSet(sql); DataTable AdresTable = new DataTable(); AdresTable = AdressForm.Tables[0]; DataRow dr = AdresTable.NewRow(); dr["AddressRecID"] = 0; dr["UserRecID"] = i; dr["AddressName"] = tbx.Text; dr["IsUsuallyAddress"] = 1; AdresTable.Rows.Add(dr); int p = DataBase.update("Address", "AddressRecID", AdresTable); if (p > 0) { MessageTxt.Value = "增添成功!"; tbx.Text = ""; } Response.Redirect("UserCenter.aspx"); } else { MessageTxt.Value = "此地址已存在!请重新输入!"; tbx.Text = ""; } } } else { MessageTxt.Value = "地址不能超过三个!添加失败!"; tbx.Text = ""; } } else { MessageTxt.Value = "不能增添地址,请重新输入地址!"; } } }