Exemple #1
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtCommodityFatherID.Text.Trim().Length == 0)
            {
                strErr += "CommodityFatherID不能为空!\\n";
            }
            if (this.txtCommoditySonName.Text.Trim().Length == 0)
            {
                strErr += "CommoditySonName不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string CommoditySonID    = this.lblCommoditySonID.Text;
            string CommodityFatherID = this.txtCommodityFatherID.Text;
            string CommoditySonName  = this.txtCommoditySonName.Text;


            Maticsoft.Model.CommoditySon model = new Maticsoft.Model.CommoditySon();
            model.CommoditySonID    = CommoditySonID;
            model.CommodityFatherID = CommodityFatherID;
            model.CommoditySonName  = CommoditySonName;

            Maticsoft.BLL.CommoditySon bll = new Maticsoft.BLL.CommoditySon();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }
Exemple #2
0
 private void ShowInfo(string CommoditySonID)
 {
     Maticsoft.BLL.CommoditySon   bll   = new Maticsoft.BLL.CommoditySon();
     Maticsoft.Model.CommoditySon model = bll.GetModel(CommoditySonID);
     this.lblCommoditySonID.Text    = model.CommoditySonID;
     this.lblCommodityFatherID.Text = model.CommodityFatherID;
     this.lblCommoditySonName.Text  = model.CommoditySonName;
 }
Exemple #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.CommoditySon DataRowToModel(DataRow row)
 {
     Maticsoft.Model.CommoditySon model = new Maticsoft.Model.CommoditySon();
     if (row != null)
     {
         if (row["CommoditySonID"] != null)
         {
             model.CommoditySonID = row["CommoditySonID"].ToString();
         }
         if (row["CommodityFatherID"] != null)
         {
             model.CommodityFatherID = row["CommodityFatherID"].ToString();
         }
         if (row["CommoditySonName"] != null)
         {
             model.CommoditySonName = row["CommoditySonName"].ToString();
         }
     }
     return(model);
 }
Exemple #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.CommoditySon GetModel(string CommoditySonID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1  ");
            strSql.Append(" CommoditySonID,CommodityFatherID,CommoditySonName ");
            strSql.Append(" from CommoditySon ");
            strSql.Append(" where CommoditySonID='" + CommoditySonID + "' ");
            Maticsoft.Model.CommoditySon model = new Maticsoft.Model.CommoditySon();
            DataSet ds = DbHelperSQL.Query(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Exemple #5
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Maticsoft.Model.CommoditySon model)
        {
            StringBuilder strSql  = new StringBuilder();
            StringBuilder strSql1 = new StringBuilder();
            StringBuilder strSql2 = new StringBuilder();

            if (model.CommoditySonID != null)
            {
                strSql1.Append("CommoditySonID,");
                strSql2.Append("'" + model.CommoditySonID + "',");
            }
            if (model.CommodityFatherID != null)
            {
                strSql1.Append("CommodityFatherID,");
                strSql2.Append("'" + model.CommodityFatherID + "',");
            }
            if (model.CommoditySonName != null)
            {
                strSql1.Append("CommoditySonName,");
                strSql2.Append("'" + model.CommoditySonName + "',");
            }
            strSql.Append("insert into CommoditySon(");
            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);
            }
        }
Exemple #6
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.CommoditySon model)
        {
            StringBuilder strSql = new StringBuilder();

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

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

            if (rowsAffected > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }