Beispiel #1
0
 private void ShowInfo()
 {
     Maticsoft.BLL.test.Table_1   bll   = new Maticsoft.BLL.test.Table_1();
     Maticsoft.Model.test.Table_1 model = bll.GetModel();
     this.txtname.Text     = model.name;
     this.txtnianling.Text = model.nianling;
     this.txtshenggao.Text = model.shenggao;
     this.txtbianhao.Text  = model.bianhao;
 }
Beispiel #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.test.Table_1 model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Table_1 set ");
            if (model.name != null)
            {
                strSql.Append("name='" + model.name + "',");
            }
            else
            {
                strSql.Append("name= null ,");
            }
            if (model.nianling != null)
            {
                strSql.Append("nianling='" + model.nianling + "',");
            }
            else
            {
                strSql.Append("nianling= null ,");
            }
            if (model.shenggao != null)
            {
                strSql.Append("shenggao='" + model.shenggao + "',");
            }
            else
            {
                strSql.Append("shenggao= null ,");
            }
            if (model.bianhao != null)
            {
                strSql.Append("bianhao='" + model.bianhao + "',");
            }
            else
            {
                strSql.Append("bianhao= null ,");
            }
            int n = strSql.ToString().LastIndexOf(",");

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

            if (rowsAffected > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Maticsoft.Model.test.Table_1 model)
        {
            StringBuilder strSql  = new StringBuilder();
            StringBuilder strSql1 = new StringBuilder();
            StringBuilder strSql2 = new StringBuilder();

            if (model.name != null)
            {
                strSql1.Append("name,");
                strSql2.Append("'" + model.name + "',");
            }
            if (model.nianling != null)
            {
                strSql1.Append("nianling,");
                strSql2.Append("'" + model.nianling + "',");
            }
            if (model.shenggao != null)
            {
                strSql1.Append("shenggao,");
                strSql2.Append("'" + model.shenggao + "',");
            }
            if (model.bianhao != null)
            {
                strSql1.Append("bianhao,");
                strSql2.Append("'" + model.bianhao + "',");
            }
            strSql.Append("insert into Table_1(");
            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);
            }
        }
Beispiel #4
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtname.Text.Trim().Length == 0)
            {
                strErr += "name不能为空!\\n";
            }
            if (this.txtnianling.Text.Trim().Length == 0)
            {
                strErr += "nianling不能为空!\\n";
            }
            if (this.txtshenggao.Text.Trim().Length == 0)
            {
                strErr += "shenggao不能为空!\\n";
            }
            if (this.txtbianhao.Text.Trim().Length == 0)
            {
                strErr += "bianhao不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string name     = this.txtname.Text;
            string nianling = this.txtnianling.Text;
            string shenggao = this.txtshenggao.Text;
            string bianhao  = this.txtbianhao.Text;


            Maticsoft.Model.test.Table_1 model = new Maticsoft.Model.test.Table_1();
            model.name     = name;
            model.nianling = nianling;
            model.shenggao = shenggao;
            model.bianhao  = bianhao;

            Maticsoft.BLL.test.Table_1 bll = new Maticsoft.BLL.test.Table_1();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }
Beispiel #5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.test.Table_1 GetModel()
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1  ");
            strSql.Append(" name,nianling,shenggao,bianhao ");
            strSql.Append(" from Table_1 ");
            strSql.Append(" where ");
            Maticsoft.Model.test.Table_1 model = new Maticsoft.Model.test.Table_1();
            DataSet ds = DbHelperSQL.Query(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["name"] != null && ds.Tables[0].Rows[0]["name"].ToString() != "")
                {
                    model.name = ds.Tables[0].Rows[0]["name"].ToString();
                }
                if (ds.Tables[0].Rows[0]["nianling"] != null && ds.Tables[0].Rows[0]["nianling"].ToString() != "")
                {
                    model.nianling = ds.Tables[0].Rows[0]["nianling"].ToString();
                }
                if (ds.Tables[0].Rows[0]["shenggao"] != null && ds.Tables[0].Rows[0]["shenggao"].ToString() != "")
                {
                    model.shenggao = ds.Tables[0].Rows[0]["shenggao"].ToString();
                }
                if (ds.Tables[0].Rows[0]["bianhao"] != null && ds.Tables[0].Rows[0]["bianhao"].ToString() != "")
                {
                    model.bianhao = ds.Tables[0].Rows[0]["bianhao"].ToString();
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }