Пример #1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public WebDemo.Model.WebDemo.PriceFare DataRowToModel(DataRow row)
 {
     WebDemo.Model.WebDemo.PriceFare model = new WebDemo.Model.WebDemo.PriceFare();
     if (row != null)
     {
         if (row["FareID"] != null && row["FareID"].ToString() != "")
         {
             model.FareID = int.Parse(row["FareID"].ToString());
         }
         if (row["PriceTypeID"] != null && row["PriceTypeID"].ToString() != "")
         {
             model.PriceTypeID = int.Parse(row["PriceTypeID"].ToString());
         }
         if (row["FareTypeName"] != null)
         {
             model.FareTypeName = row["FareTypeName"].ToString();
         }
         if (row["Price"] != null && row["Price"].ToString() != "")
         {
             model.Price = decimal.Parse(row["Price"].ToString());
         }
         if (row["Price2"] != null && row["Price2"].ToString() != "")
         {
             model.Price2 = decimal.Parse(row["Price2"].ToString());
         }
         if (row["Price3"] != null && row["Price3"].ToString() != "")
         {
             model.Price3 = decimal.Parse(row["Price3"].ToString());
         }
         if (row["FareNo"] != null && row["FareNo"].ToString() != "")
         {
             model.FareNo = int.Parse(row["FareNo"].ToString());
         }
         if (row["ReMark"] != null)
         {
             model.ReMark = row["ReMark"].ToString();
         }
         if (row["Price4"] != null && row["Price4"].ToString() != "")
         {
             model.Price4 = decimal.Parse(row["Price4"].ToString());
         }
         if (row["Price5"] != null && row["Price5"].ToString() != "")
         {
             model.Price5 = decimal.Parse(row["Price5"].ToString());
         }
         if (row["Price6"] != null && row["Price6"].ToString() != "")
         {
             model.Price6 = decimal.Parse(row["Price6"].ToString());
         }
         if (row["TaxRate"] != null && row["TaxRate"].ToString() != "")
         {
             model.TaxRate = decimal.Parse(row["TaxRate"].ToString());
         }
         if (row["ProjectName"] != null)
         {
             model.ProjectName = row["ProjectName"].ToString();
         }
     }
     return(model);
 }
