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

            if (!PageValidate.IsNumber(txtHostID.Text))
            {
                strErr += "HostID格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtChNo.Text))
            {
                strErr += "ChNo格式错误!\\n";
            }
            if (this.txtFactCode.Text.Trim().Length == 0)
            {
                strErr += "FactCode不能为空!\\n";
            }
            if (this.txtDataID.Text.Trim().Length == 0)
            {
                strErr += "DataID不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txtChBand.Text))
            {
                strErr += "ChBand格式错误!\\n";
            }
            if (this.txtChBtyeType.Text.Trim().Length == 0)
            {
                strErr += "ChBtyeType不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int    ID         = int.Parse(this.lblID.Text);
            int    HostID     = int.Parse(this.txtHostID.Text);
            int    ChNo       = int.Parse(this.txtChNo.Text);
            string FactCode   = this.txtFactCode.Text;
            string DataID     = this.txtDataID.Text;
            int    ChBand     = int.Parse(this.txtChBand.Text);
            string ChBtyeType = this.txtChBtyeType.Text;


            WebDemo.Model.WebDemo.HostsCH model = new WebDemo.Model.WebDemo.HostsCH();
            model.ID         = ID;
            model.HostID     = HostID;
            model.ChNo       = ChNo;
            model.FactCode   = FactCode;
            model.DataID     = DataID;
            model.ChBand     = ChBand;
            model.ChBtyeType = ChBtyeType;

            WebDemo.BLL.WebDemo.HostsCH bll = new WebDemo.BLL.WebDemo.HostsCH();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }
Ejemplo n.º 2
0
 private void ShowInfo(int ID)
 {
     WebDemo.BLL.WebDemo.HostsCH   bll   = new WebDemo.BLL.WebDemo.HostsCH();
     WebDemo.Model.WebDemo.HostsCH model = bll.GetModel(ID);
     this.lblID.Text         = model.ID.ToString();
     this.txtHostID.Text     = model.HostID.ToString();
     this.txtChNo.Text       = model.ChNo.ToString();
     this.txtFactCode.Text   = model.FactCode;
     this.txtDataID.Text     = model.DataID;
     this.txtChBand.Text     = model.ChBand.ToString();
     this.txtChBtyeType.Text = model.ChBtyeType;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(WebDemo.Model.WebDemo.HostsCH model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update HostsCH set ");
            strSql.Append("HostID=@HostID,");
            strSql.Append("ChNo=@ChNo,");
            strSql.Append("FactCode=@FactCode,");
            strSql.Append("DataID=@DataID,");
            strSql.Append("ChBand=@ChBand,");
            strSql.Append("ChBtyeType=@ChBtyeType");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@HostID",     SqlDbType.Int,     4),
                new SqlParameter("@ChNo",       SqlDbType.Int,     4),
                new SqlParameter("@FactCode",   SqlDbType.VarChar, 8),
                new SqlParameter("@DataID",     SqlDbType.VarChar, 8),
                new SqlParameter("@ChBand",     SqlDbType.Int,     4),
                new SqlParameter("@ChBtyeType", SqlDbType.VarChar, 2),
                new SqlParameter("@ID",         SqlDbType.Int, 4)
            };
            parameters[0].Value = model.HostID;
            parameters[1].Value = model.ChNo;
            parameters[2].Value = model.FactCode;
            parameters[3].Value = model.DataID;
            parameters[4].Value = model.ChBand;
            parameters[5].Value = model.ChBtyeType;
            parameters[6].Value = model.ID;

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

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

            strSql.Append("insert into HostsCH(");
            strSql.Append("HostID,ChNo,FactCode,DataID,ChBand,ChBtyeType)");
            strSql.Append(" values (");
            strSql.Append("@HostID,@ChNo,@FactCode,@DataID,@ChBand,@ChBtyeType)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@HostID",     SqlDbType.Int,     4),
                new SqlParameter("@ChNo",       SqlDbType.Int,     4),
                new SqlParameter("@FactCode",   SqlDbType.VarChar, 8),
                new SqlParameter("@DataID",     SqlDbType.VarChar, 8),
                new SqlParameter("@ChBand",     SqlDbType.Int,     4),
                new SqlParameter("@ChBtyeType", SqlDbType.VarChar, 2)
            };
            parameters[0].Value = model.HostID;
            parameters[1].Value = model.ChNo;
            parameters[2].Value = model.FactCode;
            parameters[3].Value = model.DataID;
            parameters[4].Value = model.ChBand;
            parameters[5].Value = model.ChBtyeType;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public WebDemo.Model.WebDemo.HostsCH DataRowToModel(DataRow row)
 {
     WebDemo.Model.WebDemo.HostsCH model = new WebDemo.Model.WebDemo.HostsCH();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = int.Parse(row["ID"].ToString());
         }
         if (row["HostID"] != null && row["HostID"].ToString() != "")
         {
             model.HostID = int.Parse(row["HostID"].ToString());
         }
         if (row["ChNo"] != null && row["ChNo"].ToString() != "")
         {
             model.ChNo = int.Parse(row["ChNo"].ToString());
         }
         if (row["FactCode"] != null)
         {
             model.FactCode = row["FactCode"].ToString();
         }
         if (row["DataID"] != null)
         {
             model.DataID = row["DataID"].ToString();
         }
         if (row["ChBand"] != null && row["ChBand"].ToString() != "")
         {
             model.ChBand = int.Parse(row["ChBand"].ToString());
         }
         if (row["ChBtyeType"] != null)
         {
             model.ChBtyeType = row["ChBtyeType"].ToString();
         }
     }
     return(model);
 }
Ejemplo n.º 6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public WebDemo.Model.WebDemo.HostsCH GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,HostID,ChNo,FactCode,DataID,ChBand,ChBtyeType from HostsCH ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ID;

            WebDemo.Model.WebDemo.HostsCH model = new WebDemo.Model.WebDemo.HostsCH();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }