Ejemplo n.º 1
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtitemName.Text.Trim().Length == 0)
            {
                strErr += "码表项不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txtOrders.Text))
            {
                strErr += "排序必须填写数字!\\n";
            }
            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int    siId     = int.Parse(this.lblsiId.Text);
            string itemName = this.txtitemName.Text;
            int    orders   = int.Parse(this.txtOrders.Text);

            hm.BLL.sysItem   bll   = new hm.BLL.sysItem();
            hm.Model.sysItem model = bll.GetModel(siId);
            model.siId     = siId;
            model.itemName = itemName;
            model.orders   = orders;

            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx?id=" + model.sicId);
        }
Ejemplo n.º 2
0
 private void ShowInfo(int siId)
 {
     hm.BLL.sysItem   bll   = new hm.BLL.sysItem();
     hm.Model.sysItem model = bll.GetModel(siId);
     this.lblsiId.Text     = model.siId.ToString();
     this.txtitemName.Text = model.itemName;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public hm.Model.sysItem GetModel(int siId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select siId,sicId,itemName,orders,col1,col2,col3,col4 from sysItem ");
            strSql.Append(" where siId=@siId");
            OleDbParameter[] parameters =
            {
                new OleDbParameter("@siId", OleDbType.Integer, 4)
            };
            parameters[0].Value = siId;

            hm.Model.sysItem model = new hm.Model.sysItem();
            DataSet          ds    = DbHelperOleDb.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["siId"] != null && ds.Tables[0].Rows[0]["siId"].ToString() != "")
                {
                    model.siId = int.Parse(ds.Tables[0].Rows[0]["siId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["sicId"] != null && ds.Tables[0].Rows[0]["sicId"].ToString() != "")
                {
                    model.sicId = int.Parse(ds.Tables[0].Rows[0]["sicId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["itemName"] != null && ds.Tables[0].Rows[0]["itemName"].ToString() != "")
                {
                    model.itemName = ds.Tables[0].Rows[0]["itemName"].ToString();
                }
                if (ds.Tables[0].Rows[0]["orders"] != null && ds.Tables[0].Rows[0]["orders"].ToString() != "")
                {
                    model.orders = int.Parse(ds.Tables[0].Rows[0]["orders"].ToString());
                }
                if (ds.Tables[0].Rows[0]["col1"] != null && ds.Tables[0].Rows[0]["col1"].ToString() != "")
                {
                    model.col1 = ds.Tables[0].Rows[0]["col1"].ToString();
                }
                if (ds.Tables[0].Rows[0]["col2"] != null && ds.Tables[0].Rows[0]["col2"].ToString() != "")
                {
                    model.col2 = ds.Tables[0].Rows[0]["col2"].ToString();
                }
                if (ds.Tables[0].Rows[0]["col3"] != null && ds.Tables[0].Rows[0]["col3"].ToString() != "")
                {
                    model.col3 = ds.Tables[0].Rows[0]["col3"].ToString();
                }
                if (ds.Tables[0].Rows[0]["col4"] != null && ds.Tables[0].Rows[0]["col4"].ToString() != "")
                {
                    model.col4 = int.Parse(ds.Tables[0].Rows[0]["col4"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(hm.Model.sysItem model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update sysItem set ");
            strSql.Append("sicId=@sicId,");
            strSql.Append("itemName=@itemName,");
            strSql.Append("orders=@orders,");
            strSql.Append("col1=@col1,");
            strSql.Append("col2=@col2,");
            strSql.Append("col3=@col3,");
            strSql.Append("col4=@col4");
            strSql.Append(" where siId=@siId");
            OleDbParameter[] parameters =
            {
                new OleDbParameter("@sicId",    OleDbType.Integer,   4),
                new OleDbParameter("@itemName", OleDbType.VarChar,   0),
                new OleDbParameter("@orders",   OleDbType.Integer,   4),
                new OleDbParameter("@col1",     OleDbType.VarChar, 255),
                new OleDbParameter("@col2",     OleDbType.VarChar, 255),
                new OleDbParameter("@col3",     OleDbType.VarChar, 255),
                new OleDbParameter("@col4",     OleDbType.Integer,   4),
                new OleDbParameter("@siId",     OleDbType.Integer, 4)
            };
            parameters[0].Value = model.sicId;
            parameters[1].Value = model.itemName;
            parameters[2].Value = model.orders;
            parameters[3].Value = model.col1;
            parameters[4].Value = model.col2;
            parameters[5].Value = model.col3;
            parameters[6].Value = model.col4;
            parameters[7].Value = model.siId;

            int rows = DbHelperOleDb.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(hm.Model.sysItem model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into sysItem(");
            strSql.Append("sicId,itemName,orders,col1,col2,col3,col4)");
            strSql.Append(" values (");
            strSql.Append("@sicId,@itemName,@orders,@col1,@col2,@col3,@col4)");
            OleDbParameter[] parameters =
            {
                new OleDbParameter("@sicId",    OleDbType.Integer,   4),
                new OleDbParameter("@itemName", OleDbType.VarChar,   0),
                new OleDbParameter("@orders",   OleDbType.Integer,   4),
                new OleDbParameter("@col1",     OleDbType.VarChar, 255),
                new OleDbParameter("@col2",     OleDbType.VarChar, 255),
                new OleDbParameter("@col3",     OleDbType.VarChar, 255),
                new OleDbParameter("@col4",     OleDbType.Integer, 4)
            };
            parameters[0].Value = model.sicId;
            parameters[1].Value = model.itemName;
            parameters[2].Value = model.orders;
            parameters[3].Value = model.col1;
            parameters[4].Value = model.col2;
            parameters[5].Value = model.col3;
            parameters[6].Value = model.col4;

            int rows = DbHelperOleDb.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public hm.Model.sysItem GetModel(int siId)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 siId,sicId,itemName,itemPath,back1,back2,back3,back4,orders from sysItem ");
            strSql.Append(" where siId=@siId");
            SqlParameter[] parameters = {
                    new SqlParameter("@siId", SqlDbType.Int,4)
            };
            parameters[0].Value = siId;

            hm.Model.sysItem model=new hm.Model.sysItem();
            DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
            if(ds.Tables[0].Rows.Count>0)
            {
                if(ds.Tables[0].Rows[0]["siId"]!=null && ds.Tables[0].Rows[0]["siId"].ToString()!="")
                {
                    model.siId=int.Parse(ds.Tables[0].Rows[0]["siId"].ToString());
                }
                if(ds.Tables[0].Rows[0]["sicId"]!=null && ds.Tables[0].Rows[0]["sicId"].ToString()!="")
                {
                    model.sicId=int.Parse(ds.Tables[0].Rows[0]["sicId"].ToString());
                }
                if(ds.Tables[0].Rows[0]["itemName"]!=null && ds.Tables[0].Rows[0]["itemName"].ToString()!="")
                {
                    model.itemName=ds.Tables[0].Rows[0]["itemName"].ToString();
                }
                if(ds.Tables[0].Rows[0]["itemPath"]!=null && ds.Tables[0].Rows[0]["itemPath"].ToString()!="")
                {
                    model.itemPath=ds.Tables[0].Rows[0]["itemPath"].ToString();
                }
                if(ds.Tables[0].Rows[0]["back1"]!=null && ds.Tables[0].Rows[0]["back1"].ToString()!="")
                {
                    model.back1=ds.Tables[0].Rows[0]["back1"].ToString();
                }
                if(ds.Tables[0].Rows[0]["back2"]!=null && ds.Tables[0].Rows[0]["back2"].ToString()!="")
                {
                    model.back2=ds.Tables[0].Rows[0]["back2"].ToString();
                }
                if(ds.Tables[0].Rows[0]["back3"]!=null && ds.Tables[0].Rows[0]["back3"].ToString()!="")
                {
                    model.back3=ds.Tables[0].Rows[0]["back3"].ToString();
                }
                if(ds.Tables[0].Rows[0]["back4"]!=null && ds.Tables[0].Rows[0]["back4"].ToString()!="")
                {
                    model.back4=ds.Tables[0].Rows[0]["back4"].ToString();
                }
                if(ds.Tables[0].Rows[0]["orders"]!=null && ds.Tables[0].Rows[0]["orders"].ToString()!="")
                {
                    model.orders=int.Parse(ds.Tables[0].Rows[0]["orders"].ToString());
                }
                return model;
            }
            else
            {
                return null;
            }
        }