/// <summary> /// 增加一条数据 /// </summary> public int Add(Tunnel.Model.Tunnel_Standard model) { int rowsAffected; SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 8), new SqlParameter("@S_File", SqlDbType.VarChar, 200), new SqlParameter("@S_Title", SqlDbType.VarChar, 200), new SqlParameter("@S_Name", SqlDbType.VarChar, 100), new SqlParameter("@CreateDate", SqlDbType.DateTime), new SqlParameter("@CreateUser", SqlDbType.Int, 4), new SqlParameter("@S_bum", SqlDbType.Int, 4), }; parameters[0].Direction = ParameterDirection.Output; parameters[1].Value = model.S_File; parameters[2].Value = model.S_Title; parameters[3].Value = model.S_Name; parameters[4].Value = model.CreateDate; parameters[5].Value = model.CreateUser; parameters[6].Value = model.S_bum; DbHelperSQL.RunProcedure("UP_Tunnel_Standard_ADD", parameters, out rowsAffected); return((int)parameters[0].Value); }
/// <summary> /// 获得数据列表 /// </summary> public List <Tunnel.Model.Tunnel_Standard> DataTableToList(DataTable dt) { List <Tunnel.Model.Tunnel_Standard> modelList = new List <Tunnel.Model.Tunnel_Standard>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { Tunnel.Model.Tunnel_Standard model; for (int n = 0; n < rowsCount; n++) { model = new Tunnel.Model.Tunnel_Standard(); if (dt.Rows[n]["Id"].ToString() != "") { model.Id = int.Parse(dt.Rows[n]["Id"].ToString()); } model.S_File = dt.Rows[n]["S_File"].ToString(); model.S_Title = dt.Rows[n]["S_Title"].ToString(); model.S_Name = dt.Rows[n]["S_Name"].ToString(); if (dt.Rows[n]["CreateDate"].ToString() != "") { model.CreateDate = DateTime.Parse(dt.Rows[n]["CreateDate"].ToString()); } if (dt.Rows[n]["CreateUser"].ToString() != "") { model.CreateUser = int.Parse(dt.Rows[n]["CreateUser"].ToString()); } if (dt.Rows[n]["S_bum"].ToString() != "") { model.S_bum = int.Parse(dt.Rows[n]["S_bum"].ToString()); } modelList.Add(model); } } return(modelList); }
protected void Button1_Click(object sender, EventArgs e) { //获得所需参数 string strTitle = tb_Title.Text.Trim(); HttpPostedFile hpf = file1.PostedFile; if (Convert.ToDouble(hpf.ContentLength) / 1024 / 1024 > 10) { Response.Write("<script>alert('附件大小不能大于10MB');</script>"); return; } else { CreateMdAndFilePaht(hpf); } //写入数据库 Tunnel.BLL.Tunnel_Standard rbll = new Tunnel.BLL.Tunnel_Standard(); Tunnel.Model.Tunnel_Standard model = new Tunnel.Model.Tunnel_Standard(); model.S_File = filePaht; model.S_Title = strTitle; model.S_Name = ""; model.CreateDate = DateTime.Now; model.CreateUser = ul.LoginID; if (ul.GetUserBean(ul.LoginID) != null) { buMId = (int)ul.GetUserBean(ul.LoginID).m_id; } model.S_bum = buMId; int relt1 = -1; relt1 = rbll.Add(model); string str = "上传文件"; string url = "N_Standard_Manage.aspx"; if (relt1 > 0) { str += "成功!"; } else { str += "失败!"; } MessageBox(str, url); }
/// <summary> /// 得到一个对象实体 /// </summary> public Tunnel.Model.Tunnel_Standard GetModel(int Id) { SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int) }; parameters[0].Value = Id; Tunnel.Model.Tunnel_Standard model = new Tunnel.Model.Tunnel_Standard(); DataSet ds = DbHelperSQL.RunProcedure("Tunnel_Standard_GetModel", parameters, "ds"); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["Id"].ToString() != "") { model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString()); } model.S_File = ds.Tables[0].Rows[0]["S_File"].ToString(); model.S_Title = ds.Tables[0].Rows[0]["S_Title"].ToString(); model.S_Name = ds.Tables[0].Rows[0]["S_Name"].ToString(); if (ds.Tables[0].Rows[0]["CreateDate"].ToString() != "") { model.CreateDate = DateTime.Parse(ds.Tables[0].Rows[0]["CreateDate"].ToString()); } if (ds.Tables[0].Rows[0]["CreateUser"].ToString() != "") { model.CreateUser = int.Parse(ds.Tables[0].Rows[0]["CreateUser"].ToString()); } if (ds.Tables[0].Rows[0]["S_bum"].ToString() != "") { model.S_bum = int.Parse(ds.Tables[0].Rows[0]["S_bum"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 获得数据列表 /// </summary> /// <param name="pb">分页基本信息</param> /// <param name="count">返回总数</param> /// <returns></returns> public List <Tunnel.Model.Tunnel_Standard> GetList(PageBase pb, ref int count) { DataTable dt = dal.GetList(pb, ref count).Tables[0]; List <Tunnel.Model.Tunnel_Standard> modelList = new List <Tunnel.Model.Tunnel_Standard>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0 && pb.DoCount == 0) { Tunnel.Model.Tunnel_Standard model; for (int n = 0; n < rowsCount; n++) { model = new Tunnel.Model.Tunnel_Standard(); if (dt.Rows[n]["Id"].ToString() != "") { model.Id = int.Parse(dt.Rows[n]["Id"].ToString()); } model.S_File = dt.Rows[n]["S_File"].ToString(); model.S_Title = dt.Rows[n]["S_Title"].ToString(); model.S_Name = dt.Rows[n]["S_Name"].ToString(); if (dt.Rows[n]["CreateDate"].ToString() != "") { model.CreateDate = DateTime.Parse(dt.Rows[n]["CreateDate"].ToString()); } if (dt.Rows[n]["CreateUser"].ToString() != "") { model.CreateUser = int.Parse(dt.Rows[n]["CreateUser"].ToString()); } if (dt.Rows[n]["S_bum"].ToString() != "") { model.S_bum = int.Parse(dt.Rows[n]["S_bum"].ToString()); } modelList.Add(model); } } return(modelList); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Tunnel.Model.Tunnel_Standard model) { return(dal.Add(model)); }