当前位置: 首页 > news >正文

电商排行榜10强太原seo网站管理

电商排行榜10强,太原seo网站管理,wordpress 网格主题,开封旅游网站建设方案策划书非常简单,直接给出代码: 数据库操作类 这个无需多言就是简单的包含了数据操作的内容,允许你在这一个类中写完关于本地数据库或者云数据库操作的逻辑,与登录逻辑分开哦。 注意,如果你的软件要给别人运行使用&#xf…

非常简单,直接给出代码:

数据库操作类

这个无需多言就是简单的包含了数据操作的内容,允许你在这一个类中写完关于本地数据库或者云数据库操作的逻辑,与登录逻辑分开哦。

注意,如果你的软件要给别人运行使用,你的数据库信息也可以存在授权文件中,以避免出现信息的泄露。如果你使用软件直接操作数据库可能存在危险,请注意连接数据库时对sql语句的检查。

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;namespace chuankouzhushou1
{internal class dataoperator{private static string connString = @"Data Source=DREAMER;Database=db_Mydb;User ID=sa;Pwd=yourpasswd;";public static SqlConnection connection = new SqlConnection(connString);public int ExecuteSQL(string sql){SqlCommand cmd = new SqlCommand(sql, connection);if (connection.State == ConnectionState.Closed)connection.Open();int num = Convert.ToInt32(cmd.ExecuteScalar());        //执行查询connection.Close();return num;}public int ExecuteSQLResult(string sql){SqlCommand cmd = new SqlCommand(sql, connection);if (connection.State == ConnectionState.Closed)connection.Open();int result = cmd.ExecuteNonQuery();connection.Close();return result;}public DataSet GetDataSet(string sql){SqlDataAdapter sqlda = new SqlDataAdapter(sql, connection);    //指定要执行的SQL语句DataSet ds = new DataSet();sqlda.Fill(ds);return ds;}public SqlDataReader GetDataReader(string sql){SqlCommand cmd = new SqlCommand(sql, connection);if (connection.State == ConnectionState.Closed)connection.Open();SqlDataReader dataReader = cmd.ExecuteReader();//添加参数CommandBehavior.CloseConnection就可以自动释放连接return dataReader;}}
}

输入的监测 

 private bool ValidateInput(){if (tx_ID.Text.Trim() == "")                            //登录账号{MessageBox.Show("请输入登录账号", "登录提示", MessageBoxButtons.OK, MessageBoxIcon.Information);tx_ID.Focus();                                    //使登录账号文本框获得鼠标焦点return false;}else if (tx_ID.Text.Length>30){MessageBox.Show("请输入正确的登录账号", "登录提示", MessageBoxButtons.OK, MessageBoxIcon.Information);tx_ID.Focus();                                    //使登录账号文本框获得鼠标焦点return false;}else if (tx_ID.Text.Length > 5 && tx_PWD.Text.Trim() == "")   //密码{MessageBox.Show("请输入密码", "登录提示", MessageBoxButtons.OK, MessageBoxIcon.Information);tx_PWD.Focus();                                    //使密码文本框获得鼠标焦点return false;}return true;}

 登录按钮(回车实现登录)

private void loginbtn(object sender, EventArgs e){if(ValidateInput()){int num= 0;string sql = "select count(*) from usertb where userid=" + int.Parse(tx_ID.Text.Trim()) + " and userpwd = '" + tx_PWD.Text.Trim() + "'";try{num = dbop.ExecuteSQL(sql);}catch {//MessageBox.Show(e.ToString());}   if (num == 1)//验证通过{publicinfo.userid = int.Parse(tx_ID.Text.Trim());// 执行新的SQL查询来获取userid,username和userlvsql = "select userid, username, userlv from usertb where userid=" + publicinfo.userid;SqlDataReader reader = dbop.GetDataReader(sql);if (reader.Read()){publicinfo.userid = reader.GetInt32(0);publicinfo.username = reader.GetString(1);publicinfo.userlv = reader.GetInt32(2);}reader.Close();mainfrm frm_Main = new mainfrm();frm_Main.Show();this.Visible = false;}else{MessageBox.Show("登录失败!", "登录提示", MessageBoxButtons.OK, MessageBoxIcon.Information);}}}private void tx_ID_KeyPress(object sender, KeyPressEventArgs e){if (char.IsDigit(e.KeyChar) || (e.KeyChar == '\r') || (e.KeyChar == '\b'))e.Handled = false;elsee.Handled = true;}

http://www.hkea.cn/news/802340/

相关文章:

  • 个体营业执照可以做网站搞推广吗推广网站制作
  • 公共交通公司网站建设方案移动慧生活app下载
  • 国内开源代码网站搜了网推广效果怎么样
  • html5 metro风格网站模板今日新闻事件
  • 网站不在首页显示出来做网络推广
  • 上海网站seo公司网页推广平台
  • 网站服务器租用价格表百度怎么发布自己的广告
  • 经纪人做网站技巧搜索引擎入口yandex
  • 教育网站制作哪家服务好全球外贸采购网
  • 响应式网络网站源码百度关键词查询网站
  • 南京网站制作设计公司网络运营团队
  • 阿里巴巴上怎样做自己的网站seo网站优化网站编辑招聘
  • 网站做付费推广都需要问什么网络热词2022
  • 给男票做网站表白的软件产品市场推广计划书
  • 西安网站制作定制怎么制作自己的个人网站
  • wordpress 如何移动端盐城seo优化
  • asp.net 制作网站开发百度竞价排名软件
  • 百度爱采购推广平台天津网络推广seo
  • 福州市闽侯县建设局网站推广引流吸引人的文案
  • wordpress目录 读写权限泰安短视频seo
  • 东莞建设网站流程澎湃新闻
  • 萧县住房和城乡建设局网站seo排名推广工具
  • 企业网站php模板下载百度百科官网首页
  • 做愛視頻网站在线网页制作网站
  • 织梦pc怎么做手机网站搜索引擎优化的基础是什么
  • 课程建设网站设计源码爱站网反链查询
  • 安徽省建设业协会网站个人网页制作教程
  • 好的摄影网站推荐福州seo顾问
  • html做的好看的网站如何宣传推广产品
  • 微信手机网站制作怎么引流客源最好的方法