protected void btnadd_Click(object sender, EventArgs e) { SysLogBll.Create("鉴证书打印再次申请", "鉴证书打印再次申请", adminUser.AdminName); NCPEP.Bll.T_Dysq bll = new NCPEP.Bll.T_Dysq(); NCPEP.Model.T_Dysq model = new NCPEP.Model.T_Dysq(); DataTable dt = bll.GetList(" fid='" + Request.QueryString["p"] + "'").Tables[0]; model.fid = Request.QueryString["p"]; model.dysqnr = this.txtbeizhu.Value.Trim(); model.dysqsj = DateTime.Now.ToString(); model.dyzt = "1"; model.dycs = Convert.ToString(dt.Rows.Count + 1); //int id = (int)dal.Create(GetModels(context)); int id = bll.Add(model); if (id > 0) { NCPEP.Bll.T_Dyzt blldyzt = new NCPEP.Bll.T_Dyzt(); blldyzt.UpdateByBinid(Request.QueryString["p"], "2"); MessageBox.Show(this, "申请成功!"); this.btnadd.Visible = false; } else { MessageBox.Show(this, "更新失败!"); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(NCPEP.Model.T_Dysq model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update T_Dysq set "); strSql.Append("fid=@fid,"); strSql.Append("dycs=@dycs,"); strSql.Append("dysqnr=@dysqnr,"); strSql.Append("dysqsj=@dysqsj,"); strSql.Append("dyzt=@dyzt,"); strSql.Append("beiyong=@beiyong"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@fid", SqlDbType.VarChar, 50), new SqlParameter("@dycs", SqlDbType.VarChar, 50), new SqlParameter("@dysqnr", SqlDbType.VarChar, 500), new SqlParameter("@dysqsj", SqlDbType.VarChar, 50), new SqlParameter("@dyzt", SqlDbType.VarChar, 50), new SqlParameter("@beiyong", SqlDbType.VarChar, 50), new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = model.fid; parameters[1].Value = model.dycs; parameters[2].Value = model.dysqnr; parameters[3].Value = model.dysqsj; parameters[4].Value = model.dyzt; parameters[5].Value = model.beiyong; parameters[6].Value = model.id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(NCPEP.Model.T_Dysq model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into T_Dysq("); strSql.Append("fid,dycs,dysqnr,dysqsj,dyzt,beiyong)"); strSql.Append(" values ("); strSql.Append("@fid,@dycs,@dysqnr,@dysqsj,@dyzt,@beiyong)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@fid", SqlDbType.VarChar, 50), new SqlParameter("@dycs", SqlDbType.VarChar, 50), new SqlParameter("@dysqnr", SqlDbType.VarChar, 500), new SqlParameter("@dysqsj", SqlDbType.VarChar, 50), new SqlParameter("@dyzt", SqlDbType.VarChar, 50), new SqlParameter("@beiyong", SqlDbType.VarChar, 50) }; parameters[0].Value = model.fid; parameters[1].Value = model.dycs; parameters[2].Value = model.dysqnr; parameters[3].Value = model.dysqsj; parameters[4].Value = model.dyzt; parameters[5].Value = model.beiyong; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public NCPEP.Model.T_Dysq DataRowToModel(DataRow row) { NCPEP.Model.T_Dysq model = new NCPEP.Model.T_Dysq(); if (row != null) { if (row["id"] != null && row["id"].ToString() != "") { model.id = int.Parse(row["id"].ToString()); } if (row["fid"] != null) { model.fid = row["fid"].ToString(); } if (row["dycs"] != null) { model.dycs = row["dycs"].ToString(); } if (row["dysqnr"] != null) { model.dysqnr = row["dysqnr"].ToString(); } if (row["dysqsj"] != null) { model.dysqsj = row["dysqsj"].ToString(); } if (row["dyzt"] != null) { model.dyzt = row["dyzt"].ToString(); } if (row["beiyong"] != null) { model.beiyong = row["beiyong"].ToString(); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public NCPEP.Model.T_Dysq GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,fid,dycs,dysqnr,dysqsj,dyzt,beiyong from T_Dysq "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; NCPEP.Model.T_Dysq model = new NCPEP.Model.T_Dysq(); 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_Dysq model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(NCPEP.Model.T_Dysq model) { return(dal.Add(model)); }