private void ShowInfo(int ID) { WebDemo.BLL.WebDemo.AdjustPriceLog bll = new WebDemo.BLL.WebDemo.AdjustPriceLog(); WebDemo.Model.WebDemo.AdjustPriceLog model = bll.GetModel(ID); this.lblID.Text = model.ID.ToString(); this.txtPriceTypeID.Text = model.PriceTypeID.ToString(); this.txtExeDate.Text = model.ExeDate.ToString(); this.txtMark.Text = model.Mark.ToString(); this.txtDivid1.Text = model.Divid1.ToString(); this.txtDivid2.Text = model.Divid2.ToString(); this.txtDivid3.Text = model.Divid3.ToString(); this.txtDivid4.Text = model.Divid4.ToString(); this.txtDivid5.Text = model.Divid5.ToString(); this.txtFareID.Text = model.FareID.ToString(); this.txtFareTypeName.Text = model.FareTypeName; this.txtPrice.Text = model.Price.ToString(); this.txtPrice2.Text = model.Price2.ToString(); this.txtPrice3.Text = model.Price3.ToString(); this.txtPrice4.Text = model.Price4.ToString(); this.txtPrice5.Text = model.Price5.ToString(); this.txtPrice6.Text = model.Price6.ToString(); this.txtFareNo.Text = model.FareNo.ToString(); this.txtRemark.Text = model.Remark; this.txtPreFareTypeName.Text = model.PreFareTypeName; this.txtPrePrice.Text = model.PrePrice.ToString(); this.txtPrePrice2.Text = model.PrePrice2.ToString(); this.txtPrePrice3.Text = model.PrePrice3.ToString(); this.txtPrePrice4.Text = model.PrePrice4.ToString(); this.txtPrePrice5.Text = model.PrePrice5.ToString(); this.txtPrePrice6.Text = model.PrePrice6.ToString(); this.txtPreFareNo.Text = model.PreFareNo.ToString(); this.txtPreRemark.Text = model.PreRemark; this.txtSetNo.Text = model.SetNo.ToString(); this.txtFreezeDay.Text = model.FreezeDay.ToString(); }
/// <summary> /// 得到一个对象实体 /// </summary> public WebDemo.Model.WebDemo.AdjustPriceLog GetModel(int ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ID,PriceTypeID,ExeDate,Mark,Divid1,Divid2,Divid3,Divid4,Divid5,FareID,FareTypeName,Price,Price2,Price3,Price4,Price5,Price6,FareNo,Remark,PreFareTypeName,PrePrice,PrePrice2,PrePrice3,PrePrice4,PrePrice5,PrePrice6,PreFareNo,PreRemark,SetNo,FreezeDay from AdjustPriceLog "); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = ID; WebDemo.Model.WebDemo.AdjustPriceLog model = new WebDemo.Model.WebDemo.AdjustPriceLog(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public WebDemo.Model.WebDemo.AdjustPriceLog DataRowToModel(DataRow row) { WebDemo.Model.WebDemo.AdjustPriceLog model = new WebDemo.Model.WebDemo.AdjustPriceLog(); if (row != null) { if (row["ID"] != null && row["ID"].ToString() != "") { model.ID = int.Parse(row["ID"].ToString()); } if (row["PriceTypeID"] != null && row["PriceTypeID"].ToString() != "") { model.PriceTypeID = int.Parse(row["PriceTypeID"].ToString()); } if (row["ExeDate"] != null && row["ExeDate"].ToString() != "") { model.ExeDate = DateTime.Parse(row["ExeDate"].ToString()); } if (row["Mark"] != null && row["Mark"].ToString() != "") { model.Mark = int.Parse(row["Mark"].ToString()); } if (row["Divid1"] != null && row["Divid1"].ToString() != "") { model.Divid1 = int.Parse(row["Divid1"].ToString()); } if (row["Divid2"] != null && row["Divid2"].ToString() != "") { model.Divid2 = int.Parse(row["Divid2"].ToString()); } if (row["Divid3"] != null && row["Divid3"].ToString() != "") { model.Divid3 = int.Parse(row["Divid3"].ToString()); } if (row["Divid4"] != null && row["Divid4"].ToString() != "") { model.Divid4 = int.Parse(row["Divid4"].ToString()); } if (row["Divid5"] != null && row["Divid5"].ToString() != "") { model.Divid5 = int.Parse(row["Divid5"].ToString()); } if (row["FareID"] != null && row["FareID"].ToString() != "") { model.FareID = int.Parse(row["FareID"].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["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["FareNo"] != null && row["FareNo"].ToString() != "") { model.FareNo = int.Parse(row["FareNo"].ToString()); } if (row["Remark"] != null) { model.Remark = row["Remark"].ToString(); } if (row["PreFareTypeName"] != null) { model.PreFareTypeName = row["PreFareTypeName"].ToString(); } if (row["PrePrice"] != null && row["PrePrice"].ToString() != "") { model.PrePrice = decimal.Parse(row["PrePrice"].ToString()); } if (row["PrePrice2"] != null && row["PrePrice2"].ToString() != "") { model.PrePrice2 = decimal.Parse(row["PrePrice2"].ToString()); } if (row["PrePrice3"] != null && row["PrePrice3"].ToString() != "") { model.PrePrice3 = decimal.Parse(row["PrePrice3"].ToString()); } if (row["PrePrice4"] != null && row["PrePrice4"].ToString() != "") { model.PrePrice4 = decimal.Parse(row["PrePrice4"].ToString()); } if (row["PrePrice5"] != null && row["PrePrice5"].ToString() != "") { model.PrePrice5 = decimal.Parse(row["PrePrice5"].ToString()); } if (row["PrePrice6"] != null && row["PrePrice6"].ToString() != "") { model.PrePrice6 = decimal.Parse(row["PrePrice6"].ToString()); } if (row["PreFareNo"] != null && row["PreFareNo"].ToString() != "") { model.PreFareNo = int.Parse(row["PreFareNo"].ToString()); } if (row["PreRemark"] != null) { model.PreRemark = row["PreRemark"].ToString(); } if (row["SetNo"] != null && row["SetNo"].ToString() != "") { model.SetNo = int.Parse(row["SetNo"].ToString()); } if (row["FreezeDay"] != null && row["FreezeDay"].ToString() != "") { model.FreezeDay = int.Parse(row["FreezeDay"].ToString()); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(WebDemo.Model.WebDemo.AdjustPriceLog model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into AdjustPriceLog("); strSql.Append("PriceTypeID,ExeDate,Mark,Divid1,Divid2,Divid3,Divid4,Divid5,FareID,FareTypeName,Price,Price2,Price3,Price4,Price5,Price6,FareNo,Remark,PreFareTypeName,PrePrice,PrePrice2,PrePrice3,PrePrice4,PrePrice5,PrePrice6,PreFareNo,PreRemark,SetNo,FreezeDay)"); strSql.Append(" values ("); strSql.Append("@PriceTypeID,@ExeDate,@Mark,@Divid1,@Divid2,@Divid3,@Divid4,@Divid5,@FareID,@FareTypeName,@Price,@Price2,@Price3,@Price4,@Price5,@Price6,@FareNo,@Remark,@PreFareTypeName,@PrePrice,@PrePrice2,@PrePrice3,@PrePrice4,@PrePrice5,@PrePrice6,@PreFareNo,@PreRemark,@SetNo,@FreezeDay)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@PriceTypeID", SqlDbType.Int, 4), new SqlParameter("@ExeDate", SqlDbType.DateTime), new SqlParameter("@Mark", SqlDbType.Int, 4), new SqlParameter("@Divid1", SqlDbType.Int, 4), new SqlParameter("@Divid2", SqlDbType.Int, 4), new SqlParameter("@Divid3", SqlDbType.Int, 4), new SqlParameter("@Divid4", SqlDbType.Int, 4), new SqlParameter("@Divid5", SqlDbType.Int, 4), new SqlParameter("@FareID", SqlDbType.Int, 4), new SqlParameter("@FareTypeName", SqlDbType.VarChar, 20), new SqlParameter("@Price", SqlDbType.Decimal, 9), new SqlParameter("@Price2", SqlDbType.Decimal, 9), new SqlParameter("@Price3", SqlDbType.Decimal, 9), new SqlParameter("@Price4", SqlDbType.Decimal, 9), new SqlParameter("@Price5", SqlDbType.Decimal, 9), new SqlParameter("@Price6", SqlDbType.Decimal, 9), new SqlParameter("@FareNo", SqlDbType.Int, 4), new SqlParameter("@Remark", SqlDbType.VarChar, 200), new SqlParameter("@PreFareTypeName", SqlDbType.VarChar, 20), new SqlParameter("@PrePrice", SqlDbType.Decimal, 9), new SqlParameter("@PrePrice2", SqlDbType.Decimal, 9), new SqlParameter("@PrePrice3", SqlDbType.Decimal, 9), new SqlParameter("@PrePrice4", SqlDbType.Decimal, 9), new SqlParameter("@PrePrice5", SqlDbType.Decimal, 9), new SqlParameter("@PrePrice6", SqlDbType.Decimal, 9), new SqlParameter("@PreFareNo", SqlDbType.Int, 4), new SqlParameter("@PreRemark", SqlDbType.VarChar, 200), new SqlParameter("@SetNo", SqlDbType.Int, 4), new SqlParameter("@FreezeDay", SqlDbType.Int, 4) }; parameters[0].Value = model.PriceTypeID; parameters[1].Value = model.ExeDate; parameters[2].Value = model.Mark; parameters[3].Value = model.Divid1; parameters[4].Value = model.Divid2; parameters[5].Value = model.Divid3; parameters[6].Value = model.Divid4; parameters[7].Value = model.Divid5; parameters[8].Value = model.FareID; parameters[9].Value = model.FareTypeName; parameters[10].Value = model.Price; parameters[11].Value = model.Price2; parameters[12].Value = model.Price3; parameters[13].Value = model.Price4; parameters[14].Value = model.Price5; parameters[15].Value = model.Price6; parameters[16].Value = model.FareNo; parameters[17].Value = model.Remark; parameters[18].Value = model.PreFareTypeName; parameters[19].Value = model.PrePrice; parameters[20].Value = model.PrePrice2; parameters[21].Value = model.PrePrice3; parameters[22].Value = model.PrePrice4; parameters[23].Value = model.PrePrice5; parameters[24].Value = model.PrePrice6; parameters[25].Value = model.PreFareNo; parameters[26].Value = model.PreRemark; parameters[27].Value = model.SetNo; parameters[28].Value = model.FreezeDay; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(WebDemo.Model.WebDemo.AdjustPriceLog model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update AdjustPriceLog set "); strSql.Append("PriceTypeID=@PriceTypeID,"); strSql.Append("ExeDate=@ExeDate,"); strSql.Append("Mark=@Mark,"); strSql.Append("Divid1=@Divid1,"); strSql.Append("Divid2=@Divid2,"); strSql.Append("Divid3=@Divid3,"); strSql.Append("Divid4=@Divid4,"); strSql.Append("Divid5=@Divid5,"); strSql.Append("FareID=@FareID,"); strSql.Append("FareTypeName=@FareTypeName,"); strSql.Append("Price=@Price,"); strSql.Append("Price2=@Price2,"); strSql.Append("Price3=@Price3,"); strSql.Append("Price4=@Price4,"); strSql.Append("Price5=@Price5,"); strSql.Append("Price6=@Price6,"); strSql.Append("FareNo=@FareNo,"); strSql.Append("Remark=@Remark,"); strSql.Append("PreFareTypeName=@PreFareTypeName,"); strSql.Append("PrePrice=@PrePrice,"); strSql.Append("PrePrice2=@PrePrice2,"); strSql.Append("PrePrice3=@PrePrice3,"); strSql.Append("PrePrice4=@PrePrice4,"); strSql.Append("PrePrice5=@PrePrice5,"); strSql.Append("PrePrice6=@PrePrice6,"); strSql.Append("PreFareNo=@PreFareNo,"); strSql.Append("PreRemark=@PreRemark,"); strSql.Append("SetNo=@SetNo,"); strSql.Append("FreezeDay=@FreezeDay"); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@PriceTypeID", SqlDbType.Int, 4), new SqlParameter("@ExeDate", SqlDbType.DateTime), new SqlParameter("@Mark", SqlDbType.Int, 4), new SqlParameter("@Divid1", SqlDbType.Int, 4), new SqlParameter("@Divid2", SqlDbType.Int, 4), new SqlParameter("@Divid3", SqlDbType.Int, 4), new SqlParameter("@Divid4", SqlDbType.Int, 4), new SqlParameter("@Divid5", SqlDbType.Int, 4), new SqlParameter("@FareID", SqlDbType.Int, 4), new SqlParameter("@FareTypeName", SqlDbType.VarChar, 20), new SqlParameter("@Price", SqlDbType.Decimal, 9), new SqlParameter("@Price2", SqlDbType.Decimal, 9), new SqlParameter("@Price3", SqlDbType.Decimal, 9), new SqlParameter("@Price4", SqlDbType.Decimal, 9), new SqlParameter("@Price5", SqlDbType.Decimal, 9), new SqlParameter("@Price6", SqlDbType.Decimal, 9), new SqlParameter("@FareNo", SqlDbType.Int, 4), new SqlParameter("@Remark", SqlDbType.VarChar, 200), new SqlParameter("@PreFareTypeName", SqlDbType.VarChar, 20), new SqlParameter("@PrePrice", SqlDbType.Decimal, 9), new SqlParameter("@PrePrice2", SqlDbType.Decimal, 9), new SqlParameter("@PrePrice3", SqlDbType.Decimal, 9), new SqlParameter("@PrePrice4", SqlDbType.Decimal, 9), new SqlParameter("@PrePrice5", SqlDbType.Decimal, 9), new SqlParameter("@PrePrice6", SqlDbType.Decimal, 9), new SqlParameter("@PreFareNo", SqlDbType.Int, 4), new SqlParameter("@PreRemark", SqlDbType.VarChar, 200), new SqlParameter("@SetNo", SqlDbType.Int, 4), new SqlParameter("@FreezeDay", SqlDbType.Int, 4), new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = model.PriceTypeID; parameters[1].Value = model.ExeDate; parameters[2].Value = model.Mark; parameters[3].Value = model.Divid1; parameters[4].Value = model.Divid2; parameters[5].Value = model.Divid3; parameters[6].Value = model.Divid4; parameters[7].Value = model.Divid5; parameters[8].Value = model.FareID; parameters[9].Value = model.FareTypeName; parameters[10].Value = model.Price; parameters[11].Value = model.Price2; parameters[12].Value = model.Price3; parameters[13].Value = model.Price4; parameters[14].Value = model.Price5; parameters[15].Value = model.Price6; parameters[16].Value = model.FareNo; parameters[17].Value = model.Remark; parameters[18].Value = model.PreFareTypeName; parameters[19].Value = model.PrePrice; parameters[20].Value = model.PrePrice2; parameters[21].Value = model.PrePrice3; parameters[22].Value = model.PrePrice4; parameters[23].Value = model.PrePrice5; parameters[24].Value = model.PrePrice6; parameters[25].Value = model.PreFareNo; parameters[26].Value = model.PreRemark; parameters[27].Value = model.SetNo; parameters[28].Value = model.FreezeDay; parameters[29].Value = model.ID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
public void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (!PageValidate.IsNumber(txtPriceTypeID.Text)) { strErr += "PriceTypeID格式错误!\\n"; } if (!PageValidate.IsDateTime(txtExeDate.Text)) { strErr += "ExeDate格式错误!\\n"; } if (!PageValidate.IsNumber(txtMark.Text)) { strErr += "Mark格式错误!\\n"; } if (!PageValidate.IsNumber(txtDivid1.Text)) { strErr += "Divid1格式错误!\\n"; } if (!PageValidate.IsNumber(txtDivid2.Text)) { strErr += "Divid2格式错误!\\n"; } if (!PageValidate.IsNumber(txtDivid3.Text)) { strErr += "Divid3格式错误!\\n"; } if (!PageValidate.IsNumber(txtDivid4.Text)) { strErr += "Divid4格式错误!\\n"; } if (!PageValidate.IsNumber(txtDivid5.Text)) { strErr += "Divid5格式错误!\\n"; } if (!PageValidate.IsNumber(txtFareID.Text)) { strErr += "FareID格式错误!\\n"; } if (this.txtFareTypeName.Text.Trim().Length == 0) { strErr += "FareTypeName不能为空!\\n"; } if (!PageValidate.IsDecimal(txtPrice.Text)) { strErr += "Price格式错误!\\n"; } if (!PageValidate.IsDecimal(txtPrice2.Text)) { strErr += "Price2格式错误!\\n"; } if (!PageValidate.IsDecimal(txtPrice3.Text)) { strErr += "Price3格式错误!\\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.IsNumber(txtFareNo.Text)) { strErr += "FareNo格式错误!\\n"; } if (this.txtRemark.Text.Trim().Length == 0) { strErr += "Remark不能为空!\\n"; } if (this.txtPreFareTypeName.Text.Trim().Length == 0) { strErr += "PreFareTypeName不能为空!\\n"; } if (!PageValidate.IsDecimal(txtPrePrice.Text)) { strErr += "PrePrice格式错误!\\n"; } if (!PageValidate.IsDecimal(txtPrePrice2.Text)) { strErr += "PrePrice2格式错误!\\n"; } if (!PageValidate.IsDecimal(txtPrePrice3.Text)) { strErr += "PrePrice3格式错误!\\n"; } if (!PageValidate.IsDecimal(txtPrePrice4.Text)) { strErr += "PrePrice4格式错误!\\n"; } if (!PageValidate.IsDecimal(txtPrePrice5.Text)) { strErr += "PrePrice5格式错误!\\n"; } if (!PageValidate.IsDecimal(txtPrePrice6.Text)) { strErr += "PrePrice6格式错误!\\n"; } if (!PageValidate.IsNumber(txtPreFareNo.Text)) { strErr += "PreFareNo格式错误!\\n"; } if (this.txtPreRemark.Text.Trim().Length == 0) { strErr += "PreRemark不能为空!\\n"; } if (!PageValidate.IsNumber(txtSetNo.Text)) { strErr += "SetNo格式错误!\\n"; } if (!PageValidate.IsNumber(txtFreezeDay.Text)) { strErr += "FreezeDay格式错误!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } int ID = int.Parse(this.lblID.Text); int PriceTypeID = int.Parse(this.txtPriceTypeID.Text); DateTime ExeDate = DateTime.Parse(this.txtExeDate.Text); int Mark = int.Parse(this.txtMark.Text); int Divid1 = int.Parse(this.txtDivid1.Text); int Divid2 = int.Parse(this.txtDivid2.Text); int Divid3 = int.Parse(this.txtDivid3.Text); int Divid4 = int.Parse(this.txtDivid4.Text); int Divid5 = int.Parse(this.txtDivid5.Text); int FareID = int.Parse(this.txtFareID.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); decimal Price4 = decimal.Parse(this.txtPrice4.Text); decimal Price5 = decimal.Parse(this.txtPrice5.Text); decimal Price6 = decimal.Parse(this.txtPrice6.Text); int FareNo = int.Parse(this.txtFareNo.Text); string Remark = this.txtRemark.Text; string PreFareTypeName = this.txtPreFareTypeName.Text; decimal PrePrice = decimal.Parse(this.txtPrePrice.Text); decimal PrePrice2 = decimal.Parse(this.txtPrePrice2.Text); decimal PrePrice3 = decimal.Parse(this.txtPrePrice3.Text); decimal PrePrice4 = decimal.Parse(this.txtPrePrice4.Text); decimal PrePrice5 = decimal.Parse(this.txtPrePrice5.Text); decimal PrePrice6 = decimal.Parse(this.txtPrePrice6.Text); int PreFareNo = int.Parse(this.txtPreFareNo.Text); string PreRemark = this.txtPreRemark.Text; int SetNo = int.Parse(this.txtSetNo.Text); int FreezeDay = int.Parse(this.txtFreezeDay.Text); WebDemo.Model.WebDemo.AdjustPriceLog model = new WebDemo.Model.WebDemo.AdjustPriceLog(); model.ID = ID; model.PriceTypeID = PriceTypeID; model.ExeDate = ExeDate; model.Mark = Mark; model.Divid1 = Divid1; model.Divid2 = Divid2; model.Divid3 = Divid3; model.Divid4 = Divid4; model.Divid5 = Divid5; model.FareID = FareID; model.FareTypeName = FareTypeName; model.Price = Price; model.Price2 = Price2; model.Price3 = Price3; model.Price4 = Price4; model.Price5 = Price5; model.Price6 = Price6; model.FareNo = FareNo; model.Remark = Remark; model.PreFareTypeName = PreFareTypeName; model.PrePrice = PrePrice; model.PrePrice2 = PrePrice2; model.PrePrice3 = PrePrice3; model.PrePrice4 = PrePrice4; model.PrePrice5 = PrePrice5; model.PrePrice6 = PrePrice6; model.PreFareNo = PreFareNo; model.PreRemark = PreRemark; model.SetNo = SetNo; model.FreezeDay = FreezeDay; WebDemo.BLL.WebDemo.AdjustPriceLog bll = new WebDemo.BLL.WebDemo.AdjustPriceLog(); bll.Update(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx"); }