/// <summary> /// 获得数据列表 /// </summary> public List <Tunnel.Model.Tunnel_Profile> GetList(PageBase pb, ref int count) { DataTable dt = dal.GetList(pb, ref count).Tables[0]; List <Tunnel.Model.Tunnel_Profile> modelList = new List <Tunnel.Model.Tunnel_Profile>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0 && pb.DoCount == 0) { Tunnel.Model.Tunnel_Profile model; for (int n = 0; n < rowsCount; n++) { model = new Tunnel.Model.Tunnel_Profile(); if (dt.Rows[n]["p_id"].ToString() != "") { model.p_id = int.Parse(dt.Rows[n]["p_id"].ToString()); } model.p_name = dt.Rows[n]["p_name"].ToString(); if (dt.Rows[n]["p_year"].ToString() != "") { model.p_year = int.Parse(dt.Rows[n]["p_year"].ToString()); } model.p_bum = dt.Rows[n]["p_bum"].ToString(); model.p_filetype = dt.Rows[n]["p_filetype"].ToString(); if (dt.Rows[n]["p_uid"].ToString() != "") { model.p_uid = int.Parse(dt.Rows[n]["p_uid"].ToString()); } modelList.Add(model); } } return(modelList); }
/// <summary> /// 得到一个对象实体 /// </summary> public Tunnel.Model.Tunnel_Profile GetModel(int p_id) { SqlParameter[] parameters = { new SqlParameter("@p_id", SqlDbType.Int, 4) }; parameters[0].Value = p_id; Tunnel.Model.Tunnel_Profile model = new Tunnel.Model.Tunnel_Profile(); DataSet ds = DbHelperSQL.RunProcedure("UP_Tunnel_Profile_GetModel", parameters, "ds"); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["p_id"].ToString() != "") { model.p_id = int.Parse(ds.Tables[0].Rows[0]["p_id"].ToString()); } model.p_name = ds.Tables[0].Rows[0]["p_name"].ToString(); if (ds.Tables[0].Rows[0]["p_year"].ToString() != "") { model.p_year = int.Parse(ds.Tables[0].Rows[0]["p_year"].ToString()); } model.p_bum = ds.Tables[0].Rows[0]["p_bum"].ToString(); model.p_filetype = ds.Tables[0].Rows[0]["p_filetype"].ToString(); if (ds.Tables[0].Rows[0]["p_uid"].ToString() != "") { model.p_uid = int.Parse(ds.Tables[0].Rows[0]["p_uid"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 获得数据列表 /// </summary> public List <Tunnel.Model.Tunnel_Profile> DataTableToList(DataTable dt) { List <Tunnel.Model.Tunnel_Profile> modelList = new List <Tunnel.Model.Tunnel_Profile>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { Tunnel.Model.Tunnel_Profile model; for (int n = 0; n < rowsCount; n++) { model = new Tunnel.Model.Tunnel_Profile(); if (dt.Rows[n]["p_id"].ToString() != "") { model.p_id = int.Parse(dt.Rows[n]["p_id"].ToString()); } model.p_name = dt.Rows[n]["p_name"].ToString(); if (dt.Rows[n]["p_year"].ToString() != "") { model.p_year = int.Parse(dt.Rows[n]["p_year"].ToString()); } model.p_bum = dt.Rows[n]["p_bum"].ToString(); model.p_filetype = dt.Rows[n]["p_filetype"].ToString(); if (dt.Rows[n]["p_uid"].ToString() != "") { model.p_uid = int.Parse(dt.Rows[n]["p_uid"].ToString()); } modelList.Add(model); } } return(modelList); }
protected void btnSave_Click(object sender, EventArgs e) { Tunnel.BLL.Tunnel_Profile pf = new Tunnel.BLL.Tunnel_Profile(); Tunnel.Model.Tunnel_Profile pff = new Tunnel.Model.Tunnel_Profile(); Tunnel.BLL.UserLogin ul = new Tunnel.BLL.UserLogin(); if (pf.GetModelList("p_bum='" + DropDownList2.SelectedValue + "' and p_filetype='" + DropDownList3.SelectedValue + "' and p_name='" + TextBox1.Text + "' and p_year='" + DropDownList1.SelectedValue + "'").Count > 0) { Tunnel.Common.Message.Show("此文件已经存在,请重新命名!"); } else { pff.p_bum = DropDownList2.SelectedValue; pff.p_filetype = DropDownList3.SelectedValue; pff.p_name = TextBox1.Text; pff.p_uid = Convert.ToInt32(ul.LoginID); pff.p_year = Convert.ToInt32(DropDownList1.SelectedValue); if (pf.Add(pff) > 0) { Tunnel.Common.Message.Show("提交成功!"); string strsql = ""; strsql = "insert into tunnel_log(l_user,l_time,l_content,l_ip,l_sort) values(" + ul.LoginID + ",'" + DateTime.Now + "','公司事务>>档案管理>>新增档案。标题:" + pff.p_name + "','" + Tunnel.Common.Common.GetIp() + "',1)"; Tunnel.Data.DbHelperSQL.ExecuteSql(strsql); } } }
/// <summary> /// 删除记录 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void LinkButton1_Command(object sender, CommandEventArgs e) { string a = e.CommandName.ToString(); Tunnel.BLL.Tunnel_Profile pf = new Tunnel.BLL.Tunnel_Profile(); Tunnel.Model.Tunnel_Profile model = pf.GetModel(IsNum(a)); pf.Delete(IsNum(a)); string strsql = ""; strsql = "insert into tunnel_log(l_user,l_time,l_content,l_ip,l_sort) values(" + ul.LoginID + ",'" + DateTime.Now + "','公司事务>>档案管理>>删除档案信息。标题:" + model.p_name + "','" + Tunnel.Common.Common.GetIp() + "',2)"; Tunnel.Data.DbHelperSQL.ExecuteSql(strsql); Tunnel.Common.Message.Show("删除成功!"); }
protected void Page_Load(object sender, EventArgs e) { string a = "0"; if (!IsPostBack) { if (!string.IsNullOrEmpty(Request.QueryString["id"])) { a = Request.QueryString["id"].ToString(); } Tunnel.BLL.Tunnel_Profile pf = new Tunnel.BLL.Tunnel_Profile(); Tunnel.Model.Tunnel_Profile pff = new Tunnel.Model.Tunnel_Profile(); pff = pf.GetModel(IsNum(a)); if (pff != null) { Label1.Text = pff.p_name; Label2.Text = pff.p_year.ToString(); Label3.Text = pff.p_bum; Label4.Text = pff.p_filetype; } } }
/// <summary> /// 更新一条数据 /// </summary> public void Update(Tunnel.Model.Tunnel_Profile model) { int rowsAffected; SqlParameter[] parameters = { new SqlParameter("@p_id", SqlDbType.Int, 4), new SqlParameter("@p_name", SqlDbType.VarChar, 50), new SqlParameter("@p_year", SqlDbType.Int, 4), new SqlParameter("@p_bum", SqlDbType.VarChar, 50), new SqlParameter("@p_filetype", SqlDbType.VarChar, 50), new SqlParameter("@p_uid", SqlDbType.Int, 4) }; parameters[0].Value = model.p_id; parameters[1].Value = model.p_name; parameters[2].Value = model.p_year; parameters[3].Value = model.p_bum; parameters[4].Value = model.p_filetype; parameters[5].Value = model.p_uid; DbHelperSQL.RunProcedure("UP_Tunnel_Profile_Update", parameters, out rowsAffected); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Tunnel.Model.Tunnel_Profile model) { int rowsAffected; SqlParameter[] parameters = { new SqlParameter("@p_id", SqlDbType.Int, 4), new SqlParameter("@p_name", SqlDbType.VarChar, 600), new SqlParameter("@p_year", SqlDbType.Int, 4), new SqlParameter("@p_bum", SqlDbType.VarChar, 50), new SqlParameter("@p_filetype", SqlDbType.VarChar, 50), new SqlParameter("@p_uid", SqlDbType.Int, 4) }; parameters[0].Direction = ParameterDirection.Output; parameters[1].Value = model.p_name; parameters[2].Value = model.p_year; parameters[3].Value = model.p_bum; parameters[4].Value = model.p_filetype; parameters[5].Value = model.p_uid; DbHelperSQL.RunProcedure("UP_Tunnel_Profile_ADD", parameters, out rowsAffected); return((int)parameters[0].Value); }
/// <summary> /// 更新一条数据 /// </summary> public void Update(Tunnel.Model.Tunnel_Profile model) { dal.Update(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Tunnel.Model.Tunnel_Profile model) { return(dal.Add(model)); }