Ejemplo n.º 1
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            string CategoryId = this.txtCategoryId.Text;
            string Name = this.txtName.Text;
            string Descn = this.txtDescn.Text;



            Maticsoft.Model.Category model = new Maticsoft.Model.Category();
            model.CategoryId = CategoryId;
            model.Name = Name;
            model.Descn = Descn;
            Maticsoft.BLL.Products.Category bll = new Maticsoft.BLL.Products.Category();
            if (bll.Exists(CategoryId))
            {
                lblMsg.Visible = true;
                lblMsg.Text = "±àºÅÒѾ­´æÔÚ£¡";
            }
            else
            {
                bll.Add(model);
                if (chkAddContinue.Checked)
                {
                    Response.Redirect("Add.aspx");
                }
                else
                {
                    Response.Redirect("index.aspx");
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.Category GetModel(string CategoryId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select * from P_Category ");
            strSql.Append(" where CategoryId=@CategoryId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CategoryId", SqlDbType.VarChar)
            };
            parameters[0].Value = CategoryId;
            Maticsoft.Model.Category model = new Maticsoft.Model.Category();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            model.CategoryId = CategoryId;
            if (ds.Tables[0].Rows.Count > 0)
            {
                model.Name  = ds.Tables[0].Rows[0]["Name"].ToString();
                model.Descn = ds.Tables[0].Rows[0]["Descn"].ToString();
                return(model);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 3
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            string CategoryId = this.txtCategoryId.Text;
            string Name       = this.txtName.Text;
            string Descn      = this.txtDescn.Text;



            Maticsoft.Model.Category model = new Maticsoft.Model.Category();
            model.CategoryId = CategoryId;
            model.Name       = Name;
            model.Descn      = Descn;
            Maticsoft.BLL.Products.Category bll = new Maticsoft.BLL.Products.Category();
            if (bll.Exists(CategoryId))
            {
                lblMsg.Visible = true;
                lblMsg.Text    = "±àºÅÒѾ­´æÔÚ£¡";
            }
            else
            {
                bll.Add(model);
                if (chkAddContinue.Checked)
                {
                    Response.Redirect("Add.aspx");
                }
                else
                {
                    Response.Redirect("index.aspx");
                }
            }
        }
Ejemplo n.º 4
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtCategorytype.Text.Trim().Length == 0)
            {
                strErr += "Categorytype不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int    CategoryID   = int.Parse(this.lblCategoryID.Text);
            string Categorytype = this.txtCategorytype.Text;


            Maticsoft.Model.Category model = new Maticsoft.Model.Category();
            model.CategoryID   = CategoryID;
            model.Categorytype = Categorytype;

            Maticsoft.BLL.Category bll = new Maticsoft.BLL.Category();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }
Ejemplo n.º 5
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (!PageValidate.IsNumber(txtCategoryID.Text))
            {
                strErr += "CategoryID格式错误!\\n";
            }
            if (this.txtCategorytype.Text.Trim().Length == 0)
            {
                strErr += "Categorytype不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int    CategoryID   = int.Parse(this.txtCategoryID.Text);
            string Categorytype = this.txtCategorytype.Text;

            Maticsoft.Model.Category model = new Maticsoft.Model.Category();
            model.CategoryID   = CategoryID;
            model.Categorytype = Categorytype;

            Maticsoft.BLL.Category bll = new Maticsoft.BLL.Category();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx");
        }
Ejemplo n.º 6
0
 private void ShowInfo(int CategoryID)
 {
     Maticsoft.BLL.Category   bll   = new Maticsoft.BLL.Category();
     Maticsoft.Model.Category model = bll.GetModel(CategoryID);
     this.lblCategoryID.Text   = model.CategoryID.ToString();
     this.lblCategorytype.Text = model.Categorytype;
 }
Ejemplo n.º 7
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.Category model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Category set ");
            if (model.Categorytype != null)
            {
                strSql.Append("Categorytype='" + model.Categorytype + "',");
            }
            else
            {
                strSql.Append("Categorytype= null ,");
            }
            int n = strSql.ToString().LastIndexOf(",");

            strSql.Remove(n, 1);
            strSql.Append(" where CategoryID=" + model.CategoryID + " ");
            int rowsAffected = DbHelperSQL.ExecuteSql(strSql.ToString());

            if (rowsAffected > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Maticsoft.Model.Category model)
        {
            StringBuilder strSql  = new StringBuilder();
            StringBuilder strSql1 = new StringBuilder();
            StringBuilder strSql2 = new StringBuilder();

            if (model.CategoryID != null)
            {
                strSql1.Append("CategoryID,");
                strSql2.Append("" + model.CategoryID + ",");
            }
            if (model.Categorytype != null)
            {
                strSql1.Append("Categorytype,");
                strSql2.Append("'" + model.Categorytype + "',");
            }
            strSql.Append("insert into Category(");
            strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1));
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1));
            strSql.Append(")");
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString());

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 9
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            string CategoryId = this.lblCategoryId.Text;
            string Name = this.txtName.Text;
            string Descn = this.txtDescn.Text;

            Maticsoft.Model.Category model = new Maticsoft.Model.Category();
            model.CategoryId = CategoryId;
            model.Name = Name;
            model.Descn = Descn;
            Maticsoft.BLL.Products.Category bll = new Maticsoft.BLL.Products.Category();
            bll.Update(model);
            Response.Redirect("index.aspx");
        }
