Esempio n. 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public int Update(Model.Left_Model model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Stale_Left set ");
            strSql.Append("EID=@EID,");
            strSql.Append("EmpName=@EmpName,");
            strSql.Append("Sex=@Sex,");
            strSql.Append("DepartName=@DepartName,");
            strSql.Append("LeftTime=@LeftTime,");
            strSql.Append("LeftType=@LeftType,");
            strSql.Append("LeftReason=@LeftReason,");
            strSql.Append("ApprovalPerson=@ApprovalPerson,");
            strSql.Append("ApprovalDempart=@ApprovalDempart,");
            strSql.Append("Remark=@Remark");
            strSql.Append(" where ID=@ID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID",              SqlDbType.Int,         4),
                new SqlParameter("@EID",             SqlDbType.Int,         4),
                new SqlParameter("@EmpName",         SqlDbType.NVarChar,   50),
                new SqlParameter("@Sex",             SqlDbType.NChar,       2),
                new SqlParameter("@DepartName",      SqlDbType.NVarChar,   50),
                new SqlParameter("@LeftTime",        SqlDbType.DateTime),
                new SqlParameter("@LeftType",        SqlDbType.NVarChar,   50),
                new SqlParameter("@LeftReason",      SqlDbType.NVarChar,  200),
                new SqlParameter("@ApprovalPerson",  SqlDbType.NVarChar,   50),
                new SqlParameter("@ApprovalDempart", SqlDbType.NVarChar,   50),
                new SqlParameter("@Remark",          SqlDbType.NVarChar, 200)
            };
            parameters[0].Value  = model.ID;
            parameters[1].Value  = model.EID;
            parameters[2].Value  = model.EmpName;
            parameters[3].Value  = model.Sex;
            parameters[4].Value  = model.DepartName;
            parameters[5].Value  = model.LeftTime;
            parameters[6].Value  = model.LeftType;
            parameters[7].Value  = model.LeftReason;
            parameters[8].Value  = model.ApprovalPerson;
            parameters[9].Value  = model.ApprovalDempart;
            parameters[10].Value = model.Remark;

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

            strSql.Append("select  top 1 ID,EID,EmpName,Sex,DepartName,LeftTime,LeftType,LeftReason,ApprovalPerson,ApprovalDempart,Remark from Stale_Left ");
            strSql.Append(" where ID=@ID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ID;

            Model.Left_Model model = new Model.Left_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());
                }
                if (dt.Rows[0]["EID"].ToString() != "")
                {
                    model.EID = int.Parse(dt.Rows[0]["EID"].ToString());
                }
                model.EmpName    = dt.Rows[0]["EmpName"].ToString();
                model.Sex        = dt.Rows[0]["Sex"].ToString();
                model.DepartName = dt.Rows[0]["DepartName"].ToString();
                if (dt.Rows[0]["LeftTime"].ToString() != "")
                {
                    model.LeftTime = DateTime.Parse(dt.Rows[0]["LeftTime"].ToString());
                }
                model.LeftType        = dt.Rows[0]["LeftType"].ToString();
                model.LeftReason      = dt.Rows[0]["LeftReason"].ToString();
                model.ApprovalPerson  = dt.Rows[0]["ApprovalPerson"].ToString();
                model.ApprovalDempart = dt.Rows[0]["ApprovalDempart"].ToString();
                model.Remark          = dt.Rows[0]["Remark"].ToString();
                return(model);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.Left_Model model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Stale_Left(");
            strSql.Append("EID,EmpName,Sex,DepartName,LeftTime,LeftType,LeftReason,ApprovalPerson,ApprovalDempart,Remark)");
            strSql.Append(" values (");
            strSql.Append("@EID,@EmpName,@Sex,@DepartName,@LeftTime,@LeftType,@LeftReason,@ApprovalPerson,@ApprovalDempart,@Remark)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@EID",             SqlDbType.Int,         4),
                new SqlParameter("@EmpName",         SqlDbType.NVarChar,   50),
                new SqlParameter("@Sex",             SqlDbType.NChar,       2),
                new SqlParameter("@DepartName",      SqlDbType.NVarChar,   50),
                new SqlParameter("@LeftTime",        SqlDbType.DateTime),
                new SqlParameter("@LeftType",        SqlDbType.NVarChar,   50),
                new SqlParameter("@LeftReason",      SqlDbType.NVarChar,  200),
                new SqlParameter("@ApprovalPerson",  SqlDbType.NVarChar,   50),
                new SqlParameter("@ApprovalDempart", SqlDbType.NVarChar,   50),
                new SqlParameter("@Remark",          SqlDbType.NVarChar, 200)
            };
            parameters[0].Value = model.EID;
            parameters[1].Value = model.EmpName;
            parameters[2].Value = model.Sex;
            parameters[3].Value = model.DepartName;
            parameters[4].Value = model.LeftTime;
            parameters[5].Value = model.LeftType;
            parameters[6].Value = model.LeftReason;
            parameters[7].Value = model.ApprovalPerson;
            parameters[8].Value = model.ApprovalDempart;
            parameters[9].Value = model.Remark;


            if (DbHelperSQL.ExecuteCommand(strSql.ToString(), parameters) > 0)
            {
                return(1);
            }
            return(0);
        }