示例#1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public int Update(Model.Employee_Model model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Stale_Employee set ");
            strSql.Append("EmpName=@EmpName,");
            strSql.Append("Sex=@Sex,");
            strSql.Append("EntryTime=@EntryTime,");
            strSql.Append("DepartID=@DepartID,");
            strSql.Append("Job=@Job,");
            strSql.Append("Mobile=@Mobile,");
            strSql.Append("OfficePhone=@OfficePhone,");
            strSql.Append("Status=@Status,");
            strSql.Append("Remark=@Remark");
            strSql.Append(" where ID=@ID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID",          SqlDbType.Int,        4),
                new SqlParameter("@EmpName",     SqlDbType.NVarChar,  50),
                new SqlParameter("@Sex",         SqlDbType.NChar,      2),
                new SqlParameter("@EntryTime",   SqlDbType.DateTime),
                new SqlParameter("@DepartID",    SqlDbType.Int),
                new SqlParameter("@Job",         SqlDbType.NVarChar,  50),
                new SqlParameter("@Mobile",      SqlDbType.NVarChar,  50),
                new SqlParameter("@OfficePhone", SqlDbType.NVarChar,  50),
                new SqlParameter("@Status",      SqlDbType.NVarChar,  50),
                new SqlParameter("@Remark",      SqlDbType.NVarChar, 200)
            };
            parameters[0].Value = model.ID;
            parameters[1].Value = model.EmpName;
            parameters[2].Value = model.Sex;
            parameters[3].Value = model.EntryTime;
            parameters[4].Value = model.DepartID;
            parameters[5].Value = model.Job;
            parameters[6].Value = model.Mobile;
            parameters[7].Value = model.OfficePhone;
            parameters[8].Value = model.Status;
            parameters[9].Value = model.Remark;

            if (DbHelperSQL.ExecuteCommand(strSql.ToString(), parameters) > 0)
            {
                return(1);
            }
            return(0);
        }
示例#2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.Employee_Model GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,EmpName,Sex,EntryTime,DepartID,Job,Mobile,OfficePhone,Status,Remark from Stale_Employee ");
            strSql.Append(" where ID=@ID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ID;

            Model.Employee_Model model = new Model.Employee_Model();
            DataTable            dt    = DbHelperSQL.GetDateSet(strSql.ToString(), parameters);

            if (dt.Rows.Count > 0)
            {
                if (dt.Rows[0]["ID"].ToString() != "")
                {
                    model.ID = int.Parse(dt.Rows[0]["ID"].ToString());
                }
                model.EmpName = dt.Rows[0]["EmpName"].ToString();
                model.Sex     = dt.Rows[0]["Sex"].ToString();
                if (dt.Rows[0]["EntryTime"].ToString() != "")
                {
                    model.EntryTime = DateTime.Parse(dt.Rows[0]["EntryTime"].ToString());
                }
                model.DepartID    = int.Parse(dt.Rows[0]["DepartID"].ToString());
                model.Job         = dt.Rows[0]["Job"].ToString();
                model.Mobile      = dt.Rows[0]["Mobile"].ToString();
                model.OfficePhone = dt.Rows[0]["OfficePhone"].ToString();
                model.Status      = dt.Rows[0]["Status"].ToString();
                model.Remark      = dt.Rows[0]["Remark"].ToString();
                return(model);
            }
            else
            {
                return(null);
            }
        }
示例#3
0
        //public IList<Model.Employee_Model> GetIList()
        //{
        //    //return;
        //}
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.Employee_Model model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Stale_Employee(");
            strSql.Append("EmpName,Sex,EntryTime,DepartID,Job,Mobile,OfficePhone,Status,Remark,Code)");
            strSql.Append(" values (");
            strSql.Append("@EmpName,@Sex,@EntryTime,@DepartID,@Job,@Mobile,@OfficePhone,@Status,@Remark,@Code)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@EmpName",     SqlDbType.NVarChar,   50),
                new SqlParameter("@Sex",         SqlDbType.NChar,       2),
                new SqlParameter("@EntryTime",   SqlDbType.DateTime),
                new SqlParameter("@DepartID",    SqlDbType.Int),
                new SqlParameter("@Job",         SqlDbType.NVarChar,   50),
                new SqlParameter("@Mobile",      SqlDbType.NVarChar,   50),
                new SqlParameter("@OfficePhone", SqlDbType.NVarChar,   50),
                new SqlParameter("@Status",      SqlDbType.NVarChar,   50),
                new SqlParameter("@Remark",      SqlDbType.NVarChar,  200),
                new SqlParameter("@Code",        SqlDbType.Int)
            };
            parameters[0].Value = model.EmpName;
            parameters[1].Value = model.Sex;
            parameters[2].Value = model.EntryTime;
            parameters[3].Value = model.DepartID;
            parameters[4].Value = model.Job;
            parameters[5].Value = model.Mobile;
            parameters[6].Value = model.OfficePhone;
            parameters[7].Value = model.Status;
            parameters[8].Value = model.Remark;
            parameters[9].Value = model.Code;

            if (DbHelperSQL.ExecuteCommand(strSql.ToString(), parameters) > 0)
            {
                return(1);
            }
            return(0);
        }
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public int Update(Model.Employee_Model model)
 {
     return(dal.Update(model));
 }
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(Model.Employee_Model model)
 {
     return(dal.Add(model));
 }