Ejemplo n.º 10
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            string CategoryId = this.lblCategoryId.Text;
            string Name       = this.txtName.Text;
            string Descn      = this.txtDescn.Text;

            Maticsoft.Model.Category model = new Maticsoft.Model.Category();
            model.CategoryId = CategoryId;
            model.Name       = Name;
            model.Descn      = Descn;
            Maticsoft.BLL.Products.Category bll = new Maticsoft.BLL.Products.Category();
            bll.Update(model);
            Response.Redirect("index.aspx");
        }
Ejemplo n.º 11
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.Category DataRowToModel(DataRow row)
 {
     Maticsoft.Model.Category model = new Maticsoft.Model.Category();
     if (row != null)
     {
         if (row["CategoryID"] != null && row["CategoryID"].ToString() != "")
         {
             model.CategoryID = int.Parse(row["CategoryID"].ToString());
         }
         if (row["Categorytype"] != null)
         {
             model.Categorytype = row["Categorytype"].ToString();
         }
     }
     return(model);
 }
Ejemplo n.º 12
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.Category GetModel(int CategoryID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1  ");
            strSql.Append(" CategoryID,Categorytype ");
            strSql.Append(" from Category ");
            strSql.Append(" where CategoryID=" + CategoryID + " ");
            Maticsoft.Model.Category model = new Maticsoft.Model.Category();
            DataSet ds = DbHelperSQL.Query(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Maticsoft.Model.Category model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update P_Category set ");
            strSql.Append("Name=@Name,");
            strSql.Append("Descn=@Descn ");
            strSql.Append(" where CategoryId=@CategoryId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Name",       SqlDbType.VarChar,  80),
                new SqlParameter("@Descn",      SqlDbType.VarChar, 255),
                new SqlParameter("@CategoryId", SqlDbType.VarChar, 20)
            };
            parameters[0].Value = model.Name;
            parameters[1].Value = model.Descn;
            parameters[2].Value = model.CategoryId;


            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(Maticsoft.Model.Category model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into P_Category(");
            strSql.Append("CategoryId,Name,Descn)");
            strSql.Append(" values (");
            strSql.Append("@CategoryId,@Name,@Descn)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CategoryId", SqlDbType.VarChar, 20),
                new SqlParameter("@Name",       SqlDbType.VarChar, 80),
                new SqlParameter("@Descn",      SqlDbType.VarChar, 255)
            };
            parameters[0].Value = model.CategoryId;
            parameters[1].Value = model.Name;
            parameters[2].Value = model.Descn;


            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
Ejemplo n.º 15
0
 private void ShowInfo(string id)
 {
     Maticsoft.BLL.Products.Category bll   = new Maticsoft.BLL.Products.Category();
     Maticsoft.Model.Category        model = bll.GetModel(id);
     this.lblCategoryId.Text = model.CategoryId.ToString();
     txtName.Text            = model.Name;
     txtDescn.Text           = model.Descn;
     //if (model.ParentId == 0)
     //{
     //    dropParent.SelectedIndex = 0;
     //}
     //else
     //{
     //    for (int m = 0; m < this.dropParent.Items.Count; m++)
     //    {
     //        if (this.dropParent.Items[m].Value == model.ParentId.ToString())
     //        {
     //            this.dropParent.Items[m].Selected = true;
     //        }
     //    }
     //}
 }
Ejemplo n.º 16
0
 /// <summary>
 /// �õ�һ������ʵ��
 /// </summary>
 public Maticsoft.Model.Category GetModel(string CategoryId)
 {
     StringBuilder strSql = new StringBuilder();
     strSql.Append("select * from P_Category ");
     strSql.Append(" where CategoryId=@CategoryId");
     SqlParameter[] parameters = {
             new SqlParameter("@CategoryId", SqlDbType.VarChar)};
     parameters[0].Value = CategoryId;
     Maticsoft.Model.Category model = new Maticsoft.Model.Category();
     DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
     model.CategoryId = CategoryId;
     if (ds.Tables[0].Rows.Count > 0)
     {
         model.Name = ds.Tables[0].Rows[0]["Name"].ToString();
         model.Descn = ds.Tables[0].Rows[0]["Descn"].ToString();
         return model;
     }
     else
     {
         return null;
     }
 }