예제 #1
0
파일: add.aspx.cs 프로젝트: no10pc/Light
 private void doPost()
 {
     string cname = Request["cname"];
     light.BLL.category bll = new light.BLL.category();
     if (!bll.Exists(cname))
     {
         light.Model.category model = new light.Model.category();
         model.addtime = DateTime.Now;
         model.cname = cname;
         model.ename = light.Common.Hz2Py.Convert(cname);
         model.isopen = 1;
         model.parentid = int.Parse(ViewState["pid"].ToString());
         bll.Add(model);
         WebMessageBox.ShowMessageBox("添加成功", this);
     }
     else
     {
         WebMessageBox.ShowMessageBox("该分类名已经存在", this);
     }
 }
예제 #2
0
파일: category.cs 프로젝트: no10pc/Light
        /// <summary>
        /// �õ�һ������ʵ��
        /// </summary>
        public light.Model.category GetModel(int pkid)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select pkid,cname,ename,parentid,isopen,addtime from category ");
            strSql.Append(" where pkid=@pkid ");
            OleDbParameter[] parameters = {
                    new OleDbParameter("@pkid", OleDbType.Integer,4)};
            parameters[0].Value = pkid;

            light.Model.category model = new light.Model.category();
            DataSet ds = DbHelperOleDb.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                model.pkid = int.Parse(ds.Tables[0].Rows[0]["pkid"].ToString());
                model.cname = ds.Tables[0].Rows[0]["cname"].ToString();
                model.ename = ds.Tables[0].Rows[0]["ename"].ToString();
                model.parentid = int.Parse(ds.Tables[0].Rows[0]["parentid"].ToString());
                model.isopen = int.Parse(ds.Tables[0].Rows[0]["isopen"].ToString());
                model.addtime = DateTime.Parse(ds.Tables[0].Rows[0]["addtime"].ToString());
                return model;
            }
            else
            {
                return null;
            }
        }