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); } }
/// <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; } }