ADO.NET面向对象增添程序
2021-06-29 18:05
标签:convert trim word else white text ring ati 错误 Console.BackgroundColor = ConsoleColor.White; while (true) if (u == "1") while (true) if (uuu.PassWord.Trim().Length > 4 && uuu.PassWord == PassWord2) break; while (true) while (true) while (true) while (true) UsersData udd = new UsersData(); Console.ReadKey(); //类 public string NewUcode() cmd.CommandText = "select *from Users Order by Ucode desc"; string code = dr["Ucode"].ToString(); conn.Close(); cmd.CommandText = "insert into Users values(@a,@b,@c,@d,@e,@f,@g)"; ADO.NET面向对象增添程序 标签:convert trim word else white text ring ati 错误 原文地址:http://www.cnblogs.com/yujiamin123/p/7140993.html
Console.ForegroundColor = ConsoleColor.Black;
while (true)
{
Console.Clear();
new Test1().DataLook();
{
Console.WriteLine();
Console.WriteLine();
Console.Write("请输入你要执行的操作(添加:1,修改:2,删除:3):");
string u = Console.ReadLine();
{
Users uuu = new Users();
uuu.Ucode = new UsersData().NewUcode();
Console.WriteLine("编号为:" + uuu.Ucode);
while (true)
{
Console.Write("请输入用户名:");
uuu.UserName = Console.ReadLine();
if (uuu.UserName.Trim().Length > 0) { break; }
else { Console.WriteLine("用户名不符合规定!"); }
}
{
Console.Write("请输入密码:");
uuu.PassWord = Console.ReadLine();
Console.Write("请再次输入新的密码:");
string PassWord2 = Console.ReadLine();
{
}
else
{ Console.WriteLine("密码不符合规定!");
}
}
{
Console.Write("请输入昵称:");
uuu.NickName = Console.ReadLine();
if (uuu.NickName.Trim().Length > 0) { break; }
else { Console.WriteLine("昵称不符合规定!"); }
}
{
Console.Write("请输入性别(男/女):");
string ssex = Console.ReadLine();
if (ssex != "男" && ssex != "女")
{
Console.WriteLine("性别输入有误!");
}
else
{
uuu.Sex = ssex == "男" ? true : false;
break;
}
}
{
Console.Write("请输入生日(2000-1-1):");
string bir = Console.ReadLine();
try
{
uuu.Birthday = Convert.ToDateTime(bir);
break;
}
catch
{
Console.WriteLine("日期输入错误!");
}
}
{
Console.Write("请输入你的民族(如:汉族/藏族):");
string nat = Console.ReadLine();
string snn = new UserNationData().SelectNationCode(nat);
if (snn == "null")
{
Console.WriteLine("查无此民族!");
}
else
{
uuu.Nation = snn;
break;
}
}
bool ok = udd.InsertUser(uuu);
if (ok)
{
Console.WriteLine("添加成功!");
}
else
{
Console.WriteLine("添加失败!");
}
break;
}
{
string s = "生成失败!";
conn.Open();
SqlDataReader dr = cmd.ExecuteReader();
if (dr.HasRows)
{
dr.Read();
int a = Convert.ToInt32(code.Substring(1));
a++;
s = "U" + a.ToString("000");
}
return s;
}
public bool InsertUser(Users u)
{
bool ok = false;
cmd.Parameters.Clear();
cmd.Parameters.Add("@a", u.Ucode);
cmd.Parameters.Add("@b", u.UserName);
cmd.Parameters.Add("@c", u.PassWord);
cmd.Parameters.Add("@d", u.NickName);
cmd.Parameters.Add("@e", u.Sex);
cmd.Parameters.Add("@f", u.Birthday);
cmd.Parameters.Add("@g", u.Nation);
conn.Open();
int count = cmd.ExecuteNonQuery();
if (count > 0)
{
ok = true;
}
conn.Close();
return ok;
}
上一篇:hibernate流程图