protected void Page_Load(object sender, EventArgs e) { itemName = Request.QueryString["itemName"] ?? ""; itemType = Request.QueryString["itemType"] ?? ""; //比较分析明细进入使用 today = Session["TodayDate"].ToString(); if (Request.QueryString["date"] != null && Request.QueryString["date"] != "") { if (ValidHelper.CheckDate(Request.QueryString["date"])) { today = Request.QueryString["date"]; } } userId = Int32.Parse(Session["UserID"].ToString()); if (Request.QueryString["catTypeId"] != null && Request.QueryString["catTypeId"] != "") { catTypeId = Request.QueryString["catTypeId"]; } if (!IsPostBack) { PopulateControls(); } }
protected void Page_Load(object sender, EventArgs e) { userId = Int32.Parse(Session["UserID"].ToString()); if (Request.QueryString["type"] != null && Request.QueryString["type"] != "") { type = Request.QueryString["type"]; } #region 入日期 if (Request.QueryString["date"] != null && Request.QueryString["date"] != "") { if (!ValidHelper.CheckDate(Request.QueryString["date"])) { Session["TodayDate"] = DateTime.Now.ToString("yyyy-MM-dd"); } else { Session["TodayDate"] = Request.QueryString["date"]; } } #endregion today = Session["TodayDate"].ToString(); if (!IsPostBack) { PopulateControls(); } }
/// <summary> /// 中文汉字 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnChinese_Click(object sender, EventArgs e) { string strValue = this.cboxChinese.SelectedItem as string; bool checkFlag = false; switch (strValue) { case "中文汉字": checkFlag = ValidHelper.ChsIsChinese(this.txtChinese.Text); break; case "中字母数": checkFlag = ValidHelper.ChsIsChineseOrEngOrNum(this.txtChinese.Text); break; case "真实姓名": checkFlag = ValidHelper.ChsIsTname(this.txtChinese.Text); break; case "半角转换": this.lblResultChinese.Text = string.Format(" {0}", ValidHelper.ChsToDBC(this.txtChinese.Text)); break; default: break; } this.lblResultChinese.Text = checkFlag.ToString(); }
/// <summary> /// SQL注入 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSqlInjection_Click(object sender, EventArgs e) { string strValue = this.cboxSqlInjection.SelectedItem as string; bool checkFlag = false; switch (strValue) { case "四方法合一": checkFlag = ValidHelper.IsSqlFilter(this.txtSqlInjection.Text); break; case "SQL关键字": checkFlag = ValidHelper.IsSqlInjectionOfKey(this.txtSqlInjection.Text); break; case "SQL数据类型": checkFlag = ValidHelper.IsSqlInjectionOfType(this.txtSqlInjection.Text); break; case "SQL危险命令": checkFlag = ValidHelper.IsSqlInjectionOfURL(this.txtSqlInjection.Text); break; case "SQL危险字符": checkFlag = ValidHelper.IsSqlInjectionOfString(this.txtSqlInjection.Text); break; default: break; } this.lblResultSqlInjection.Text = checkFlag.ToString(); }
/// <summary> /// 角色信息添加数据检测 /// </summary> /// <param name="form">数据表单</param> /// <param name="stateInfo">状态消息</param> /// <returns>执行结果</returns> private bool AddedByCheck(FormCollection form, out string stateInfo) { stateInfo = GeneralHandler.StateSuccess; string txtName = form["txtName"] as string; if (string.IsNullOrEmpty(txtName) || txtName.Length < 2 || txtName.Length > 50) { stateInfo = "名称不能为空或小于2个或大于50个字符!"; return(false); } if (!ValidHelper.ChsIsChineseOrEngOrNums(txtName)) { stateInfo = "您输入的名称不正确!(只能由汉字、字母、数字组成)"; return(false); } string txtCode = form["txtCode"] as string; if ((txtCode.Length > 0 && !ValidHelper.EngIsEngAndNums(txtCode)) || txtCode.Length > 50) { stateInfo = "您输入的编码不正确!(只能由字母和数字组成,且不大于50个字)"; return(false); } string txtDesc = form["txtDesc"] as string; if ((txtDesc.Length > 0 && !ValidHelper.ChsIsMemos(txtDesc)) || txtDesc.Length > 300) { stateInfo = "您输入的描述不正确!(只能由汉字、字母、数字组成,且不大于300个字)"; return(false); } return(true); }
//修改资料 protected void SubmitButton_Click(object sender, EventArgs e) { string userNickName = this.UserNickName.Text.Trim(); this.Label3.Text = ""; string userEmail = this.UserEmail.Text.Trim(); if (userEmail != "") { if (!ValidHelper.CheckEmail(userEmail)) { this.Label3.Text = "邮箱格式填写错误!"; return; } } string userPhone = this.UserPhone.Text.Trim(); if (userPhone != "") { if (!ValidHelper.CheckPhone(userPhone)) { this.Label6.Text = "手机号码填写错误!"; return; } } string userWorkDay = this.UserWorkDay.SelectedValue; string categoryRate = this.CategoryRate.Text.Trim(); if (!ValidHelper.CheckDouble(categoryRate)) { Utility.Alert(this, "预算率填写错误!"); return; } UserEntity user = UserAccess.GetUserById(userId); user.UserNickName = userNickName; user.UserEmail = userEmail; user.UserPhone = userPhone; user.UserWorkDay = userWorkDay; user.CategoryRate = Double.Parse(categoryRate); user.Synchronize = 1; bool success = UserAccess.UpdateUser(user); if (success) { Session["UserNickName"] = user.UserNickName; Session["UserWorkDay"] = user.UserWorkDay; Session["CategoryRate"] = user.CategoryRate; Utility.Alert(this, "修改成功。", "UserAdmin.aspx"); } else { Utility.Alert(this, "修改失败!"); } }
/// <summary> /// 电话号码 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnEnter_Click(object sender, EventArgs e) { string strValue = this.cboxPhone.SelectedItem as string; bool checkFlag = false; switch (strValue) { case "电话号码": checkFlag = ValidHelper.TelIsTelephone(this.txtMobile.Text); break; case "中国移动": checkFlag = ValidHelper.TelIsChinaMobile(this.txtMobile.Text); break; case "中国联通": checkFlag = ValidHelper.TelIsChinaUnicom(this.txtMobile.Text); break; case "中国电信": checkFlag = ValidHelper.TelIsChinaTelecom(this.txtMobile.Text); break; default: break; } this.lblResultPhone.Text = checkFlag.ToString(); }
//快速添加消费 protected void LinkButton1_Click(object sender, EventArgs e) { string itemName = this.ItemNameEmpIns.Text.Trim(); string itemType = this.ItemTypeEmpIns.SelectedValue; int catTypeId = Convert.ToInt32(this.CatTypeEmpIns.SelectedValue); string itemPrice = this.ItemPriceEmpIns.Text.Trim(); DateTime itemBuyDate = Convert.ToDateTime(this.ItemBuyDateEmpIns.Text.Trim() + " " + DateTime.Now.ToString("HH:mm:ss")); int cardId = Convert.ToInt32(this.CardEmpIns.SelectedValue); if (itemName == "") { Utility.Alert(this, "商品名称未填写!"); return; } Response.Cookies["CatTypeID"].Value = catTypeId.ToString(); Response.Cookies["CatTypeID"].Expires = DateTime.MaxValue; Response.Cookies["CardID"].Value = cardId.ToString(); Response.Cookies["CardID"].Expires = DateTime.MaxValue; if (!ValidHelper.CheckDouble(itemPrice)) { Utility.Alert(this, "商品价格填写错误!"); return; } ItemInfo item = new ItemInfo(); item.ItemType = itemType; item.ItemName = itemName; item.CategoryTypeID = catTypeId; item.ItemPrice = Convert.ToDecimal(itemPrice); item.ItemBuyDate = itemBuyDate; item.UserID = userId; item.RegionID = 0; item.RegionType = ""; item.Synchronize = 1; item.ZhuanTiID = ztId; item.ModifyDate = DateTime.Now; item.CardID = cardId; bool success = item_bll.InsertItem(item); if (success) { Session["TodayDate"] = itemBuyDate.ToString("yyyy-MM-dd"); this.ItemNameEmpIns.Text = ""; this.ItemPriceEmpIns.Text = ""; List.EditIndex = -1; BindGrid(); } else { Utility.Alert(this, "添加失败!"); return; } }
protected override ValidationResult IsValid(object value, ValidationContext validationContext) { if (ValidHelper.ValidEmail(value.ToString())) { return(new ValidationResult(FormatErrorMessage(validationContext.DisplayName))); } return(null); }
//保存方法 protected int SaveItem() { string itemName = this.ItemNameEmpIns.Text.Trim(); if (itemName == "") { Utility.Alert(this, "商品名称未填写!"); return(2); } string itemType = this.ItemTypeEmpIns.SelectedValue; int catTypeId = Int32.Parse(this.CatTypeEmpIns.SelectedValue); Response.Cookies["CatTypeID"].Value = catTypeId.ToString(); Response.Cookies["CatTypeID"].Expires = DateTime.MaxValue; string itemPrice = this.ItemPriceEmpIns.Text.Trim(); if (!ValidHelper.CheckDouble(itemPrice)) { Utility.Alert(this, "商品价格填写错误!"); return(2); } DateTime itemBuyDate = DateTime.Parse(today + " " + DateTime.Now.ToString("HH:mm:ss")); int cardId = Int32.Parse(this.CardEmpIns.SelectedValue); Response.Cookies["CardID"].Value = cardId.ToString(); Response.Cookies["CardID"].Expires = DateTime.MaxValue; ItemEntity item = new ItemEntity(); item.ItemType = itemType; item.ItemName = itemName; item.CategoryTypeID = catTypeId; item.ItemPrice = Double.Parse(itemPrice); item.ItemBuyDate = itemBuyDate; item.UserID = userId; item.RegionID = 0; item.RegionType = ""; item.Synchronize = 1; item.CardID = cardId; bool success = ItemAccess.InsertItem(item, 1); if (success) { Session["TodayDate"] = itemBuyDate.ToString("yyyy-MM-dd"); return(1); } else { return(0); } }
/// <summary> /// 数字校验 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnNumeral_Click(object sender, EventArgs e) { string strValue = this.cboxNumeral.SelectedItem as string; bool checkFlag = false; switch (strValue) { case "纯数字": checkFlag = ValidHelper.NumIsInteger(this.txtNumeral.Text); break; case "零和非零": checkFlag = ValidHelper.NumIsZeroOrNot(this.txtNumeral.Text); break; case "正数两位小数": checkFlag = ValidHelper.NumIsPlus2Point(this.txtNumeral.Text); break; case "正数一至三位": checkFlag = ValidHelper.NumIsPlus3Point(this.txtNumeral.Text); break; case "非零正整数": checkFlag = ValidHelper.NumIsIntegralBySignless(this.txtNumeral.Text); break; case "非零负整数": checkFlag = ValidHelper.NumIsIntegralByNegative(this.txtNumeral.Text); break; case "正浮点数": checkFlag = ValidHelper.NumIsFloatBySignless(this.txtNumeral.Text); break; case "负浮点数": checkFlag = ValidHelper.NumIsFloatByNegative(this.txtNumeral.Text); break; case "Int32类型": checkFlag = ValidHelper.NumIsNumeric(this.txtNumeral.Text); break; case "Double类型": checkFlag = ValidHelper.NumIsDouble(this.txtNumeral.Text); break; case "Int32类型逗号": checkFlag = ValidHelper.NumIsNumericList(this.txtNumeral.Text); break; default: break; } this.lblResultNumeral.Text = checkFlag.ToString(); }
/// <summary> /// 模块功能数据列表 /// </summary> /// <param name="id">数据表单</param> /// <returns>执行结果</returns> public ActionResult Search(FormCollection form) { string strWhere = null; var pgParam = "Nothing,Nothing"; //隶属模块 var sltModule = TypeHelper.TypeToInt32(form["sltModule"], -1); if (sltModule > 0) { pgParam += string.Format(",sltModule,{0}", sltModule); if (strWhere == null) { strWhere = string.Format("mdl_id='{0}'", sltModule); } else { strWhere += string.Format(" and mdl_id='{0}'", sltModule); } } //功能编码 var txtCode = form["txtCode"] as string; if (!string.IsNullOrEmpty(txtCode) && ValidHelper.EngIsEngAndNums(txtCode)) { pgParam += string.Format(",txtCode,{0}", txtCode); if (strWhere == null) { strWhere = string.Format("charindex('{0}',fun_code)>0", txtCode); } else { strWhere += string.Format(" and charindex('{0}',fun_code)>0", txtCode); } } var dataPager = new PagerHelperCHS(); dataPager.PageSize = GeneralHandler.PageSize; if (form.Count > 1) { dataPager.PageCurrent = TypeHelper.TypeToInt32(form["pager"], 1); } else { dataPager.PageCurrent = TypeHelper.TypeToInt32(form["id"], 1); } int pageCount, recordCount; var dataList = DawnAuthFunctionBLL.SelectPSPisAllPurposeRowNumber(dataPager.PageSize, dataPager.PageCurrent, "fun_time desc,mdl_id", strWhere, out pageCount, out recordCount); dataPager.PageCount = pageCount; dataPager.RecordCount = recordCount; dataPager.PageRecordCount = dataList.Count; ViewBag.Pager = dataPager; ViewBag.PagerParam = pgParam; ViewBag.ModuleList = DawnAuthModuleBLL.ISelect(); return(View("List", dataList)); }
/// <summary> /// 权限扩展数据列表 /// </summary> /// <param name="id">数据表单</param> /// <returns>执行结果</returns> public ActionResult Search(FormCollection form) { string strWhere = null; var pgParam = "Nothing,Nothing"; //扩展编码 var txtCode = form["txtCode"] as string; if (!string.IsNullOrEmpty(txtCode) && ValidHelper.EngIsEngAndNum(txtCode)) { pgParam += string.Format(",txtCode,{0}", txtCode); if (strWhere == null) { strWhere = string.Format("charindex('{0}',exte_code)>0", txtCode); } else { strWhere += string.Format(" and charindex('{0}',exte_code)>0", txtCode); } } //扩展标识 var txtMark = form["txtMark"] as string; if (!string.IsNullOrEmpty(txtMark) && ValidHelper.EngIsEngAndNum(txtMark)) { pgParam += string.Format(",txtMark,{0}", txtMark); if (strWhere == null) { strWhere = string.Format("charindex('{0}',exte_mark)>0", txtMark); } else { strWhere += string.Format(" and charindex('{0}',exte_mark)>0", txtMark); } } var dataPager = new PagerHelperCHS(); dataPager.PageSize = GeneralHandler.PageSize; if (form.Count > 1) { dataPager.PageCurrent = TypeHelper.TypeToInt32(form["pager"], 1); } else { dataPager.PageCurrent = TypeHelper.TypeToInt32(form["id"], 1); } int pageCount, recordCount; var dataList = DawnAuthExtentBLL.SelectPSPisAllPurposeRowNumber(dataPager.PageSize, dataPager.PageCurrent, "exte_time desc,exte_code", strWhere, out pageCount, out recordCount); dataPager.PageCount = pageCount; dataPager.RecordCount = recordCount; dataPager.PageRecordCount = dataList.Count; ViewBag.Pager = dataPager; ViewBag.PagerParam = pgParam; return(View("List", dataList)); }
protected void PopulateControls() { string title = Request.QueryString["title"]; string itemName = Request.QueryString["itemName"] ?? ""; string itemType = Request.QueryString["itemType"] ?? ""; string today = Session["TodayDate"].ToString(); string catTypeId = "0"; if (Request.QueryString["catTypeId"] != null && Request.QueryString["catTypeId"] != "") { catTypeId = Request.QueryString["catTypeId"]; } //比较分析明细进入使用 if (Request.QueryString["date"] != null && Request.QueryString["date"] != "") { if (ValidHelper.CheckDate(Request.QueryString["date"])) { today = Request.QueryString["date"]; } } int userId = Int32.Parse(Session["UserID"].ToString()); double priceMax = 0; DataTable dt = ItemAccess.GetItemNumDetailList(itemName, itemType, userId, Int32.Parse(catTypeId), today, "list", out priceMax); string max = "1"; string step = "1"; string itemNameValue = ""; string itemPrice = ""; if (dt.Rows.Count > 0) { max = Math.Ceiling(priceMax).ToString(); step = Math.Floor(Double.Parse(max) / 10).ToString(); int i = 0; foreach (DataRow dr in dt.Rows) { if (i == 15) { break; } string dot = (i < 15 - 1 && i < dt.Rows.Count - 1 ? "," : ""); itemNameValue += "{\"text\":\"" + DateTime.Parse(dr["ItemBuyDate"].ToString()).ToString("yyyy-MM-dd") + "\",\"rotate\":90}" + dot; itemPrice += dr["ItemPrice"].ToString() + dot; i++; } } else { itemNameValue = "{\"text\":\"0\"},{\"text\":\"1\"}"; } Response.Write(GetChartJsonString(itemNameValue, itemPrice, title, max, step)); Response.End(); }
//修改密码 protected void Button2_Click(object sender, EventArgs e) { string userPassword = ""; try { userPassword = UserAccess.GetUserPasswordById(userId); } catch { Utility.Alert(this, "修改失败!"); return; } string oldPassword = this.UserPassword.Text.Trim(); if (oldPassword == "") { this.Label2.Text = "旧密码未填写!"; return; } else { if (oldPassword != userPassword) { this.Label2.Text = "旧密码不正确!"; return; } } string newPassword = this.NewPassword.Text.Trim(); string newPassword2 = this.NewPassword2.Text.Trim(); if (!ValidHelper.CheckLength(newPassword, 2)) { this.Label1.Text = "新密码填写错误!"; return; } if (newPassword != newPassword2) { this.Label4.Text = "两次新密码不一致!"; return; } bool success = UserAccess.UpdateUserPassword(userId, newPassword); if (success) { Utility.Alert(this, "修改成功。", "UserLogout.aspx"); } else { Utility.Alert(this, "修改失败!"); } }
/// <summary> /// 错误信息详细信息 /// </summary> /// <param name="id">错误编号</param> /// <param name="pager">页码</param> /// <returns>执行结果</returns> public ActionResult ErrorDetailed(string id, string pager) { if (string.IsNullOrEmpty(id) || !ValidHelper.IsGuid(id)) { return(RedirectToAction("ErrorList")); } var dataInfo = DawnAuthErrorBLL.Select(Guid.Parse(id)); ViewBag.PageCurrent = pager; return(View(dataInfo)); }
//绑定已有帐号 protected void BoundButton_Click(object sender, EventArgs e) { string userName = this.UserNameBound.Text.Trim(); if (!ValidHelper.CheckLength(userName, 2)) { Utility.Alert(this, "用户名填写错误!"); return; } string userPassword = this.UserPasswordBound.Text.Trim(); if (!ValidHelper.CheckLength(userPassword, 2)) { Utility.Alert(this, "密码填写错误!"); return; } int newUserId = 0; bool success = UserAccess.CheckUserLogin(userName, userPassword, out newUserId); if (success) { UserEntity user = UserAccess.GetUserById(newUserId); success = OAuthAccess.OAuthBoundUser(userId, user.UserID); if (success) { Session["UserID"] = userId = user.UserID; Session["UserName"] = user.UserName; Session["UserNickName"] = user.UserNickName; Session["UserTheme"] = user.UserTheme; Session["UserLevel"] = user.UserLevel.ToString(); Session["UserFrom"] = user.UserFrom; Session["UserWorkDay"] = user.UserWorkDay; Session["UserFunction"] = user.UserFunction; Session["CategoryRate"] = user.CategoryRate; Response.Cookies["ThemeCookie"].Value = user.UserTheme; Response.Cookies["ThemeCookie"].Expires = DateTime.MaxValue; PopulateControls(); Utility.Alert(this, "绑定成功。", "UserBoundAdmin.aspx"); } else { Utility.Alert(this, "绑定失败!"); } } else { Utility.Alert(this, "登录失败!"); } }
/// <summary> /// 模块信息添加数据检测 /// </summary> /// <param name="form">数据表单</param> /// <param name="stateInfo">状态消息</param> /// <returns>执行结果</returns> private bool AddedByCheck(FormCollection form, out string stateInfo) { stateInfo = GeneralHandler.StateSuccess; int father = TypeHelper.TypeToInt32(form["ddlFather"], -1); if (father == 0 || father < -1) { stateInfo = "模块标识不正确!"; return(false); } string txtName = form["txtName"] as string; if (string.IsNullOrEmpty(txtName) || txtName.Length < 2 || txtName.Length > 50) { stateInfo = "名称不能为空或小于2个或大于50个字符!"; return(false); } if (!ValidHelper.ChsIsChineseOrEngOrNums(txtName)) { stateInfo = "您输入的名称不正确!(只能由汉字、字母、数字组成)"; return(false); } string txtCode = form["txtCode"] as string; if ((txtCode.Length > 0 && !ValidHelper.EngIsEngAndNums(txtCode)) || txtCode.Length > 50) { stateInfo = "您输入的编码不正确!(只能由字母和数字组成,且不大于50个字)"; return(false); } string txtIdent = form["txtIdent"] as string; if (!ValidHelper.NumIsInteger(txtIdent)) { stateInfo = "您输入的识别码不正确!(只能由数字组成,介于1-65535为佳)"; return(false); } string txtRank = form["txtRank"] as string; if ((txtRank.Length > 0 && !ValidHelper.NumIsIntegralBySignless(txtRank)) || int.Parse(txtRank) < 1 || int.Parse(txtRank) > 65535) { stateInfo = "您输入的序列不正确!(只能由数字组成,且不小于1及大于65535)"; return(false); } string txtDesc = form["txtDesc"] as string; if ((txtDesc.Length > 0 && !ValidHelper.ChsIsMemos(txtDesc)) || txtDesc.Length > 300) { stateInfo = "您输入的描述不正确!(只能由汉字、字母、数字组成,且不大于300个字)"; return(false); } return(true); }
/// <summary> /// 管理员信息编辑数据检测 /// </summary> /// <param name="form">数据表单</param> /// <param name="stateInfo">状态消息</param> /// <returns>执行结果</returns> private bool EditoredByCheck(FormCollection form, out string stateInfo) { stateInfo = GeneralHandler.StateSuccess; int sltDepart = TypeHelper.TypeToInt32(form["sltDepart"], -1); if (sltDepart < 1) { stateInfo = "隶属部门不正确!"; return(false); } int ddlGrade = TypeHelper.TypeToInt32(form["ddlGrade"], -1); if (ddlGrade < 1 || ddlGrade > 3) { stateInfo = "管理级别不正确!"; return(false); } string txtSurname = form["txtSurname"] as string; if (string.IsNullOrEmpty(txtSurname) || txtSurname.Length < 2 || txtSurname.Length > 10) { stateInfo = "姓名不能为空或小于2个或大于10个汉字!"; return(false); } if (!ValidHelper.ChsIsChinese(txtSurname)) { stateInfo = "您输入的姓名不正确!(只能由汉字组成)"; return(false); } string txtMobile = form["txtMobile"] as string; if (string.IsNullOrEmpty(txtMobile) || txtMobile.Length > 15 || !ValidHelper.TelIsMobile(txtMobile)) { stateInfo = "您输入的手机号码为空或不正确!"; return(false); } string txtEmail = form["txtEmail"] as string; if (string.IsNullOrEmpty(txtEmail) || txtEmail.Length > 50 || !ValidHelper.IsEmail(txtEmail)) { stateInfo = "您输入的电子邮件为空或不正确!"; return(false); } string txtDesc = form["txtDesc"] as string; if ((txtDesc.Length > 0 && !ValidHelper.ChsIsMemos(txtDesc)) || txtDesc.Length > 300) { stateInfo = "您输入的描述不正确!(只能由汉字、字母、数字组成,且不大于300个字)"; return(false); } return(true); }
//添加钱包操作 protected void Button1_Click(object sender, EventArgs e) { string cardName = this.CardNameEmpIns.Text.Trim(); string cardMoney = this.CardMoneyEmpIns.Text.Trim(); if (cardName == "") { Utility.Alert(this, "钱包名称未填写!"); return; } if (cardMoney != "") { if (!ValidHelper.CheckDouble(cardMoney)) { Utility.Alert(this, "余额填写错误!"); return; } } else { cardMoney = "0"; } CardInfo card = bll.GetCardByCardName(userId, cardName); card.CardName = cardName; card.MoneyStart = Convert.ToDecimal(cardMoney); card.UserID = userId; card.CardLive = 1; card.Synchronize = 1; card.CDID = bll.GetMaxCardId(userId); card.ModifyDate = DateTime.Now; if (card.CardID > 0 || cardName == "我的钱包") { Utility.Alert(this, "钱包已存在,不能重复添加!"); return; } bool success = bll.InsertCard(card); if (success) { Utility.Alert(this, "添加成功。", "UserCardAdmin.aspx"); } else { Utility.Alert(this, "添加失败!"); } }
//添加类别操作 protected void Button1_Click(object sender, EventArgs e) { string catTypeName = this.CatTypeNameEmpIns.Text.Trim(); string catTypePrice = this.CatTypePriceEmpIns.Text.Trim(); if (catTypeName == "") { Utility.Alert(this, "类别名称未填写!"); return; } if (catTypePrice != "") { if (!ValidHelper.CheckNumber(catTypePrice)) { Utility.Alert(this, "类别预算填写错误!"); return; } } else { catTypePrice = "0"; } UserCategoryInfo category = bll.GetUserCategoryByName(userId, catTypeName); category.CategoryTypeID = bll.GetMaxCategoryTypeId(userId); category.CategoryTypeName = catTypeName; category.CategoryTypePrice = Convert.ToInt32(catTypePrice); category.UserID = userId; category.CategoryTypeLive = 1; category.Synchronize = 1; category.ModifyDate = DateTime.Now; if (category.UserCategoryID > 0) { Utility.Alert(this, "类别已存在,不能重复添加!"); return; } bool success = bll.InsertUserCategory(category); if (success) { Utility.Alert(this, "添加成功。", "UserCategoryAdmin.aspx"); } else { Utility.Alert(this, "添加失败!"); } }
//类别更新操作 protected void CardList_RowUpdating(object sender, GridViewUpdateEventArgs e) { int cardId = Int32.Parse(CardList.DataKeys[e.RowIndex].Value.ToString()); TextBox cardNameBox = (TextBox)CardList.Rows[e.RowIndex].FindControl("CardNameBox"); string cardName = cardNameBox.Text.Trim(); if (cardName == "") { Utility.Alert(this, "名称未填写!"); return; } TextBox cardMoneyBox = (TextBox)CardList.Rows[e.RowIndex].FindControl("CardMoneyBox"); string cardMoney = cardMoneyBox.Text.Trim(); if (!ValidHelper.CheckDouble(cardMoney)) { Utility.Alert(this, "余额填写错误!"); return; } bool success = false; if (cardId == 0) { success = UserAccess.UpdateUserMoneyNew(userId, Double.Parse(cardMoney)); } else { CardEntity card = new CardEntity(); card.CardID = cardId; card.CardName = cardName; card.CardMoney = Double.Parse(cardMoney); card.UserID = userId; card.CardLive = 1; card.Synchronize = 1; success = CardAccess.UpdateCard(card); } if (success) { Utility.Alert(this, "更新成功。"); CardList.EditIndex = -1; BindGrid(); } else { Utility.Alert(this, "更新失败!"); } }
/// <summary> /// 权限扩展添加数据检测 /// </summary> /// <param name="form">数据表单</param> /// <param name="stateInfo">状态消息</param> /// <returns>执行结果</returns> private bool AddedByCheck(FormCollection form, out string stateInfo) { stateInfo = GeneralHandler.StateSuccess; string txtCode = form["txtCode"] as string; if ((txtCode.Length > 0 && !ValidHelper.EngIsEngAndNum(txtCode)) || txtCode.Length > 100) { stateInfo = "您输入的编码不正确!(只能由字母和数字组成,且不大于100个字)"; return(false); } string txtCodeName = form["txtCodeName"] as string; if (string.IsNullOrEmpty(txtCodeName) || txtCodeName.Length < 2 || txtCodeName.Length > 200) { stateInfo = "编码名称不能为空或小于2个或大于200个字符!"; return(false); } if (!ValidHelper.ChsIsChineseOrEngOrNum(txtCodeName)) { stateInfo = "您输入的编码名称不正确!(只能由汉字、字母、数字组成)"; return(false); } string txtMark = form["txtMark"] as string; if ((txtMark.Length > 0 && !ValidHelper.EngIsEngAndNum(txtMark)) || txtMark.Length > 100) { stateInfo = "您输入的标识不正确!(只能由字母和数字组成,且不大于100个字)"; return(false); } string txtMarkName = form["txtMarkName"] as string; if (string.IsNullOrEmpty(txtMarkName) || txtMarkName.Length < 2 || txtMarkName.Length > 200) { stateInfo = "标识名称不能为空或小于2个或大于200个字符!"; return(false); } if (!ValidHelper.ChsIsChineseOrEngOrNum(txtMarkName)) { stateInfo = "您输入的标识名称不正确!(只能由汉字、字母、数字组成)"; return(false); } string txtMemo = form["txtMemo"] as string; if ((txtMemo.Length > 0 && !ValidHelper.ChsIsMemos(txtMemo)) || txtMemo.Length > 500) { stateInfo = "您输入的扩展备注不正确!(只能由汉字、字母、数字组成,且不大于500个字)"; return(false); } return(true); }
//检查内容 private bool CheckSave() { string itemType = this.ItemTypeHid.Value; int catTypeId = Convert.ToInt32(this.CategoryTypeDown.SelectedValue); string itemName = this.ItemName.Text.Trim(); string itemPrice = this.ItemPrice.Text.Trim(); if (itemType == "") { Utility.Alert(this, "消费分类填写错误!"); return(false); } if (catTypeId == 0) { Utility.Alert(this, "商品类别填写错误!"); return(false); } if (itemName == "") { Utility.Alert(this, "商品名称填写错误!"); return(false); } if (!ValidHelper.CheckDouble(itemPrice)) { Utility.Alert(this, "商品价格填写错误!"); return(false); } if (this.RegionID.Checked) { if (!ValidHelper.CheckDate(this.ItemBuyDate1.Text.Trim()) || !ValidHelper.CheckDate(this.ItemBuyDate2.Text.Trim())) { Utility.Alert(this, "购买日期填写错误!"); return(false); } } else { if (!ValidHelper.CheckDate(this.ItemBuyDateHid.Value)) { Utility.Alert(this, "购买日期填写错误!"); return(false); } } return(true); }
//绑定已有帐号 protected void BoundButton_Click(object sender, EventArgs e) { string userName = this.UserNameBound.Text.Trim(); string userPassword = this.UserPasswordBound.Text.Trim(); if (!ValidHelper.CheckLength(userName, 2)) { Utility.Alert(this, "用户名填写错误!"); return; } if (!ValidHelper.CheckLength(userPassword, 2)) { Utility.Alert(this, "密码填写错误!"); return; } bool success = user_bll.UserLogin(userName, userPassword); if (!success) { Utility.Alert(this, "登录失败!"); return; } UserInfo user = user_bll.GetUserByUserPassword(userName, userPassword); using (TransactionScope ts = new TransactionScope()) { success = bll.OAuthBoundOldUser(userId, user.UserID); bool succ = item_bll.UpdateItemToUser(userId, user.UserID); ts.Complete(); } if (success) { UserHelper.SaveSession(user); Response.Cookies["ThemeCookie"].Value = user.UserTheme; Response.Cookies["ThemeCookie"].Expires = DateTime.MaxValue; Utility.Alert(this, "绑定成功。", "UserBoundAdmin.aspx"); } else { Utility.Alert(this, "绑定失败!"); } }
protected void Page_Load(object sender, EventArgs e) { userId = Int32.Parse(Session["UserID"].ToString()); catTypeList = UserCategoryAccess.GetCategoryTypeList(userId); itemTypeList = ItemAccess.GetItemListType(); cardList = CardAccess.GetCardList(userId); if (Request.QueryString["date"] != null && Request.QueryString["date"] != "") { if (!ValidHelper.CheckDate(Request.QueryString["date"])) { Session["TodayDate"] = DateTime.Now.ToString("yyyy-MM-dd"); } else { Session["TodayDate"] = Request.QueryString["date"]; } } today = Session["TodayDate"].ToString(); if (!IsPostBack) { BindGrid(); this.CatTypeEmpIns.DataSource = catTypeList; this.CatTypeEmpIns.DataTextField = "CategoryTypeName"; this.CatTypeEmpIns.DataValueField = "CategoryTypeID"; this.CatTypeEmpIns.DataBind(); if (Request.Cookies["CatTypeID"] != null) { this.CatTypeEmpIns.SelectedValue = Request.Cookies["CatTypeID"].Value; } this.ItemTypeEmpIns.DataSource = itemTypeList; this.ItemTypeEmpIns.DataTextField = "ItemTypeName"; this.ItemTypeEmpIns.DataValueField = "ItemTypeValue"; this.ItemTypeEmpIns.DataBind(); //钱包 this.CardEmpIns.DataSource = cardList; this.CardEmpIns.DataTextField = "CardName"; this.CardEmpIns.DataValueField = "CardID"; this.CardEmpIns.DataBind(); if (Request.Cookies["CardID"] != null) { this.CardEmpIns.SelectedValue = Request.Cookies["CardID"].Value; } } }
/// <summary> /// 反转Base64 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnToUnBase64_Click(object sender, EventArgs e) { string strVal = txtBase64Origin.Text.Trim(); if (!string.IsNullOrEmpty(strVal)) { this.txtBase64Value.Clear(); if (!ValidHelper.IsBase64String(strVal)) { this.txtBase64Value.Text = "错误的[Base64]原数据!"; return; } this.txtBase64Value.Text = TypeHelper.ToBase64Decode(txtBase64Origin.Text.Trim()); } }
/// <summary> /// 字符串验证 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnString_Click(object sender, EventArgs e) { string strValue = this.cboxString.SelectedItem as string; bool checkFlag = false; switch (strValue) { case "用户密码": checkFlag = ValidHelper.EngIsPassword(this.txtString.Text); break; case "用户密码2": checkFlag = ValidHelper.EngIsPasswords(this.txtString.Text); break; case "注册帐号": checkFlag = ValidHelper.EngIsRegister(this.txtString.Text); break; case "26个字母": checkFlag = ValidHelper.EngIsEnglish(this.txtString.Text); break; case "大写字母": checkFlag = ValidHelper.EngIsUppercase(this.txtString.Text); break; case "小写字母": checkFlag = ValidHelper.EngIsLowercase(this.txtString.Text); break; case "字母数字": checkFlag = ValidHelper.EngIsEngAndNum(this.txtString.Text); break; case "英头数字": checkFlag = ValidHelper.EngIsEngAndNums(this.txtString.Text); break; case "字数下线": checkFlag = ValidHelper.EngIsEngAndNumOrUnderline(this.txtString.Text); break; default: break; } this.lblResultString.Text = checkFlag.ToString(); }
/// <summary> /// 增加收件人信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnRecipients_Click(object sender, EventArgs e) { var _val = txtRecipients.Text.Trim(); if (ValidHelper.IsEmailValid(_val)) { lstRecipients.BeginUpdate(); lstRecipients.Items.Add(_val); lstRecipients.EndUpdate(); //MessageBox.Show(string.Format("对不起!收件人数量已达到最大设定值【{0}】。", FMailMessage.MaxRecipientNum), "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show(ValidError.IsEmailValid, "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
/// <summary> /// 增加收件人信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnRecipients_Click(object sender, EventArgs e) { var _val = txtRecipients.Text.Trim(); if (ValidHelper.IsEmailValid(_val)) { lstRecipients.BeginUpdate(); lstRecipients.Items.Add(_val); lstRecipients.EndUpdate(); //MsgBox.Show($"对不起!收件人数量已达到最大设定值【{FMailMessage.MaxRecipientNum}】。"); } else { MsgBox.Show(ValidError.IsEmailValid); } }