コード例 #1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        private thesis.model.Office GetModelByCondition(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select   ");
            strSql.Append(" ID,NAME,MASTER,COMPANYID, DEPARTMENTID");
            strSql.Append(" from OFFICE ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            thesis.model.Office model = new thesis.model.Office();
            DataSet             ds    = DbHelperSQL.Query(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ID"].ToString() != "")
                {
                    model.ID = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
                }
                model.NAME   = ds.Tables[0].Rows[0]["NAME"].ToString();
                model.MASTER = ds.Tables[0].Rows[0]["MASTER"].ToString();

                model.COMPANYID    = int.Parse(ds.Tables[0].Rows[0]["COMPANYID"].ToString());
                model.DEPARTMENTID = int.Parse(ds.Tables[0].Rows[0]["DEPARTMENTID"].ToString());
                return(model);
            }
            else
            {
                return(null);
            }
        }
コード例 #2
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        private List <Office> GetList(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select ID,NAME,MASTER,COMPANYID,DEPARTMENTID");
            strSql.Append(" FROM office ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            DataSet       ds   = DbHelperSQL.Query(strSql.ToString());
            List <Office> list = new List <Office>();

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                thesis.model.Office model = new thesis.model.Office();
                if (ds.Tables[0].Rows[i]["ID"].ToString() != "")
                {
                    model.ID = int.Parse(ds.Tables[0].Rows[i]["ID"].ToString());
                }
                model.NAME         = ds.Tables[0].Rows[i]["NAME"].ToString();
                model.MASTER       = ds.Tables[0].Rows[i]["MASTER"].ToString();
                model.COMPANYID    = int.Parse(ds.Tables[0].Rows[i]["COMPANYID"].ToString());
                model.DEPARTMENTID = int.Parse(ds.Tables[0].Rows[i]["DEPARTMENTID"].ToString());
                list.Add(model);
            }
            return(list);
        }
コード例 #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(thesis.model.Office model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update OFFICE set ");
            strSql.Append("NAME='" + model.NAME + "',");
            strSql.Append("MASTER='" + model.MASTER + "',");
            strSql.Append("COMPANYID=" + model.COMPANYID + ",");
            strSql.Append("DEPARTMENTID=" + model.DEPARTMENTID + "");
            strSql.Append(" where ID=" + model.ID + " ");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }
コード例 #4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(thesis.model.Office model)
        {
            model.ID = GetMaxID() + 1;
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into office(");
            strSql.Append("ID,NAME,MASTER,COMPANYID,DEPARTMENTID");
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append("" + model.ID + ",");
            strSql.Append("'" + model.NAME + "',");
            strSql.Append("'" + model.MASTER + "',");
            strSql.Append("" + model.COMPANYID + ",");
            strSql.Append("" + model.DEPARTMENTID + "");
            strSql.Append(")");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }
コード例 #5
0
ファイル: Office.cs プロジェクト: ZwPandora/GIL
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public void Update(thesis.model.Office model)
 {
     dal.Update(model);
 }
コード例 #6
0
ファイル: Office.cs プロジェクト: ZwPandora/GIL
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public void Add(thesis.model.Office model)
 {
     dal.Add(model);
 }