protected void btnDownLoad_Click(object sender, EventArgs e) { int fid = Convert.ToInt32(Request["FileApplyId"].ToString()); FileApplyInfo fa = new FileApplyInfo(fid); int fileid = Convert.ToInt32(fa.FileOfApplyId); Response.Redirect("DownLoadFile.aspx?fileid=" + fileid); }
protected void btnSave_Click(object sender, EventArgs e) { if (rblOver.SelectedIndex == -1) { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('请选择修正或通过!');</script>"); } else { try { int fid = Convert.ToInt32(Request["FileApplyId"].ToString()); FileApplyInfo fa = new FileApplyInfo(fid); fa.DepartView = txtView.Text.ToString(); if (rblOver.Items[0].Selected) { fa.State = 2; fa.Save(); Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('您让申请人修正!');</script>"); } else if (rblOver.Items[1].Selected) { fa.State = 3; fa.Save(); Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('审批通过!');</script>"); } } catch (Exception Ex) { ClientScript.RegisterStartupScript(this.GetType(), "Save", "alert('保存失败:" + Ex.Message + "');", true); } } }
/// <summary> /// 获得分页列表,无论是否是缓存实体都从数据库直接拿取数据 /// </summary> /// <param name="pPageIndex">页数</param> /// <param name="pPageSize">每页列表</param> /// <param name="pOrderBy">排序</param> /// <param name="pSortExpression">排序字段</param> /// <param name="pRecordCount">列表行数</param> /// <returns>数据分页</returns> public static List <FileApplyInfo> GetPagedList(int pPageIndex, int pPageSize, SortDirection pOrderBy, string pSortExpression, out int pRecordCount) { if (pPageIndex <= 1) { pPageIndex = 1; } List <FileApplyInfo> list = new List <FileApplyInfo>(); Query q = FileApply.CreateQuery(); q.PageIndex = pPageIndex; q.PageSize = pPageSize; q.ORDER_BY(pSortExpression, pOrderBy.ToString()); FileApplyCollection collection = new FileApplyCollection(); collection.LoadAndCloseReader(q.ExecuteReader()); foreach (FileApply fileApply in collection) { FileApplyInfo fileApplyInfo = new FileApplyInfo(); LoadFromDAL(fileApplyInfo, fileApply); list.Add(fileApplyInfo); } pRecordCount = q.GetRecordCount(); return(list); }
protected void btnSave_Click(object sender, EventArgs e) { if (UpFile.HasFile) { this.UpFile.PostedFile.SaveAs(Server.MapPath("~/Files/File/" + UpFile.FileName)); FileOfApplyInfo ffa = new FileOfApplyInfo(); ffa.FileOfName = UpFile.FileName.ToString(); ffa.PhysicalName = UpFile.PostedFile.FileName.ToString(); ffa.Save(); FileApplyInfo fa = new FileApplyInfo(); fa.ApplyName = lblEm.Text.ToString(); fa.ApplyTime = txtTime.Text.ToString(); fa.DepartName = Session["DepartName"].ToString(); fa.DepartView = txtSectionView.Text.ToString(); fa.FileDes = txtFileDes.Text.ToString(); fa.FilesName = txtFileName.Text.ToString(); fa.FileType = txtFileType.Text.ToString(); fa.State = 0; fa.FileOfApplyId = ffa.FileOfApplyId; fa.Save(); Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('新增成功,确认无误后需要您进一步提交!');</script>"); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('请上传文件!');</script>"); } }
/// <summary> /// 获得数据列表 /// </summary> /// <returns></returns> public static List <FileApplyInfo> GetList() { string cacheKey = GetCacheKey(); //本实体已经注册成缓存实体,并且缓存存在的时候,直接从缓存取 if (CachedEntityCommander.IsTypeRegistered(typeof(FileApplyInfo)) && CachedEntityCommander.GetCache(cacheKey) != null) { return(CachedEntityCommander.GetCache(cacheKey) as List <FileApplyInfo>); } else { List <FileApplyInfo> list = new List <FileApplyInfo>(); FileApplyCollection collection = new FileApplyCollection(); Query qry = new Query(FileApply.Schema); collection.LoadAndCloseReader(qry.ExecuteReader()); foreach (FileApply fileApply in collection) { FileApplyInfo fileApplyInfo = new FileApplyInfo(); LoadFromDAL(fileApplyInfo, fileApply); list.Add(fileApplyInfo); } //生成缓存 if (CachedEntityCommander.IsTypeRegistered(typeof(FileApplyInfo))) { CachedEntityCommander.SetCache(cacheKey, list); } return(list); } }
protected void btnSubmit_Click(object sender, EventArgs e) { int fid = Convert.ToInt32(((Button)sender).CommandArgument.ToString()); FileApplyInfo fa = new FileApplyInfo(fid); fa.State = 3; fa.Save(); gvDataBind(); }
protected void PageInit() { FileApplyInfo fa = new FileApplyInfo(Convert.ToInt32(Request["FileApplyId"].ToString())); lblDes.Text = fa.FileDes.ToString(); lblEm.Text = fa.ApplyName.ToString(); lblName.Text = fa.FilesName.ToString(); lblTime.Text = fa.ApplyTime.ToString(); lblType.Text = fa.FileType.ToString(); }
/// <summary> /// 批量装载 /// </summary> internal static void LoadFromDALPatch(List <FileApplyInfo> pList, FileApplyCollection pCollection) { foreach (FileApply fileApply in pCollection) { FileApplyInfo fileApplyInfo = new FileApplyInfo(); LoadFromDAL(fileApplyInfo, fileApply); pList.Add(fileApplyInfo); } }
protected void gvFileApply_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { //鼠标移动到每项时颜色交替效果 e.Row.Attributes.Add("onmouseover", "e=this.style.backgroundColor; this.style.backgroundColor='#c1ebff'"); e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=e"); //设置悬浮鼠标指针形状为"小手" e.Row.Attributes["style"] = "Cursor:hand"; if (!Convert.IsDBNull(gvFileApply.DataKeys[e.Row.RowIndex].Value)) { int fid = Convert.ToInt32(gvFileApply.DataKeys[e.Row.RowIndex].Value); FileApplyInfo fa = new FileApplyInfo(fid); if (fa.State != 0) { Button btnSubmit = e.Row.FindControl("btnSubmit") as Button; Button btnEdit = e.Row.FindControl("btnEdit") as Button; Button btnDelete = e.Row.FindControl("btnDelete") as Button; btnSubmit.Enabled = false; btnEdit.Enabled = false; btnDelete.Enabled = false; } Label lblState = e.Row.FindControl("lblState") as Label; switch (fa.State) { case 0: lblState.Text = "未提交"; break; case 1: lblState.Text = "待部门领导审批"; break; case 2: lblState.Text = "部门:修正"; break; case 3: lblState.Text = "待总经理审批"; break; case 4: lblState.Text = "通过"; break; case 5: lblState.Text = "总经理:修正"; break; default: lblState.Text = "其他状态"; break; } } } }
protected void PageInit() { ViewState["BackUrl"] = Request.UrlReferrer.ToString(); FileApplyInfo fa=new FileApplyInfo(Convert.ToInt32(Request["FileApplyId"].ToString())); lblEm.Text=fa.ApplyName.ToString(); txtTime.Text=fa.ApplyTime.ToString(); txtSectionView.Text=fa.DepartView.ToString(); txtFileDes.Text=fa.FileDes.ToString(); txtFileName.Text=fa.FilesName.ToString(); txtFileType.Text=fa.FileType.ToString(); }
/// <summary> /// 复制一个对象,采用硬编码的方式,避免反射的低效 /// </summary> /// <param name="pIndustryTypeInfoFrom"></param> /// <param name="pIndustryTypeInfoTo"></param> public static void Copy(FileApplyInfo pFileApplyInfoFrom, FileApplyInfo pFileApplyInfoTo) { pFileApplyInfoTo.FileApplyId = pFileApplyInfoFrom.fileApplyId; pFileApplyInfoTo.ApplyTime = pFileApplyInfoFrom.applyTime; pFileApplyInfoTo.FilesName = pFileApplyInfoFrom.filesName; pFileApplyInfoTo.FileType = pFileApplyInfoFrom.fileType; pFileApplyInfoTo.FileDes = pFileApplyInfoFrom.fileDes; pFileApplyInfoTo.DepartView = pFileApplyInfoFrom.departView; pFileApplyInfoTo.ManagerView = pFileApplyInfoFrom.managerView; pFileApplyInfoTo.FileOfApplyId = pFileApplyInfoFrom.fileOfApplyId; pFileApplyInfoTo.State = pFileApplyInfoFrom.state; pFileApplyInfoTo.DepartName = pFileApplyInfoFrom.departName; pFileApplyInfoTo.ApplyName = pFileApplyInfoFrom.applyName; pFileApplyInfoTo.Loaded = pFileApplyInfoFrom.Loaded; }
//从后台获取数据 internal static void LoadFromDAL(FileApplyInfo pFileApplyInfo, FileApply pFileApply) { pFileApplyInfo.fileApplyId = pFileApply.FileApplyId; pFileApplyInfo.applyTime = pFileApply.ApplyTime; pFileApplyInfo.filesName = pFileApply.FilesName; pFileApplyInfo.fileType = pFileApply.FileType; pFileApplyInfo.fileDes = pFileApply.FileDes; pFileApplyInfo.departView = pFileApply.DepartView; pFileApplyInfo.managerView = pFileApply.ManagerView; pFileApplyInfo.fileOfApplyId = pFileApply.FileOfApplyId; pFileApplyInfo.state = pFileApply.State; pFileApplyInfo.departName = pFileApply.DepartName; pFileApplyInfo.applyName = pFileApply.ApplyName; pFileApplyInfo.Loaded = true; }
public FileApplyInfo GetFileApplyInfoById(int FileApplyId) { FileApplyInfo fileApplyInfo = null; // try { fileApplyInfo = new FileApplyInfo(FileApplyId); } catch (AppException) { return(null); } return(fileApplyInfo); }
public FileApplyInfo GetFileApplyInfoById(int FileApplyId) { FileApplyInfo fileApplyInfo = null;// try { fileApplyInfo = new FileApplyInfo(FileApplyId); } catch (AppException) { return null; } return fileApplyInfo; }
private void LoadFromId(int fileApplyId) { if (CachedEntityCommander.IsTypeRegistered(typeof(FileApplyInfo))) { FileApplyInfo fileApplyInfo = Find(GetList(), fileApplyId); if (fileApplyInfo == null) { throw new AppException("未能在缓存中找到相应的键值对象"); } Copy(fileApplyInfo, this); } else { FileApply fileApply = new FileApply(fileApplyId); if (fileApply.IsNew) { throw new AppException("尚未初始化"); } LoadFromDAL(this, fileApply); } }
protected void btnSave_Click(object sender, EventArgs e) { if (UpFile.HasFile) { FileApplyInfo fa = new FileApplyInfo(Convert.ToInt32(Request["FileApplyId"].ToString())); FileOfApplyInfo ffa = new FileOfApplyInfo(Convert.ToInt32(fa.FileOfApplyId)); ffa.FileOfName = UpFile.FileName.ToString(); ffa.PhysicalName = UpFile.PostedFile.FileName.ToString(); ffa.Save(); fa.ApplyTime = txtTime.Text.ToString(); fa.DepartView = txtSectionView.Text.ToString(); fa.FileDes = txtFileDes.Text.ToString(); fa.FilesName = txtFileName.Text.ToString(); fa.FileType = txtFileType.Text.ToString(); fa.Save(); Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('保存成功,确认无误后需要您进一步提交!');</script>"); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('请重新修改文件名并上传!');</script>"); } }
//数据持久化 internal static void SaveToDb(FileApplyInfo pFileApplyInfo, FileApply pFileApply, bool pIsNew) { pFileApply.FileApplyId = pFileApplyInfo.fileApplyId; pFileApply.ApplyTime = pFileApplyInfo.applyTime; pFileApply.FilesName = pFileApplyInfo.filesName; pFileApply.FileType = pFileApplyInfo.fileType; pFileApply.FileDes = pFileApplyInfo.fileDes; pFileApply.DepartView = pFileApplyInfo.departView; pFileApply.ManagerView = pFileApplyInfo.managerView; pFileApply.FileOfApplyId = pFileApplyInfo.fileOfApplyId; pFileApply.State = pFileApplyInfo.state; pFileApply.DepartName = pFileApplyInfo.departName; pFileApply.ApplyName = pFileApplyInfo.applyName; pFileApply.IsNew = pIsNew; string UserName = SubsonicHelper.GetUserName(); try { pFileApply.Save(UserName); } catch (Exception ex) { LogManager.getInstance().getLogger(typeof(FileApplyInfo)).Error(ex); if (ex.Message.Contains("插入重复键")) //违反了唯一键 { throw new AppException("此对象已经存在"); //此处等待优化可以从唯一约束中直接取出提示来,如果没有的话,默认为原始的出错提示 } throw new AppException("保存失败"); } pFileApplyInfo.fileApplyId = pFileApply.FileApplyId; //如果缓存存在,更新缓存 if (CachedEntityCommander.IsTypeRegistered(typeof(FileApplyInfo))) { ResetCache(); } }
//从后台获取数据 internal static void LoadFromDAL(FileApplyInfo pFileApplyInfo, FileApply pFileApply) { pFileApplyInfo.fileApplyId = pFileApply.FileApplyId; pFileApplyInfo.applyTime = pFileApply.ApplyTime; pFileApplyInfo.filesName = pFileApply.FilesName; pFileApplyInfo.fileType = pFileApply.FileType; pFileApplyInfo.fileDes = pFileApply.FileDes; pFileApplyInfo.departView = pFileApply.DepartView; pFileApplyInfo.managerView = pFileApply.ManagerView; pFileApplyInfo.fileOfApplyId = pFileApply.FileOfApplyId; pFileApplyInfo.state = pFileApply.State; pFileApplyInfo.departName = pFileApply.DepartName; pFileApplyInfo.applyName = pFileApply.ApplyName; pFileApplyInfo.Loaded=true; }
/// <summary> /// 复制为另一个对象 /// </summary> /// <param name="pIndustryTypeInfoTo"></param> public void CopyTo(FileApplyInfo pFileApplyInfoTo) { Copy(this, pFileApplyInfoTo); }
/// <summary> /// 获得分页列表,无论是否是缓存实体都从数据库直接拿取数据 /// </summary> /// <param name="pPageIndex">页数</param> /// <param name="pPageSize">每页列表</param> /// <param name="pOrderBy">排序</param> /// <param name="pSortExpression">排序字段</param> /// <param name="pRecordCount">列表行数</param> /// <returns>数据分页</returns> public static List<FileApplyInfo> GetPagedList(int pPageIndex,int pPageSize,SortDirection pOrderBy,string pSortExpression,out int pRecordCount) { if(pPageIndex<=1) pPageIndex=1; List< FileApplyInfo> list = new List< FileApplyInfo>(); Query q = FileApply .CreateQuery(); q.PageIndex = pPageIndex; q.PageSize = pPageSize; q.ORDER_BY(pSortExpression,pOrderBy.ToString()); FileApplyCollection collection=new FileApplyCollection(); collection.LoadAndCloseReader(q.ExecuteReader()); foreach (FileApply fileApply in collection) { FileApplyInfo fileApplyInfo = new FileApplyInfo(); LoadFromDAL(fileApplyInfo, fileApply); list.Add(fileApplyInfo); } pRecordCount=q.GetRecordCount(); return list; }
/// <summary> /// 获得数据列表 /// </summary> /// <returns></returns> public static List<FileApplyInfo> GetList() { string cacheKey = GetCacheKey(); //本实体已经注册成缓存实体,并且缓存存在的时候,直接从缓存取 if (CachedEntityCommander.IsTypeRegistered(typeof(FileApplyInfo)) && CachedEntityCommander.GetCache(cacheKey) != null) { return CachedEntityCommander.GetCache(cacheKey) as List< FileApplyInfo>; } else { List< FileApplyInfo> list =new List< FileApplyInfo>(); FileApplyCollection collection=new FileApplyCollection(); Query qry = new Query(FileApply.Schema); collection.LoadAndCloseReader(qry.ExecuteReader()); foreach(FileApply fileApply in collection) { FileApplyInfo fileApplyInfo= new FileApplyInfo(); LoadFromDAL(fileApplyInfo,fileApply); list.Add(fileApplyInfo); } //生成缓存 if (CachedEntityCommander.IsTypeRegistered(typeof(FileApplyInfo))) { CachedEntityCommander.SetCache(cacheKey, list); } return list; } }
/// <summary> /// 复制一个对象,采用硬编码的方式,避免反射的低效 /// </summary> /// <param name="pIndustryTypeInfoFrom"></param> /// <param name="pIndustryTypeInfoTo"></param> public static void Copy(FileApplyInfo pFileApplyInfoFrom, FileApplyInfo pFileApplyInfoTo) { pFileApplyInfoTo.FileApplyId = pFileApplyInfoFrom.fileApplyId; pFileApplyInfoTo.ApplyTime = pFileApplyInfoFrom.applyTime; pFileApplyInfoTo.FilesName = pFileApplyInfoFrom.filesName; pFileApplyInfoTo.FileType = pFileApplyInfoFrom.fileType; pFileApplyInfoTo.FileDes = pFileApplyInfoFrom.fileDes; pFileApplyInfoTo.DepartView = pFileApplyInfoFrom.departView; pFileApplyInfoTo.ManagerView = pFileApplyInfoFrom.managerView; pFileApplyInfoTo.FileOfApplyId = pFileApplyInfoFrom.fileOfApplyId; pFileApplyInfoTo.State = pFileApplyInfoFrom.state; pFileApplyInfoTo.DepartName = pFileApplyInfoFrom.departName; pFileApplyInfoTo.ApplyName = pFileApplyInfoFrom.applyName; pFileApplyInfoTo.Loaded=pFileApplyInfoFrom.Loaded; }
public object SaveFileApplyInfo(FileApplyInfo fileApplyInfo) { fileApplyInfo.Save(); return fileApplyInfo . FileApplyId; }
public void DeleteById(FileApplyInfo pFileApplyInfo) { FileApplyInfo fileApplyInfo = new FileApplyInfo(pFileApplyInfo.FileApplyId); fileApplyInfo.Delete(); }
public List <FileApplyInfo> GetFileApplyInfoList() { return(FileApplyInfo.GetList()); }
public List <FileApplyInfo> GetPagedList(int pPageIndex, int pPageSize, SortDirection pOrderBy, string pSortExpression, out int pRecordCount) { return(FileApplyInfo.GetPagedList(pPageIndex, pPageSize, pOrderBy, pSortExpression, out pRecordCount)); }
public object SaveFileApplyInfo(FileApplyInfo fileApplyInfo) { fileApplyInfo.Save(); return(fileApplyInfo.FileApplyId); }
/// <summary> /// 批量装载 /// </summary> internal static void LoadFromDALPatch(List< FileApplyInfo> pList, FileApplyCollection pCollection) { foreach (FileApply fileApply in pCollection) { FileApplyInfo fileApplyInfo = new FileApplyInfo(); LoadFromDAL(fileApplyInfo, fileApply ); pList.Add(fileApplyInfo); } }
//数据持久化 internal static void SaveToDb(FileApplyInfo pFileApplyInfo, FileApply pFileApply,bool pIsNew) { pFileApply.FileApplyId = pFileApplyInfo.fileApplyId; pFileApply.ApplyTime = pFileApplyInfo.applyTime; pFileApply.FilesName = pFileApplyInfo.filesName; pFileApply.FileType = pFileApplyInfo.fileType; pFileApply.FileDes = pFileApplyInfo.fileDes; pFileApply.DepartView = pFileApplyInfo.departView; pFileApply.ManagerView = pFileApplyInfo.managerView; pFileApply.FileOfApplyId = pFileApplyInfo.fileOfApplyId; pFileApply.State = pFileApplyInfo.state; pFileApply.DepartName = pFileApplyInfo.departName; pFileApply.ApplyName = pFileApplyInfo.applyName; pFileApply.IsNew=pIsNew; string UserName = SubsonicHelper.GetUserName(); try { pFileApply.Save(UserName); } catch(Exception ex) { LogManager.getInstance().getLogger(typeof(FileApplyInfo)).Error(ex); if(ex.Message.Contains("插入重复键"))//违反了唯一键 { throw new AppException("此对象已经存在");//此处等待优化可以从唯一约束中直接取出提示来,如果没有的话,默认为原始的出错提示 } throw new AppException("保存失败"); } pFileApplyInfo.fileApplyId = pFileApply.FileApplyId; //如果缓存存在,更新缓存 if (CachedEntityCommander.IsTypeRegistered(typeof(FileApplyInfo))) { ResetCache(); } }