Beispiel #1
0
 /// <summary>
 /// 获得数据列表
 /// </summary>
 public List<Organ> DataTableToList(DataTable dt)
 {
     List<Organ> modelList = new List<Organ>();
     int rowsCount = dt.Rows.Count;
     if (rowsCount > 0)
     {
         Organ model;
         for (int n = 0; n < rowsCount; n++)
         {
             model = new Organ();
             if (dt.Rows[n]["OrganID"] != null && dt.Rows[n]["OrganID"].ToString() != "")
             {
                 model.OrganID = int.Parse(dt.Rows[n]["OrganID"].ToString());
             }
             if (dt.Rows[n]["OrganName"] != null && dt.Rows[n]["OrganName"].ToString() != "")
             {
                 model.OrganName = dt.Rows[n]["OrganName"].ToString();
             }
             if (dt.Rows[n]["Remark"] != null && dt.Rows[n]["Remark"].ToString() != "")
             {
                 model.Remark = dt.Rows[n]["Remark"].ToString();
             }
             if (dt.Rows[n]["Superior"] != null && dt.Rows[n]["Superior"].ToString() != "")
             {
                 model.Superior = int.Parse(dt.Rows[n]["Superior"].ToString());
             }
             if (dt.Rows[n]["Level"] != null && dt.Rows[n]["Level"].ToString() != "")
             {
                 model.Level = int.Parse(dt.Rows[n]["Level"].ToString());
             }
             modelList.Add(model);
         }
     }
     return modelList;
 }
Beispiel #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Organ model)
        {
            //StringBuilder strSql = new StringBuilder();
            //strSql.Append("insert into Organ(OrganID,OrganName,Remark,Superior,Level)");
            //strSql.Append(" SELECT (Max(OrganID)+1),@OrganName,@Remark,@Superior,@Level FROM Organ ");

            //SqlParameter[] parameters = {
            //        new SqlParameter("@OrganName", model.OrganName),
            //        new SqlParameter("@Remark", model.Remark == null ? "" : model.Remark),
            //        new SqlParameter("@Superior", model.Superior == null ? 0 : model.Superior),
            //        new SqlParameter("@Level", model.Level)
            //                            };

            //int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
            //if (rows > 0)
            //{
            //    return true;
            //}
            //else
            //{
            //    return false;
            //}

            SqlParameter[] parameters = {
                    new SqlParameter("@OrganName", model.OrganName),
                    new SqlParameter("@Remark", model.Remark == null ? "" : model.Remark),
                    new SqlParameter("@Superior", model.Superior == null ? 0 : model.Superior),
                    new SqlParameter("@Level", model.Level),
                    new SqlParameter("@InputBy",model.InputBy)
                                        };
            int re = 0;
            DbHelperSQL.RunProcedure("Proc_AddOrgan", parameters, out re);
            return (re>0);
        }
Beispiel #3
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(Organ model)
 {
     return dal.Add(model);
 }
Beispiel #4
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Organ model)
 {
     return dal.Update(model);
 }
Beispiel #5
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Organ model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update Organ set ");
            strSql.Append("OrganName=@OrganName,");
            strSql.Append("Remark=@Remark,");
            strSql.Append("Superior=@Superior,");
            strSql.Append("Level=@Level");
            strSql.Append(" where OrganID=@OrganID ");
            SqlParameter[] parameters = {
                    new SqlParameter("@OrganName", model.OrganName),
                    new SqlParameter("@Remark", model.Remark == null ? "" : model.Remark),
                    new SqlParameter("@Superior", model.Superior == null ? 0 : model.Superior),
                    new SqlParameter("@Level", model.Level),
                    new SqlParameter("@OrganID", model.OrganID)};

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
Beispiel #6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Organ GetModel(int OrganID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 OrganID,OrganName,Remark,Superior,Level from Organ ");
            strSql.Append(" where OrganID=@OrganID ");
            SqlParameter[] parameters = {
                    new SqlParameter("@OrganID", SqlDbType.Int,4)			};
            parameters[0].Value = OrganID;

            Organ model = new Organ();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["OrganID"] != null && ds.Tables[0].Rows[0]["OrganID"].ToString() != "")
                {
                    model.OrganID = int.Parse(ds.Tables[0].Rows[0]["OrganID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["OrganName"] != null && ds.Tables[0].Rows[0]["OrganName"].ToString() != "")
                {
                    model.OrganName = ds.Tables[0].Rows[0]["OrganName"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Remark"] != null && ds.Tables[0].Rows[0]["Remark"].ToString() != "")
                {
                    model.Remark = ds.Tables[0].Rows[0]["Remark"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Superior"] != null && ds.Tables[0].Rows[0]["Superior"].ToString() != "")
                {
                    model.Superior = int.Parse(ds.Tables[0].Rows[0]["Superior"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Level"] != null && ds.Tables[0].Rows[0]["Level"].ToString() != "")
                {
                    model.Level = int.Parse(ds.Tables[0].Rows[0]["Level"].ToString());
                }
                return model;
            }
            else
            {
                return null;
            }
        }