Пример #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(WebDemo.Model.WebDemo.PriceFare model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update PriceFare set ");
            strSql.Append("PriceTypeID=@PriceTypeID,");
            strSql.Append("FareTypeName=@FareTypeName,");
            strSql.Append("Price=@Price,");
            strSql.Append("Price2=@Price2,");
            strSql.Append("Price3=@Price3,");
            strSql.Append("FareNo=@FareNo,");
            strSql.Append("ReMark=@ReMark,");
            strSql.Append("Price4=@Price4,");
            strSql.Append("Price5=@Price5,");
            strSql.Append("Price6=@Price6,");
            strSql.Append("TaxRate=@TaxRate,");
            strSql.Append("ProjectName=@ProjectName");
            strSql.Append(" where FareID=@FareID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@PriceTypeID",  SqlDbType.Int,        4),
                new SqlParameter("@FareTypeName", SqlDbType.VarChar,   50),
                new SqlParameter("@Price",        SqlDbType.Decimal,    9),
                new SqlParameter("@Price2",       SqlDbType.Decimal,    9),
                new SqlParameter("@Price3",       SqlDbType.Decimal,    9),
                new SqlParameter("@FareNo",       SqlDbType.Int,        4),
                new SqlParameter("@ReMark",       SqlDbType.VarChar,  200),
                new SqlParameter("@Price4",       SqlDbType.Decimal,    9),
                new SqlParameter("@Price5",       SqlDbType.Decimal,    9),
                new SqlParameter("@Price6",       SqlDbType.Decimal,    9),
                new SqlParameter("@TaxRate",      SqlDbType.Decimal,    9),
                new SqlParameter("@ProjectName",  SqlDbType.NVarChar,  90),
                new SqlParameter("@FareID",       SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.PriceTypeID;
            parameters[1].Value  = model.FareTypeName;
            parameters[2].Value  = model.Price;
            parameters[3].Value  = model.Price2;
            parameters[4].Value  = model.Price3;
            parameters[5].Value  = model.FareNo;
            parameters[6].Value  = model.ReMark;
            parameters[7].Value  = model.Price4;
            parameters[8].Value  = model.Price5;
            parameters[9].Value  = model.Price6;
            parameters[10].Value = model.TaxRate;
            parameters[11].Value = model.ProjectName;
            parameters[12].Value = model.FareID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(WebDemo.Model.WebDemo.PriceFare model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into PriceFare(");
            strSql.Append("PriceTypeID,FareTypeName,Price,Price2,Price3,FareNo,ReMark,Price4,Price5,Price6,TaxRate,ProjectName)");
            strSql.Append(" values (");
            strSql.Append("@PriceTypeID,@FareTypeName,@Price,@Price2,@Price3,@FareNo,@ReMark,@Price4,@Price5,@Price6,@TaxRate,@ProjectName)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@PriceTypeID",  SqlDbType.Int,        4),
                new SqlParameter("@FareTypeName", SqlDbType.VarChar,   50),
                new SqlParameter("@Price",        SqlDbType.Decimal,    9),
                new SqlParameter("@Price2",       SqlDbType.Decimal,    9),
                new SqlParameter("@Price3",       SqlDbType.Decimal,    9),
                new SqlParameter("@FareNo",       SqlDbType.Int,        4),
                new SqlParameter("@ReMark",       SqlDbType.VarChar,  200),
                new SqlParameter("@Price4",       SqlDbType.Decimal,    9),
                new SqlParameter("@Price5",       SqlDbType.Decimal,    9),
                new SqlParameter("@Price6",       SqlDbType.Decimal,    9),
                new SqlParameter("@TaxRate",      SqlDbType.Decimal,    9),
                new SqlParameter("@ProjectName",  SqlDbType.NVarChar, 90)
            };
            parameters[0].Value  = model.PriceTypeID;
            parameters[1].Value  = model.FareTypeName;
            parameters[2].Value  = model.Price;
            parameters[3].Value  = model.Price2;
            parameters[4].Value  = model.Price3;
            parameters[5].Value  = model.FareNo;
            parameters[6].Value  = model.ReMark;
            parameters[7].Value  = model.Price4;
            parameters[8].Value  = model.Price5;
            parameters[9].Value  = model.Price6;
            parameters[10].Value = model.TaxRate;
            parameters[11].Value = model.ProjectName;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Пример #4
0
 private void ShowInfo(int FareID)
 {
     WebDemo.BLL.WebDemo.PriceFare   bll   = new WebDemo.BLL.WebDemo.PriceFare();
     WebDemo.Model.WebDemo.PriceFare model = bll.GetModel(FareID);
     this.lblFareID.Text       = model.FareID.ToString();
     this.lblPriceTypeID.Text  = model.PriceTypeID.ToString();
     this.lblFareTypeName.Text = model.FareTypeName;
     this.lblPrice.Text        = model.Price.ToString();
     this.lblPrice2.Text       = model.Price2.ToString();
     this.lblPrice3.Text       = model.Price3.ToString();
     this.lblFareNo.Text       = model.FareNo.ToString();
     this.lblReMark.Text       = model.ReMark;
     this.lblPrice4.Text       = model.Price4.ToString();
     this.lblPrice5.Text       = model.Price5.ToString();
     this.lblPrice6.Text       = model.Price6.ToString();
     this.lblTaxRate.Text      = model.TaxRate.ToString();
     this.lblProjectName.Text  = model.ProjectName;
 }
Пример #5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public WebDemo.Model.WebDemo.PriceFare GetModel(int FareID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 FareID,PriceTypeID,FareTypeName,Price,Price2,Price3,FareNo,ReMark,Price4,Price5,Price6,TaxRate,ProjectName from PriceFare ");
            strSql.Append(" where FareID=@FareID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@FareID", SqlDbType.Int, 4)
            };
            parameters[0].Value = FareID;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Пример #6
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (!PageValidate.IsNumber(txtPriceTypeID.Text))
            {
                strErr += "PriceTypeID格式错误!\\n";
            }
            if (this.txtFareTypeName.Text.Trim().Length == 0)
            {
                strErr += "费用名称不能为空!\\n";
            }
            if (!PageValidate.IsDecimal(txtPrice.Text))
            {
                strErr += "单价格式错误!\\n";
            }
            if (!PageValidate.IsDecimal(txtPrice2.Text))
            {
                strErr += "Price2格式错误!\\n";
            }
            if (!PageValidate.IsDecimal(txtPrice3.Text))
            {
                strErr += "Price3格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtFareNo.Text))
            {
                strErr += "FareNo格式错误!\\n";
            }
            if (this.txtReMark.Text.Trim().Length == 0)
            {
                strErr += "ReMark不能为空!\\n";
            }
            if (!PageValidate.IsDecimal(txtPrice4.Text))
            {
                strErr += "Price4格式错误!\\n";
            }
            if (!PageValidate.IsDecimal(txtPrice5.Text))
            {
                strErr += "Price5格式错误!\\n";
            }
            if (!PageValidate.IsDecimal(txtPrice6.Text))
            {
                strErr += "Price6格式错误!\\n";
            }
            if (!PageValidate.IsDecimal(txtTaxRate.Text))
            {
                strErr += "TaxRate格式错误!\\n";
            }
            if (this.txtProjectName.Text.Trim().Length == 0)
            {
                strErr += "ProjectName不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int     FareID       = int.Parse(this.lblFareID.Text);
            int     PriceTypeID  = int.Parse(this.txtPriceTypeID.Text);
            string  FareTypeName = this.txtFareTypeName.Text;
            decimal Price        = decimal.Parse(this.txtPrice.Text);
            decimal Price2       = decimal.Parse(this.txtPrice2.Text);
            decimal Price3       = decimal.Parse(this.txtPrice3.Text);
            int     FareNo       = int.Parse(this.txtFareNo.Text);
            string  ReMark       = this.txtReMark.Text;
            decimal Price4       = decimal.Parse(this.txtPrice4.Text);
            decimal Price5       = decimal.Parse(this.txtPrice5.Text);
            decimal Price6       = decimal.Parse(this.txtPrice6.Text);
            decimal TaxRate      = decimal.Parse(this.txtTaxRate.Text);
            string  ProjectName  = this.txtProjectName.Text;


            WebDemo.Model.WebDemo.PriceFare model = new WebDemo.Model.WebDemo.PriceFare();
            model.FareID       = FareID;
            model.PriceTypeID  = PriceTypeID;
            model.FareTypeName = FareTypeName;
            model.Price        = Price;
            model.Price2       = Price2;
            model.Price3       = Price3;
            model.FareNo       = FareNo;
            model.ReMark       = ReMark;
            model.Price4       = Price4;
            model.Price5       = Price5;
            model.Price6       = Price6;
            model.TaxRate      = TaxRate;
            model.ProjectName  = ProjectName;

            WebDemo.BLL.WebDemo.PriceFare bll = new WebDemo.BLL.WebDemo.PriceFare();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }