示例#1
0
        public Entity.HRJobCate GetItemByID(string ID)
        {
            string       sSql  = "select AddDate,CateType,DelTime,FlowState,ID,Intro,IsDel,NodeCode,ParentID,SiteID,Title,Orders from K_HRJobCate where ID=@ID";
            SqlParameter param = new SqlParameter("@ID", ID);

            Entity.HRJobCate model = new Entity.HRJobCate();
            using (DbDataReader dr = SQLHelper.ExecuteReader(SQLHelper.ConnectionStringLocalTransaction, CommandType.Text, sSql, param))
            {
                while (dr.Read())
                {
                    model.AddDate   = Utils.StrToDate(dr["AddDate"].ToString());
                    model.CateType  = dr["CateType"].ToString();
                    model.DelTime   = Utils.StrToDate(dr["DelTime"].ToString());
                    model.FlowState = Utils.ParseInt(dr["FlowState"].ToString(), 0);
                    model.ID        = dr["ID"].ToString();
                    model.Intro     = dr["Intro"].ToString();
                    model.IsDel     = Utils.ParseInt(dr["IsDel"].ToString(), 0);
                    model.NodeCode  = dr["NodeCode"].ToString();
                    model.ParentID  = dr["ParentID"].ToString();
                    model.SiteID    = Utils.ParseInt(dr["SiteID"].ToString(), 0);
                    model.Title     = dr["Title"].ToString();
                    model.Orders    = Utils.ParseInt(dr["Orders"].ToString(), 0);
                }
            }
            return(model);
        }
示例#2
0
        public string[] CreateItem(Entity.HRJobCate model)
        {
            Dictionary <string, string> dic = new Dictionary <string, string>();

            string sql = "select max(ID) from K_HRJobCate Where ParentID=@ParentID AND CateType=@CateType";

            SqlParameter[] prams = new SqlParameter[] {
                new SqlParameter("@ParentID", model.ParentID),
                new SqlParameter("@CateType", model.CateType),
            };
            SqlDataReader dr = SQLHelper.ExecuteReader(SQLHelper.ConnectionStringLocalTransaction, CommandType.Text, sql, prams);
            string        id = "100";

            if (dr.Read())
            {
                string id1 = dr[0].ToString();
                if (string.IsNullOrEmpty(id1) && model.ParentID != "0")
                {
                    id = model.ParentID + "001";
                }
                else if (!string.IsNullOrEmpty(id1))
                {
                    int    idLen = id1.Length;
                    string id2   = "00" + (Utils.ParseInt(id1.Substring(idLen - 3), 0) + 1).ToString();
                    id = id1.Substring(0, idLen - 3) + id2.Substring(id2.Length - 3);
                }
            }
            else
            {
                if (model.ParentID != "0")
                {
                    id = model.ParentID + "001";
                }
            }
            dr.Close();
            dr.Dispose();

            dic.Add("ID", id);
            dic.Add("AddDate", model.AddDate.ToString());
            dic.Add("CateType", model.CateType);
            dic.Add("DelTime", model.DelTime.ToString());
            dic.Add("FlowState", model.FlowState.ToString());
            dic.Add("Intro", model.Intro.ToString());
            dic.Add("IsDel", model.IsDel.ToString());
            dic.Add("NodeCode", model.NodeCode.ToString());
            dic.Add("ParentID", model.ParentID);
            dic.Add("SiteID", model.SiteID.ToString());
            dic.Add("Title", model.Title.ToString());
            dic.Add("Orders", model.Orders.ToString());
            return(InfoHelper.Add("K_HRJobCate", dic));
        }