//保存 protected void btnSave_Click(object sender, EventArgs e) { ShowShop.Model.Admin.AdminInfo adminInfo = (ShowShop.Model.Admin.AdminInfo)ShowShop.Common.AdministrorManager.Get(); ShowShop.Model.SystemInfo.TerraceManage terrace = new ShowShop.Model.SystemInfo.TerraceManage(); int id = ChangeHope.WebPage.PageRequest.GetQueryInt("Payment_ID"); terrace.Tmname = this.txtName.Text.Trim().ToString(); terrace.Tmseller = this.txtSellerId.Text.Trim().ToString(); terrace.Tmgarden = Convert.ToInt32(this.SelPayment.Value); terrace.Tmexpenses = Convert.ToDecimal(this.txtExpenses.Text); terrace.Payment_description = this.txtPaymentDesc.Text.Trim().ToString(); if(this.SelPayment.Value=="1" || this.SelPayment.Value=="3") { terrace.Tmkey = this.txtKey.Text.Trim().ToString(); terrace.Tmaccount = this.txtAccount.Text.Trim().ToString(); terrace.Tmtaxis = Convert.ToInt32(this.txtTaxis.Text.Trim()); terrace.Tmsetup = Convert.ToInt32(this.RdlSetup.SelectedValue); } else if(this.SelPayment.Value=="2") { terrace.Porttype = this.ddlPortType.SelectedValue; terrace.Tmkey = this.txtKey.Text.Trim().ToString(); terrace.Tmaccount = this.txtAccount.Text.Trim().ToString(); terrace.Tmtaxis = Convert.ToInt32(this.txtTaxis.Text.Trim()); terrace.Tmsetup = Convert.ToInt32(this.RdlSetup.SelectedValue); } terrace.Tmputoutid = ViewState["PutoutID"] == null ? 0 : Convert.ToInt32(ViewState["PutoutID"].ToString()); terrace.Tmputouttypeid = ViewState["PutoutTypeID"] == null ? 0 : Convert.ToInt32(ViewState["PutoutTypeID"].ToString()); if (Request["Payment_ID"] != null && Request["Payment_ID"] != "") { terrace.Tmid = Convert.ToInt32(Request.QueryString["Payment_ID"]); terraceBll.Update(terrace); ChangeHope.WebPage.BasePage.PageRight("操作成功,已修改该信息", "paymentmanage_list.aspx"); } else { int count = terraceBll.Add(terrace); if (count > 0) { ChangeHope.WebPage.BasePage.PageRight("操作成功,已保存该信息", "paymentmanage_edit.aspx?paytype=" + terrace.Tmgarden.ToString()); } } }
public ShowShop.Model.SystemInfo.TerraceManage GetModelByName(string name) { StringBuilder strSql = new StringBuilder(); strSql.Append("Select top 1 [payment_id], [payment_seller], [payment_key], [payment_expenses],[payment_setup],[payment_name],[payment_garden],[payment_putoutid],[payment_putouttypeid],[payment_taxis],[payment_account] From [yxs_paymentmanage] "); strSql.Append("Where [payment_name]=@name"); SqlParameter[] parameters ={ new SqlParameter("@name",SqlDbType.VarChar,50) }; parameters[0].Value = name; ShowShop.Model.SystemInfo.TerraceManage terrace = null; using (SqlDataReader reader = ChangeHope.DataBase.SQLServerHelper.ExecuteReader(strSql.ToString(), parameters)) { while (reader.Read()) { terrace = new ShowShop.Model.SystemInfo.TerraceManage(); terrace.Tmid = (int)reader["payment_id"]; terrace.Tmseller = (string)reader["payment_seller"]; terrace.Tmkey = (string)reader["payment_key"]; terrace.Tmexpenses = Convert.ToDecimal(reader["payment_expenses"]); terrace.Tmsetup = Convert.ToInt32(reader["payment_setup"]); terrace.Tmname = (string)reader["payment_name"]; terrace.Tmgarden = (int)reader["payment_garden"]; terrace.Tmputoutid = (int)reader["payment_putoutid"]; terrace.Tmputouttypeid = (int)reader["payment_putouttypeid"]; terrace.Tmtaxis = (int)reader["payment_taxis"]; terrace.Tmaccount = (string)reader["payment_account"]; } } return terrace; }
/// <summary> /// 根据ID得实体 /// </summary> /// <param name="id"></param> /// <returns></returns> public ShowShop.Model.SystemInfo.TerraceManage GetModelById(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("Select top 1 [payment_id], [payment_seller], [payment_key], [payment_expenses],[payment_setup],[payment_name],[payment_garden],[payment_putoutid],[payment_putouttypeid],[payment_taxis],[payment_account],[payment_description],[porttype] From [yxs_paymentmanage] "); strSql.Append("Where [payment_id]=@TM_ID"); SqlParameter[] parameters={ new SqlParameter("@TM_ID",SqlDbType.Int,4) }; parameters[0].Value = id; ShowShop.Model.SystemInfo.TerraceManage terrace = null; using(SqlDataReader reader=ChangeHope.DataBase.SQLServerHelper.ExecuteReader(strSql.ToString(),parameters)){ while(reader.Read()){ terrace = new ShowShop.Model.SystemInfo.TerraceManage(); terrace.Tmid = reader["payment_id"] != DBNull.Value ? (int)reader["payment_id"] : 0; terrace.Tmseller = reader["payment_seller"] != DBNull.Value? (string)reader["payment_seller"] : "无"; terrace.Tmkey = reader["payment_key"] != DBNull.Value ? (string)reader["payment_key"] : "无"; terrace.Tmexpenses = reader["payment_expenses"] != DBNull.Value ? Convert.ToDecimal(reader["payment_expenses"]) : 0; terrace.Tmsetup = reader["payment_setup"] != DBNull.Value ? Convert.ToInt32(reader["payment_setup"]) : 0; terrace.Tmname = reader["payment_name"] != DBNull.Value ? (string)reader["payment_name"] : "无"; terrace.Tmgarden = reader["payment_garden"] != DBNull.Value ? (int)reader["payment_garden"] : 0; terrace.Tmputoutid = reader["payment_putoutid"] != DBNull.Value ? (int)reader["payment_putoutid"] : 0; terrace.Tmputouttypeid = reader["payment_putouttypeid"] != DBNull.Value ? (int)reader["payment_putouttypeid"] : 0; terrace.Tmtaxis = reader["payment_taxis"] != DBNull.Value ? (int)reader["payment_taxis"] : 0; terrace.Tmaccount = reader["payment_account"] != DBNull.Value ? (string)reader["payment_account"] : "无"; terrace.Payment_description = reader["payment_description"] != DBNull.Value ? (string)reader["payment_description"] : "暂无描述"; terrace.Porttype = reader["porttype"] != DBNull.Value ? (string)reader["porttype"] : "无"; } } return terrace; }