Пример #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(WebDemo.Model.WebDemo.ManageFare model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into ManageFare(");
            strSql.Append("ManageFareName,ManageFarePrice,ManageFareTypeID,ReMark,SystemNum)");
            strSql.Append(" values (");
            strSql.Append("@ManageFareName,@ManageFarePrice,@ManageFareTypeID,@ReMark,@SystemNum)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ManageFareName",   SqlDbType.VarChar,  50),
                new SqlParameter("@ManageFarePrice",  SqlDbType.Decimal,   9),
                new SqlParameter("@ManageFareTypeID", SqlDbType.Int,       4),
                new SqlParameter("@ReMark",           SqlDbType.VarChar, 200),
                new SqlParameter("@SystemNum",        SqlDbType.Int, 4)
            };
            parameters[0].Value = model.ManageFareName;
            parameters[1].Value = model.ManageFarePrice;
            parameters[2].Value = model.ManageFareTypeID;
            parameters[3].Value = model.ReMark;
            parameters[4].Value = model.SystemNum;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Пример #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public WebDemo.Model.WebDemo.ManageFare DataRowToModel(DataRow row)
 {
     WebDemo.Model.WebDemo.ManageFare model = new WebDemo.Model.WebDemo.ManageFare();
     if (row != null)
     {
         if (row["ManageFareID"] != null && row["ManageFareID"].ToString() != "")
         {
             model.ManageFareID = int.Parse(row["ManageFareID"].ToString());
         }
         if (row["ManageFareName"] != null)
         {
             model.ManageFareName = row["ManageFareName"].ToString();
         }
         if (row["ManageFarePrice"] != null && row["ManageFarePrice"].ToString() != "")
         {
             model.ManageFarePrice = decimal.Parse(row["ManageFarePrice"].ToString());
         }
         if (row["ManageFareTypeID"] != null && row["ManageFareTypeID"].ToString() != "")
         {
             model.ManageFareTypeID = int.Parse(row["ManageFareTypeID"].ToString());
         }
         if (row["ReMark"] != null)
         {
             model.ReMark = row["ReMark"].ToString();
         }
         if (row["SystemNum"] != null && row["SystemNum"].ToString() != "")
         {
             model.SystemNum = int.Parse(row["SystemNum"].ToString());
         }
     }
     return(model);
 }
Пример #3
0
 private void ShowInfo(int ManageFareID)
 {
     WebDemo.BLL.WebDemo.ManageFare   bll   = new WebDemo.BLL.WebDemo.ManageFare();
     WebDemo.Model.WebDemo.ManageFare model = bll.GetModel(ManageFareID);
     this.lblManageFareID.Text     = model.ManageFareID.ToString();
     this.txtManageFareName.Text   = model.ManageFareName;
     this.txtManageFarePrice.Text  = model.ManageFarePrice.ToString();
     this.txtManageFareTypeID.Text = model.ManageFareTypeID.ToString();
     this.txtReMark.Text           = model.ReMark;
     this.txtSystemNum.Text        = model.SystemNum.ToString();
 }
Пример #4
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtManageFareName.Text.Trim().Length == 0)
            {
                strErr += "ManageFareName不能为空!\\n";
            }
            if (!PageValidate.IsDecimal(txtManageFarePrice.Text))
            {
                strErr += "ManageFarePrice格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtManageFareTypeID.Text))
            {
                strErr += "ManageFareTypeID格式错误!\\n";
            }
            if (this.txtReMark.Text.Trim().Length == 0)
            {
                strErr += "ReMark不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txtSystemNum.Text))
            {
                strErr += "SystemNum格式错误!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int     ManageFareID     = int.Parse(this.lblManageFareID.Text);
            string  ManageFareName   = this.txtManageFareName.Text;
            decimal ManageFarePrice  = decimal.Parse(this.txtManageFarePrice.Text);
            int     ManageFareTypeID = int.Parse(this.txtManageFareTypeID.Text);
            string  ReMark           = this.txtReMark.Text;
            int     SystemNum        = int.Parse(this.txtSystemNum.Text);


            WebDemo.Model.WebDemo.ManageFare model = new WebDemo.Model.WebDemo.ManageFare();
            model.ManageFareID     = ManageFareID;
            model.ManageFareName   = ManageFareName;
            model.ManageFarePrice  = ManageFarePrice;
            model.ManageFareTypeID = ManageFareTypeID;
            model.ReMark           = ReMark;
            model.SystemNum        = SystemNum;

            WebDemo.BLL.WebDemo.ManageFare bll = new WebDemo.BLL.WebDemo.ManageFare();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }
Пример #5
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(WebDemo.Model.WebDemo.ManageFare model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update ManageFare set ");
            strSql.Append("ManageFareName=@ManageFareName,");
            strSql.Append("ManageFarePrice=@ManageFarePrice,");
            strSql.Append("ManageFareTypeID=@ManageFareTypeID,");
            strSql.Append("ReMark=@ReMark,");
            strSql.Append("SystemNum=@SystemNum");
            strSql.Append(" where ManageFareID=@ManageFareID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ManageFareName",   SqlDbType.VarChar,  50),
                new SqlParameter("@ManageFarePrice",  SqlDbType.Decimal,   9),
                new SqlParameter("@ManageFareTypeID", SqlDbType.Int,       4),
                new SqlParameter("@ReMark",           SqlDbType.VarChar, 200),
                new SqlParameter("@SystemNum",        SqlDbType.Int,       4),
                new SqlParameter("@ManageFareID",     SqlDbType.Int, 4)
            };
            parameters[0].Value = model.ManageFareName;
            parameters[1].Value = model.ManageFarePrice;
            parameters[2].Value = model.ManageFareTypeID;
            parameters[3].Value = model.ReMark;
            parameters[4].Value = model.SystemNum;
            parameters[5].Value = model.ManageFareID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public WebDemo.Model.WebDemo.ManageFare GetModel(int ManageFareID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ManageFareID,ManageFareName,ManageFarePrice,ManageFareTypeID,ReMark,SystemNum from ManageFare ");
            strSql.Append(" where ManageFareID=@ManageFareID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ManageFareID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ManageFareID;

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

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