protected void btnsave_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.txtjingjiajg.Text)) { MessageBox.Show(this, "请填写竞拍价格!"); return; } else { decimal jbjg; try { jbjg = decimal.Parse(this.txtjingjiajg.Text); } catch { MessageBox.Show(this, "竞拍价格请填写数字"); return; } decimal jbdj = decimal.Parse(this.lbdijia.Text); if (jbdj > jbjg) { MessageBox.Show(this, "竞拍价格必须大于起价"); return; } DateTime dtjzsj = DateTime.Parse(this.lbjzsj.Text); if (DateTime.Now > dtjzsj) { MessageBox.Show(this, "竞价截止时间已到,不能继续竞价!"); return; } NCPEP.Model.T_JBTWO jbmodel = new NCPEP.Model.T_JBTWO(); jbmodel.bid = Request.QueryString["st"]; jbmodel.jbbs = "0"; jbmodel.jbdj = this.lbdijia.Text; jbmodel.jbjg = this.txtjingjiajg.Text; NCPEP.Model.T_LiceTran tmodel = new NCPEP.Model.T_LiceTran(); tmodel = Session["jbyhm"] as NCPEP.Model.T_LiceTran; jbmodel.jbyhm = tmodel.JBYhm; jbmodel.tid = tmodel.Id.ToString(); jbmodel.zbzt = "0"; jbmodel.jbbs = "1"; NCPEP.Bll.T_JBTWO jbbll = new NCPEP.Bll.T_JBTWO(); DataTable dt = jbbll.GetList(" jbbs='1' and bid='" + Request.QueryString["st"] + "' and tid='" + tmodel.Id + "' and jbyhm='" + tmodel.JBYhm + "'").Tables[0]; if (dt.Rows.Count > 0) { foreach (DataRow item in dt.Rows) { jbbll.Delete(int.Parse(item["sid"].ToString())); } } if (jbbll.Add(jbmodel) > 0) { MessageBox.ShowAndRedirect(this, "竞价成功!", "jbtwo-user.aspx"); return; } else { MessageBox.Show(this, "竞价失败!请联系管理员"); return; } } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(NCPEP.Model.T_JBTWO model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update T_JBTWO set "); strSql.Append("bid=@bid,"); strSql.Append("tid=@tid,"); strSql.Append("jbyhm=@jbyhm,"); strSql.Append("jbjg=@jbjg,"); strSql.Append("jbdj=@jbdj,"); strSql.Append("zbzt=@zbzt,"); strSql.Append("beizhu=@beizhu,"); strSql.Append("jbbs=@jbbs"); strSql.Append(" where sid=@sid"); SqlParameter[] parameters = { new SqlParameter("@bid", SqlDbType.VarChar, 50), new SqlParameter("@tid", SqlDbType.VarChar, 50), new SqlParameter("@jbyhm", SqlDbType.NVarChar, 50), new SqlParameter("@jbjg", SqlDbType.NVarChar, 50), new SqlParameter("@jbdj", SqlDbType.NVarChar, 50), new SqlParameter("@zbzt", SqlDbType.NVarChar, 50), new SqlParameter("@beizhu", SqlDbType.NVarChar, 50), new SqlParameter("@jbbs", SqlDbType.NVarChar, 50), new SqlParameter("@sid", SqlDbType.Int, 4) }; parameters[0].Value = model.bid; parameters[1].Value = model.tid; parameters[2].Value = model.jbyhm; parameters[3].Value = model.jbjg; parameters[4].Value = model.jbdj; parameters[5].Value = model.zbzt; parameters[6].Value = model.beizhu; parameters[7].Value = model.jbbs; parameters[8].Value = model.sid; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public NCPEP.Model.T_JBTWO DataRowToModel(DataRow row) { NCPEP.Model.T_JBTWO model = new NCPEP.Model.T_JBTWO(); if (row != null) { if (row["sid"] != null && row["sid"].ToString() != "") { model.sid = int.Parse(row["sid"].ToString()); } if (row["bid"] != null) { model.bid = row["bid"].ToString(); } if (row["tid"] != null) { model.tid = row["tid"].ToString(); } if (row["jbyhm"] != null) { model.jbyhm = row["jbyhm"].ToString(); } if (row["jbjg"] != null) { model.jbjg = row["jbjg"].ToString(); } if (row["jbdj"] != null) { model.jbdj = row["jbdj"].ToString(); } if (row["zbzt"] != null) { model.zbzt = row["zbzt"].ToString(); } if (row["beizhu"] != null) { model.beizhu = row["beizhu"].ToString(); } if (row["jbbs"] != null) { model.jbbs = row["jbbs"].ToString(); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(NCPEP.Model.T_JBTWO model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into T_JBTWO("); strSql.Append("bid,tid,jbyhm,jbjg,jbdj,zbzt,beizhu,jbbs)"); strSql.Append(" values ("); strSql.Append("@bid,@tid,@jbyhm,@jbjg,@jbdj,@zbzt,@beizhu,@jbbs)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@bid", SqlDbType.VarChar, 50), new SqlParameter("@tid", SqlDbType.VarChar, 50), new SqlParameter("@jbyhm", SqlDbType.NVarChar, 50), new SqlParameter("@jbjg", SqlDbType.NVarChar, 50), new SqlParameter("@jbdj", SqlDbType.NVarChar, 50), new SqlParameter("@zbzt", SqlDbType.NVarChar, 50), new SqlParameter("@beizhu", SqlDbType.NVarChar, 50), new SqlParameter("@jbbs", SqlDbType.NVarChar, 50) }; parameters[0].Value = model.bid; parameters[1].Value = model.tid; parameters[2].Value = model.jbyhm; parameters[3].Value = model.jbjg; parameters[4].Value = model.jbdj; parameters[5].Value = model.zbzt; parameters[6].Value = model.beizhu; parameters[7].Value = model.jbbs; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public NCPEP.Model.T_JBTWO GetModel(int sid) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 sid,bid,tid,jbyhm,jbjg,jbdj,zbzt,beizhu,jbbs from T_JBTWO "); strSql.Append(" where sid=@sid"); SqlParameter[] parameters = { new SqlParameter("@sid", SqlDbType.Int, 4) }; parameters[0].Value = sid; NCPEP.Model.T_JBTWO model = new NCPEP.Model.T_JBTWO(); 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 bool Update(NCPEP.Model.T_JBTWO model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(NCPEP.Model.T_JBTWO model) { return(dal.Add(model)); }