Beispiel #1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public DHMSClass.Model.DHMS_BoarderLeave DataRowToModel(DataRow row)
 {
     DHMSClass.Model.DHMS_BoarderLeave model = new DHMSClass.Model.DHMS_BoarderLeave();
     if (row != null)
     {
         if (row["BoarderLeave_ID"] != null)
         {
             model.BoarderLeave_ID = row["BoarderLeave_ID"].ToString();
         }
         if (row["BoarderLeave_Date"] != null && row["BoarderLeave_Date"].ToString() != "")
         {
             model.BoarderLeave_Date = DateTime.Parse(row["BoarderLeave_Date"].ToString());
         }
         if (row["BoarderLeave_Reason"] != null)
         {
             model.BoarderLeave_Reason = row["BoarderLeave_Reason"].ToString();
         }
         if (row["BoarderLeave_Auditor"] != null)
         {
             model.BoarderLeave_Auditor = row["BoarderLeave_Auditor"].ToString();
         }
         if (row["BoarderLeave_State"] != null)
         {
             model.BoarderLeave_State = row["BoarderLeave_State"].ToString();
         }
     }
     return(model);
 }
Beispiel #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(DHMSClass.Model.DHMS_BoarderLeave model)
        {
            StringBuilder strSql  = new StringBuilder();
            StringBuilder strSql1 = new StringBuilder();
            StringBuilder strSql2 = new StringBuilder();

            if (model.BoarderLeave_ID != null)
            {
                strSql1.Append("BoarderLeave_ID,");
                strSql2.Append("'" + model.BoarderLeave_ID + "',");
            }
            if (model.BoarderLeave_Date != null)
            {
                strSql1.Append("BoarderLeave_Date,");
                strSql2.Append("'" + model.BoarderLeave_Date + "',");
            }
            if (model.BoarderLeave_Reason != null)
            {
                strSql1.Append("BoarderLeave_Reason,");
                strSql2.Append("'" + model.BoarderLeave_Reason + "',");
            }
            if (model.BoarderLeave_Auditor != null)
            {
                strSql1.Append("BoarderLeave_Auditor,");
                strSql2.Append("'" + model.BoarderLeave_Auditor + "',");
            }
            if (model.BoarderLeave_State != null)
            {
                strSql1.Append("BoarderLeave_State,");
                strSql2.Append("'" + model.BoarderLeave_State + "',");
            }
            strSql.Append("insert into DHMS_BoarderLeave(");
            strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1));
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1));
            strSql.Append(")");
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString());

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public DHMSClass.Model.DHMS_BoarderLeave GetModel(string BoarderLeave_ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1  ");
            strSql.Append(" BoarderLeave_ID,BoarderLeave_Date,BoarderLeave_Reason,BoarderLeave_Auditor,BoarderLeave_State ");
            strSql.Append(" from DHMS_BoarderLeave ");
            strSql.Append(" where BoarderLeave_ID='" + BoarderLeave_ID + "' ");
            DHMSClass.Model.DHMS_BoarderLeave model = new DHMSClass.Model.DHMS_BoarderLeave();
            DataSet ds = DbHelperSQL.Query(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Beispiel #4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(DHMSClass.Model.DHMS_BoarderLeave model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update DHMS_BoarderLeave set ");
            if (model.BoarderLeave_Date != null)
            {
                strSql.Append("BoarderLeave_Date='" + model.BoarderLeave_Date + "',");
            }
            if (model.BoarderLeave_Reason != null)
            {
                strSql.Append("BoarderLeave_Reason='" + model.BoarderLeave_Reason + "',");
            }
            if (model.BoarderLeave_Auditor != null)
            {
                strSql.Append("BoarderLeave_Auditor='" + model.BoarderLeave_Auditor + "',");
            }
            if (model.BoarderLeave_State != null)
            {
                strSql.Append("BoarderLeave_State='" + model.BoarderLeave_State + "',");
            }
            int n = strSql.ToString().LastIndexOf(",");

            strSql.Remove(n, 1);
            strSql.Append(" where BoarderLeave_ID='" + model.BoarderLeave_ID + "' ");
            int rowsAffected = DbHelperSQL.ExecuteSql(strSql.ToString());

            if (rowsAffected > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }