public DtCms.Model.TeamLeader QueryOneRecord(string Username) { DtCms.Model.TeamLeader teamleader; string cmdstr = "Select * From dt_TeamLeader Where UserName='******'"; SqlParameter[] SqlParam = new SqlParameter[1]; SqlParam[0] = new SqlParameter("@Username", Username); //获取SqlDataReader对象 SqlDataReader dataReader = DbHelperSQL.ExecuteReader(cmdstr, SqlParam); if (dataReader.Read()) { teamleader = new DtCms.Model.TeamLeader(); teamleader.Id = Convert.ToInt32(dataReader["Id"]); teamleader.Username = dataReader["Username"].ToString(); teamleader.Turename = dataReader["Turename"].ToString(); teamleader.Team = dataReader["Team"].ToString(); teamleader.LeaderTel = dataReader["LeaderTel"].ToString(); teamleader.StartTime = Convert.ToDateTime(dataReader["StartTime"]); teamleader.EndTime = Convert.ToDateTime(dataReader["EndTime"]); } else { teamleader = null; } dataReader.Close(); return(teamleader); }
/// <summary> /// 得到一个对象实体 /// </summary> public DtCms.Model.TeamLeader GetModel(int Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 Id,UserName,TureName,Team,Pwd,LeaderTel,StartTime,EndTime from dt_TeamLeader "); strSql.Append(" where Id='" + Id + "'"); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = Id; DtCms.Model.TeamLeader model = new DtCms.Model.TeamLeader(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["Id"].ToString() != "") { model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString()); } model.Username = ds.Tables[0].Rows[0]["UserName"].ToString(); model.Turename = ds.Tables[0].Rows[0]["TureName"].ToString(); model.Team = ds.Tables[0].Rows[0]["Team"].ToString(); model.Pwd = ds.Tables[0].Rows[0]["Pwd"].ToString(); model.StartTime = DateTime.Parse(ds.Tables[0].Rows[0]["StartTime"].ToString()); model.EndTime = DateTime.Parse(ds.Tables[0].Rows[0]["EndTime"].ToString()); return(model); } else { return(null); } }
public string GetAppName(string Username) { DtCms.Model.TeamLeader teacher = dal.QueryOneRecord(Username); if (teacher != null) { return(teacher.Turename); } return(null); //return (dal.QueryOneRecord(Username)).Turename; }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(DtCms.Model.TeamLeader model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update dt_LeaderTeam set "); strSql.Append("UserName=@UserName,"); strSql.Append("TureName=@TureName,"); strSql.Append("Team=@Team,"); strSql.Append("Pwd=@Pwd,"); strSql.Append("LeaderTel=@LeaderTel,"); strSql.Append("StartTime=@StartTime,"); strSql.Append("EndTime=@EndTime,"); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int), new SqlParameter("@UserName", SqlDbType.VarChar, 20), new SqlParameter("@TureName", SqlDbType.VarChar, 20), new SqlParameter("@Team", SqlDbType.VarChar, 20), new SqlParameter("@Pwd", SqlDbType.VarChar, 20), new SqlParameter("@LeaderTel", SqlDbType.NVarChar, 50), new SqlParameter("@StartTime", SqlDbType.DateTime), new SqlParameter("@EndTime", SqlDbType.DateTime) }; parameters[0].Value = model.Id; parameters[1].Value = model.Username; parameters[2].Value = model.Turename; parameters[3].Value = model.Team; parameters[4].Value = model.Pwd; parameters[5].Value = model.LeaderTel; parameters[6].Value = model.StartTime; parameters[7].Value = model.EndTime; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(DtCms.Model.TeamLeader model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into dt_TeamLeader("); strSql.Append("UserName,Pwd,TureName,Team,LeaderTel,SartTime,EndTime)"); strSql.Append(" values ("); strSql.Append("@UserName,@Pwd,@TureName,@Team,@LeaderTel,@StartTime,@EndTime)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@UserName", SqlDbType.VarChar, 20), new SqlParameter("@TureName", SqlDbType.VarChar, 20), new SqlParameter("@Team", SqlDbType.VarChar, 20), new SqlParameter("@Pwd", SqlDbType.VarChar, 20), new SqlParameter("@LeaderTel", SqlDbType.NVarChar, 50), new SqlParameter("@StartTime", SqlDbType.DateTime), new SqlParameter("@EndTime", SqlDbType.DateTime) }; parameters[0].Value = model.Username; parameters[1].Value = model.Turename; parameters[2].Value = model.Team; parameters[3].Value = model.Pwd; parameters[4].Value = model.LeaderTel; parameters[5].Value = model.StartTime; parameters[6].Value = model.EndTime; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
protected void btnSubmit_Click(object sender, EventArgs e) { string Code = txtCode.Text.Trim(); string UserName = txtUserName.Text.Trim(); string pwd = txtpwd.Text.Trim(); if (Code.ToLower() != (Session["DtCode"].ToString()).ToLower()) { Response.Write("<script>alert('您输入的验证码与系统的不一致!');</script>"); return; } if (string.IsNullOrEmpty(UserName)) { Response.Write("<script>alert('请输入会员名!');</script>"); return; } if (string.IsNullOrEmpty(pwd)) { Response.Write("<script>alert('请输入密码!');</script>"); return; } // if (RadioButtonListRole.SelectedValue == "管理员") //{ // DtCms.Model.Administrator administrator = new DtCms.Model.Administrator(); // administrator.UserName = UserName; // administrator.UserPwd = pwd; // DtCms.BLL.Administrator bll = new DtCms.BLL.Administrator(); // if (bll.chkAdminLogin(UserName, DESEncrypt.Encrypt(pwd))) //{ // Session["Administrator"] = UserName; // Response.Write("<script>alert('登录成功!')</script>"); // Response.Redirect("~/Admin/Admin_Index.aspx"); // } // else if (bll.GetCount(" Username='******' and UserPwd='" + pwd + "' ") == 0) // { // Response.Write("<script>alert('登录失败,管理员名名或密码输入错误!');</script>"); // } // } if (RadioButtonListRole.SelectedValue == "学生") { DtCms.Model.Member member = new DtCms.Model.Member(); member.Username = UserName; member.Pwd = pwd; DtCms.BLL.Member bll = new DtCms.BLL.Member(); if (bll.GetCount(" Username='******' and Pwd='" + pwd + "' ") > 0) { Session["Member"] = UserName; Response.Write("<script>alert('登录成功!');window.location.href='index.aspx'</script>"); } else { Response.Write("<script>alert('登录失败,用户名或密码输入错误!');</script>"); } } if (RadioButtonListRole.SelectedValue == "队长") { DtCms.Model.TeamLeader teamleader = new DtCms.Model.TeamLeader(); teamleader.Username = UserName; teamleader.Pwd = pwd; DtCms.BLL.TeamLeader bll = new DtCms.BLL.TeamLeader(); if (bll.GetCount(" Username='******' and Pwd='" + pwd + "' ") > 0) { Session["TeamLeader"] = UserName; Response.Write("<script>alert('登录成功!');window.location.href='Tindex.aspx'</script>"); } else { Response.Write("<script>alert('登录失败,用户名或密码输入错误!');</script>"); } } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(DtCms.Model.TeamLeader model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(DtCms.Model.TeamLeader model) { return(dal.Add(model)); }