Ejemplo n.º 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(DriveMgr.Model.RegistrationModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tb_Students set ");
            strSql.Append("StudentsName=@StudentsName,");
            strSql.Append("Sex=@Sex,");
            strSql.Append("Age=@Age,");
            strSql.Append("IsLocal=@IsLocal,");
            strSql.Append("PhoneNum=@PhoneNum,");
            strSql.Append("PeriodsID=@PeriodsID,");
            strSql.Append("CardNum=@CardNum,");
            strSql.Append("Address=@Address,");
            strSql.Append("Remark=@Remark,");
            strSql.Append("Operater=@Operater");
            strSql.Append(" where ID=@ID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@StudentsName", SqlDbType.VarChar,  20),
                new SqlParameter("@Sex",          SqlDbType.Bit,       1),
                new SqlParameter("@Age",          SqlDbType.Int,       4),
                new SqlParameter("@IsLocal",      SqlDbType.Bit,       1),
                new SqlParameter("@PhoneNum",     SqlDbType.VarChar,  50),
                new SqlParameter("@PeriodsID",    SqlDbType.Int,       4),
                new SqlParameter("@CardNum",      SqlDbType.VarChar,  20),
                new SqlParameter("@Address",      SqlDbType.VarChar, 200),
                new SqlParameter("@Remark",       SqlDbType.VarChar, 500),
                new SqlParameter("@Operater",     SqlDbType.VarChar,  50),
                new SqlParameter("@ID",           SqlDbType.BigInt, 8)
            };
            parameters[0].Value  = model.StudentsName;
            parameters[1].Value  = model.Sex;
            parameters[2].Value  = model.Age;
            parameters[3].Value  = model.IsLocal;
            parameters[4].Value  = model.PhoneNum; //手机号码
            parameters[5].Value  = model.PeriodsID;
            parameters[6].Value  = model.CardNum;
            parameters[7].Value  = model.Address;
            parameters[8].Value  = model.Remark;
            parameters[9].Value  = model.Operater;
            parameters[10].Value = model.ID;

            int rows = DriveMgr.Common.SqlHelper.ExecuteNonQuery(DriveMgr.Common.SqlHelper.connStrDriveData, CommandType.Text, strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(DriveMgr.Model.RegistrationModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tb_Students(");
            strSql.Append("StudentsName,StudentCode,Sex,Age,IsLocal,PhoneNum,PeriodsID,CardNum,Address,PicPath,Remark,Status,Operater)");
            strSql.Append(" values (");
            strSql.Append("@StudentsName,@StudentCode,@Sex,@Age,@IsLocal,@PhoneNum,@PeriodsID,@CardNum,@Address,@PicPath,@Remark,@Status,@Operater)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@StudentsName", SqlDbType.VarChar,  20),
                new SqlParameter("@StudentCode",  SqlDbType.VarChar,  20),
                new SqlParameter("@Sex",          SqlDbType.Bit,       1),
                new SqlParameter("@Age",          SqlDbType.Int,       4),
                new SqlParameter("@IsLocal",      SqlDbType.Bit,       1),
                new SqlParameter("@PhoneNum",     SqlDbType.VarChar,  50),
                new SqlParameter("@PeriodsID",    SqlDbType.Int,       4),
                new SqlParameter("@CardNum",      SqlDbType.VarChar,  20),
                new SqlParameter("@Address",      SqlDbType.VarChar, 200),
                new SqlParameter("@PicPath",      SqlDbType.VarChar, 200),
                new SqlParameter("@Remark",       SqlDbType.VarChar, 500),
                new SqlParameter("@Status",       SqlDbType.Int,       4),
                new SqlParameter("@Operater",     SqlDbType.VarChar, 50)
            };
            parameters[0].Value  = model.StudentsName;
            parameters[1].Value  = model.StudentCode;
            parameters[2].Value  = model.Sex;
            parameters[3].Value  = model.Age;
            parameters[4].Value  = model.IsLocal;
            parameters[5].Value  = model.PhoneNum; //手机号码
            parameters[6].Value  = model.PeriodsID;
            parameters[7].Value  = model.CardNum;
            parameters[8].Value  = model.Address;
            parameters[9].Value  = model.PicPath;
            parameters[10].Value = model.Remark;
            parameters[11].Value = model.Status;
            parameters[12].Value = model.Operater;

            int rows = Convert.ToInt32(DriveMgr.Common.SqlHelper.ExecuteNonQuery(DriveMgr.Common.SqlHelper.connStrDriveData, CommandType.Text, strSql.ToString(), parameters));

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public DriveMgr.Model.RegistrationModel GetModel(long stuId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,StudentsName,StudentCode,Sex,Age,PhoneNum,IsLocal,PeriodsID,CardNum,Address,PicPath,Remark,Status,Operater,flag from tb_Students ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.BigInt)
            };
            parameters[0].Value = stuId;

            DriveMgr.Model.RegistrationModel model = new DriveMgr.Model.RegistrationModel();
            DataTable dt = DriveMgr.Common.SqlHelper.GetDataTable(DriveMgr.Common.SqlHelper.connStrDriveData, CommandType.Text, strSql.ToString(), parameters);

            if (dt.Rows.Count > 0)
            {
                if (dt.Rows[0]["ID"] != null && dt.Rows[0]["ID"].ToString() != "")
                {
                    model.ID = long.Parse(dt.Rows[0]["ID"].ToString());
                }
                if (dt.Rows[0]["StudentsName"] != null && dt.Rows[0]["StudentsName"].ToString() != "")
                {
                    model.StudentsName = dt.Rows[0]["StudentsName"].ToString();
                }
                if (dt.Rows[0]["StudentCode"] != null && dt.Rows[0]["StudentCode"].ToString() != "")
                {
                    model.StudentCode = dt.Rows[0]["StudentCode"].ToString();
                }
                if (dt.Rows[0]["Sex"] != null && dt.Rows[0]["Sex"].ToString() != "")
                {
                    if ((dt.Rows[0]["Sex"].ToString() == "1") || (dt.Rows[0]["Sex"].ToString().ToLower() == "true"))
                    {
                        model.Sex = true;
                    }
                    else
                    {
                        model.Sex = false;
                    }
                }
                if (dt.Rows[0]["Age"] != null && dt.Rows[0]["Age"].ToString() != "")
                {
                    model.Age = int.Parse(dt.Rows[0]["Age"].ToString());
                }
                if (dt.Rows[0]["PhoneNum"] != null && dt.Rows[0]["PhoneNum"].ToString() != "")
                {
                    model.PhoneNum = dt.Rows[0]["PhoneNum"].ToString();
                }
                if (dt.Rows[0]["IsLocal"] != null && dt.Rows[0]["IsLocal"].ToString() != "")
                {
                    if ((dt.Rows[0]["IsLocal"].ToString() == "1") || (dt.Rows[0]["IsLocal"].ToString().ToLower() == "true"))
                    {
                        model.IsLocal = true;
                    }
                    else
                    {
                        model.IsLocal = false;
                    }
                }
                if (dt.Rows[0]["PeriodsID"] != null && dt.Rows[0]["PeriodsID"].ToString() != "")
                {
                    model.PeriodsID = int.Parse(dt.Rows[0]["PeriodsID"].ToString());
                }
                if (dt.Rows[0]["CardNum"] != null && dt.Rows[0]["CardNum"].ToString() != "")
                {
                    model.CardNum = dt.Rows[0]["CardNum"].ToString();
                }
                if (dt.Rows[0]["Address"] != null && dt.Rows[0]["Address"].ToString() != "")
                {
                    model.Address = dt.Rows[0]["Address"].ToString();
                }
                if (dt.Rows[0]["PicPath"] != null && dt.Rows[0]["PicPath"].ToString() != "")
                {
                    model.PicPath = dt.Rows[0]["PicPath"].ToString();
                }
                if (dt.Rows[0]["Remark"] != null && dt.Rows[0]["Remark"].ToString() != "")
                {
                    model.Remark = dt.Rows[0]["Remark"].ToString();
                }
                if (dt.Rows[0]["Status"] != null && dt.Rows[0]["Status"].ToString() != "")
                {
                    model.Status = int.Parse(dt.Rows[0]["Status"].ToString());
                }
                if (dt.Rows[0]["Operater"] != null && dt.Rows[0]["Operater"].ToString() != "")
                {
                    model.Operater = dt.Rows[0]["Operater"].ToString();
                }
                if (dt.Rows[0]["flag"] != null && dt.Rows[0]["flag"].ToString() != "")
                {
                    model.flag = int.Parse(dt.Rows[0]["flag"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <DriveMgr.Model.RegistrationModel> DataTableToList(DataTable dt)
        {
            List <DriveMgr.Model.RegistrationModel> modelList = new List <DriveMgr.Model.RegistrationModel>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                DriveMgr.Model.RegistrationModel model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new DriveMgr.Model.RegistrationModel();
                    if (dt.Rows[n]["ID"] != null && dt.Rows[n]["ID"].ToString() != "")
                    {
                        model.ID = long.Parse(dt.Rows[n]["ID"].ToString());
                    }
                    if (dt.Rows[n]["StudentsName"] != null && dt.Rows[n]["StudentsName"].ToString() != "")
                    {
                        model.StudentsName = dt.Rows[n]["StudentsName"].ToString();
                    }
                    if (dt.Rows[n]["StudentCode"] != null && dt.Rows[n]["StudentCode"].ToString() != "")
                    {
                        model.StudentCode = dt.Rows[n]["StudentCode"].ToString();
                    }
                    if (dt.Rows[n]["Sex"] != null && dt.Rows[n]["Sex"].ToString() != "")
                    {
                        if ((dt.Rows[n]["Sex"].ToString() == "1") || (dt.Rows[n]["Sex"].ToString().ToLower() == "true"))
                        {
                            model.Sex = true;
                        }
                        else
                        {
                            model.Sex = false;
                        }
                    }
                    if (dt.Rows[n]["Age"] != null && dt.Rows[n]["Age"].ToString() != "")
                    {
                        model.Age = int.Parse(dt.Rows[n]["Age"].ToString());
                    }
                    if (dt.Rows[n]["IsLocal"] != null && dt.Rows[n]["IsLocal"].ToString() != "")
                    {
                        if ((dt.Rows[n]["IsLocal"].ToString() == "1") || (dt.Rows[n]["IsLocal"].ToString().ToLower() == "true"))
                        {
                            model.IsLocal = true;
                        }
                        else
                        {
                            model.IsLocal = false;
                        }
                    }
                    if (dt.Rows[n]["PeriodsID"] != null && dt.Rows[n]["PeriodsID"].ToString() != "")
                    {
                        model.PeriodsID = int.Parse(dt.Rows[n]["PeriodsID"].ToString());
                    }
                    if (dt.Rows[n]["CardNum"] != null && dt.Rows[n]["CardNum"].ToString() != "")
                    {
                        model.CardNum = dt.Rows[n]["CardNum"].ToString();
                    }
                    if (dt.Rows[n]["Address"] != null && dt.Rows[n]["Address"].ToString() != "")
                    {
                        model.Address = dt.Rows[n]["Address"].ToString();
                    }
                    if (dt.Rows[n]["Remark"] != null && dt.Rows[n]["Remark"].ToString() != "")
                    {
                        model.Remark = dt.Rows[n]["Remark"].ToString();
                    }
                    if (dt.Rows[n]["Status"] != null && dt.Rows[n]["Status"].ToString() != "")
                    {
                        model.Status = int.Parse(dt.Rows[n]["Status"].ToString());
                    }
                    if (dt.Rows[n]["Operater"] != null && dt.Rows[n]["Operater"].ToString() != "")
                    {
                        model.Operater = dt.Rows[n]["Operater"].ToString();
                    }
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(DriveMgr.Model.RegistrationModel model)
 {
     return(dal.Update(model));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(DriveMgr.Model.RegistrationModel model)
 {
     return(dal.Add(model));
 }