//数据持久化 internal static void SaveToDb(OutRegistInfo pOutRegistInfo, OutRegist pOutRegist, bool pIsNew) { pOutRegist.OutRegistId = pOutRegistInfo.outRegistId; pOutRegist.OutDate = pOutRegistInfo.outDate; pOutRegist.OutTime = pOutRegistInfo.outTime; pOutRegist.OutContent = pOutRegistInfo.outContent; pOutRegist.BackTime = pOutRegistInfo.backTime; pOutRegist.OutTool = pOutRegistInfo.outTool; pOutRegist.Memo = pOutRegistInfo.memo; pOutRegist.ApplyName = pOutRegistInfo.applyName; pOutRegist.DepartName = pOutRegistInfo.departName; pOutRegist.State = pOutRegistInfo.state; pOutRegist.IsNew = pIsNew; string UserName = SubsonicHelper.GetUserName(); try { pOutRegist.Save(UserName); } catch (Exception ex) { LogManager.getInstance().getLogger(typeof(OutRegistInfo)).Error(ex); if (ex.Message.Contains("插入重复键")) //违反了唯一键 { throw new AppException("此对象已经存在"); //此处等待优化可以从唯一约束中直接取出提示来,如果没有的话,默认为原始的出错提示 } throw new AppException("保存失败"); } pOutRegistInfo.outRegistId = pOutRegist.OutRegistId; //如果缓存存在,更新缓存 if (CachedEntityCommander.IsTypeRegistered(typeof(OutRegistInfo))) { ResetCache(); } }
/// <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 <OutRegistInfo> GetPagedList(int pPageIndex, int pPageSize, SortDirection pOrderBy, string pSortExpression, out int pRecordCount) { if (pPageIndex <= 1) { pPageIndex = 1; } List <OutRegistInfo> list = new List <OutRegistInfo>(); Query q = OutRegist.CreateQuery(); q.PageIndex = pPageIndex; q.PageSize = pPageSize; q.ORDER_BY(pSortExpression, pOrderBy.ToString()); OutRegistCollection collection = new OutRegistCollection(); collection.LoadAndCloseReader(q.ExecuteReader()); foreach (OutRegist outRegist in collection) { OutRegistInfo outRegistInfo = new OutRegistInfo(); LoadFromDAL(outRegistInfo, outRegist); list.Add(outRegistInfo); } pRecordCount = q.GetRecordCount(); return(list); }
/// <summary> /// 获得数据列表 /// </summary> /// <returns></returns> public static List <OutRegistInfo> GetList() { string cacheKey = GetCacheKey(); //本实体已经注册成缓存实体,并且缓存存在的时候,直接从缓存取 if (CachedEntityCommander.IsTypeRegistered(typeof(OutRegistInfo)) && CachedEntityCommander.GetCache(cacheKey) != null) { return(CachedEntityCommander.GetCache(cacheKey) as List <OutRegistInfo>); } else { List <OutRegistInfo> list = new List <OutRegistInfo>(); OutRegistCollection collection = new OutRegistCollection(); Query qry = new Query(OutRegist.Schema); collection.LoadAndCloseReader(qry.ExecuteReader()); foreach (OutRegist outRegist in collection) { OutRegistInfo outRegistInfo = new OutRegistInfo(); LoadFromDAL(outRegistInfo, outRegist); list.Add(outRegistInfo); } //生成缓存 if (CachedEntityCommander.IsTypeRegistered(typeof(OutRegistInfo))) { CachedEntityCommander.SetCache(cacheKey, list); } return(list); } }
/// <summary> /// 批量装载 /// </summary> internal static void LoadFromDALPatch(List <OutRegistInfo> pList, OutRegistCollection pCollection) { foreach (OutRegist outRegist in pCollection) { OutRegistInfo outRegistInfo = new OutRegistInfo(); LoadFromDAL(outRegistInfo, outRegist); pList.Add(outRegistInfo); } }
protected void btnSubmit_Click(object sender, EventArgs e) { int outid = Convert.ToInt32(((Button)sender).CommandArgument.ToString()); OutRegistInfo ore = new OutRegistInfo(outid); ore.State = 4; ore.Save(); gvDataBind(); Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('同意外出!');</script>"); }
/// <summary> /// 复制一个对象,采用硬编码的方式,避免反射的低效 /// </summary> /// <param name="pIndustryTypeInfoFrom"></param> /// <param name="pIndustryTypeInfoTo"></param> public static void Copy(OutRegistInfo pOutRegistInfoFrom, OutRegistInfo pOutRegistInfoTo) { pOutRegistInfoTo.OutRegistId = pOutRegistInfoFrom.outRegistId; pOutRegistInfoTo.OutDate = pOutRegistInfoFrom.outDate; pOutRegistInfoTo.OutTime = pOutRegistInfoFrom.outTime; pOutRegistInfoTo.OutContent = pOutRegistInfoFrom.outContent; pOutRegistInfoTo.BackTime = pOutRegistInfoFrom.backTime; pOutRegistInfoTo.OutTool = pOutRegistInfoFrom.outTool; pOutRegistInfoTo.Memo = pOutRegistInfoFrom.memo; pOutRegistInfoTo.ApplyName = pOutRegistInfoFrom.applyName; pOutRegistInfoTo.DepartName = pOutRegistInfoFrom.departName; pOutRegistInfoTo.State = pOutRegistInfoFrom.state; pOutRegistInfoTo.Loaded = pOutRegistInfoFrom.Loaded; }
protected void gvOutRegist_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"; Button btnSubmit = e.Row.FindControl("btnSubmit") as Button; Button btnNoSubmit = e.Row.FindControl("btnNoSubmit") as Button; if (!Convert.IsDBNull(gvOutRegist.DataKeys[e.Row.RowIndex].Value)) { int outid = Convert.ToInt32(gvOutRegist.DataKeys[e.Row.RowIndex].Value); OutRegistInfo ore = new OutRegistInfo(outid); if (ore.State !=1) { btnSubmit.Enabled = false; btnNoSubmit.Enabled = false; } Label lblState = e.Row.FindControl("lblState") as Label; switch (ore.State) { 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; } } } }
//从后台获取数据 internal static void LoadFromDAL(OutRegistInfo pOutRegistInfo, OutRegist pOutRegist) { pOutRegistInfo.outRegistId = pOutRegist.OutRegistId; pOutRegistInfo.outDate = pOutRegist.OutDate; pOutRegistInfo.outTime = pOutRegist.OutTime; pOutRegistInfo.outContent = pOutRegist.OutContent; pOutRegistInfo.backTime = pOutRegist.BackTime; pOutRegistInfo.outTool = pOutRegist.OutTool; pOutRegistInfo.memo = pOutRegist.Memo; pOutRegistInfo.applyName = pOutRegist.ApplyName; pOutRegistInfo.departName = pOutRegist.DepartName; pOutRegistInfo.state = pOutRegist.State; pOutRegistInfo.Loaded = true; }
protected void btnAdd_Click(object sender, EventArgs e) { OutRegistInfo ore = new OutRegistInfo(); ore.BackTime = ""; ore.Memo = ""; ore.OutContent = ""; ore.OutDate = ""; ore.OutTime = ""; ore.OutTool = ""; ore.State = 0; ore.DepartName = Session["DepartName"].ToString(); ore.ApplyName = Session["EmployeeName"].ToString(); ore.Save(); gvDataBind(); }
public OutRegistInfo GetOutRegistInfoById(int OutRegistId) { OutRegistInfo outRegistInfo = null; // try { outRegistInfo = new OutRegistInfo(OutRegistId); } catch (AppException) { return(null); } return(outRegistInfo); }
public OutRegistInfo GetOutRegistInfoById(int OutRegistId) { OutRegistInfo outRegistInfo = null;// try { outRegistInfo = new OutRegistInfo(OutRegistId); } catch (AppException) { return null; } return outRegistInfo; }
private void LoadFromId(int outRegistId) { if (CachedEntityCommander.IsTypeRegistered(typeof(OutRegistInfo))) { OutRegistInfo outRegistInfo = Find(GetList(), outRegistId); if (outRegistInfo == null) { throw new AppException("未能在缓存中找到相应的键值对象"); } Copy(outRegistInfo, this); } else { OutRegist outRegist = new OutRegist(outRegistId); if (outRegist.IsNew) { throw new AppException("尚未初始化"); } LoadFromDAL(this, outRegist); } }
public void DeleteById(OutRegistInfo pOutRegistInfo) { OutRegistInfo outRegistInfo = new OutRegistInfo(pOutRegistInfo.OutRegistId); outRegistInfo.Delete(); }
protected void gvOutRegist_RowUpdating(object sender, GridViewUpdateEventArgs e) { int outid = Convert.ToInt32(gvOutRegist.DataKeys[e.RowIndex].Value); TextBox txtOutDate = gvOutRegist.Rows[e.RowIndex].FindControl("txtOutDate") as TextBox; TextBox txtOutContent = gvOutRegist.Rows[e.RowIndex].FindControl("txtOutContent") as TextBox; TextBox txtOutTime = gvOutRegist.Rows[e.RowIndex].FindControl("txtOutTime") as TextBox; TextBox txtBackTime = gvOutRegist.Rows[e.RowIndex].FindControl("txtBackTime") as TextBox; TextBox txtOutTool = gvOutRegist.Rows[e.RowIndex].FindControl("txtOutTool") as TextBox; TextBox txtMemo = gvOutRegist.Rows[e.RowIndex].FindControl("txtMemo") as TextBox; try { OutRegistInfo ore = new OutRegistInfo(outid); ore.BackTime = txtBackTime.Text.ToString(); ore.Memo = txtMemo.Text.ToString(); ore.OutContent = txtOutContent.Text.ToString(); ore.OutDate = txtOutDate.Text.ToString(); ore.OutTime = txtOutTime.Text.ToString(); ore.OutTool = txtOutTool.Text.ToString(); ore.Save(); gvOutRegist.EditIndex = -1; gvDataBind(); } catch (Exception Ex) { ClientScript.RegisterStartupScript(this.GetType(), "Save", "alert('更新失败:" + Ex.Message + "');", true); } }
//数据持久化 internal static void SaveToDb(OutRegistInfo pOutRegistInfo, OutRegist pOutRegist,bool pIsNew) { pOutRegist.OutRegistId = pOutRegistInfo.outRegistId; pOutRegist.OutDate = pOutRegistInfo.outDate; pOutRegist.OutTime = pOutRegistInfo.outTime; pOutRegist.OutContent = pOutRegistInfo.outContent; pOutRegist.BackTime = pOutRegistInfo.backTime; pOutRegist.OutTool = pOutRegistInfo.outTool; pOutRegist.Memo = pOutRegistInfo.memo; pOutRegist.ApplyName = pOutRegistInfo.applyName; pOutRegist.DepartName = pOutRegistInfo.departName; pOutRegist.State = pOutRegistInfo.state; pOutRegist.IsNew=pIsNew; string UserName = SubsonicHelper.GetUserName(); try { pOutRegist.Save(UserName); } catch(Exception ex) { LogManager.getInstance().getLogger(typeof(OutRegistInfo)).Error(ex); if(ex.Message.Contains("插入重复键"))//违反了唯一键 { throw new AppException("此对象已经存在");//此处等待优化可以从唯一约束中直接取出提示来,如果没有的话,默认为原始的出错提示 } throw new AppException("保存失败"); } pOutRegistInfo.outRegistId = pOutRegist.OutRegistId; //如果缓存存在,更新缓存 if (CachedEntityCommander.IsTypeRegistered(typeof(OutRegistInfo))) { ResetCache(); } }
/// <summary> /// 批量装载 /// </summary> internal static void LoadFromDALPatch(List< OutRegistInfo> pList, OutRegistCollection pCollection) { foreach (OutRegist outRegist in pCollection) { OutRegistInfo outRegistInfo = new OutRegistInfo(); LoadFromDAL(outRegistInfo, outRegist ); pList.Add(outRegistInfo); } }
//从后台获取数据 internal static void LoadFromDAL(OutRegistInfo pOutRegistInfo, OutRegist pOutRegist) { pOutRegistInfo.outRegistId = pOutRegist.OutRegistId; pOutRegistInfo.outDate = pOutRegist.OutDate; pOutRegistInfo.outTime = pOutRegist.OutTime; pOutRegistInfo.outContent = pOutRegist.OutContent; pOutRegistInfo.backTime = pOutRegist.BackTime; pOutRegistInfo.outTool = pOutRegist.OutTool; pOutRegistInfo.memo = pOutRegist.Memo; pOutRegistInfo.applyName = pOutRegist.ApplyName; pOutRegistInfo.departName = pOutRegist.DepartName; pOutRegistInfo.state = pOutRegist.State; pOutRegistInfo.Loaded=true; }
/// <summary> /// 复制为另一个对象 /// </summary> /// <param name="pIndustryTypeInfoTo"></param> public void CopyTo(OutRegistInfo pOutRegistInfoTo) { Copy(this, pOutRegistInfoTo); }
/// <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<OutRegistInfo> GetPagedList(int pPageIndex,int pPageSize,SortDirection pOrderBy,string pSortExpression,out int pRecordCount) { if(pPageIndex<=1) pPageIndex=1; List< OutRegistInfo> list = new List< OutRegistInfo>(); Query q = OutRegist .CreateQuery(); q.PageIndex = pPageIndex; q.PageSize = pPageSize; q.ORDER_BY(pSortExpression,pOrderBy.ToString()); OutRegistCollection collection=new OutRegistCollection(); collection.LoadAndCloseReader(q.ExecuteReader()); foreach (OutRegist outRegist in collection) { OutRegistInfo outRegistInfo = new OutRegistInfo(); LoadFromDAL(outRegistInfo, outRegist); list.Add(outRegistInfo); } pRecordCount=q.GetRecordCount(); return list; }
/// <summary> /// 获得数据列表 /// </summary> /// <returns></returns> public static List<OutRegistInfo> GetList() { string cacheKey = GetCacheKey(); //本实体已经注册成缓存实体,并且缓存存在的时候,直接从缓存取 if (CachedEntityCommander.IsTypeRegistered(typeof(OutRegistInfo)) && CachedEntityCommander.GetCache(cacheKey) != null) { return CachedEntityCommander.GetCache(cacheKey) as List< OutRegistInfo>; } else { List< OutRegistInfo> list =new List< OutRegistInfo>(); OutRegistCollection collection=new OutRegistCollection(); Query qry = new Query(OutRegist.Schema); collection.LoadAndCloseReader(qry.ExecuteReader()); foreach(OutRegist outRegist in collection) { OutRegistInfo outRegistInfo= new OutRegistInfo(); LoadFromDAL(outRegistInfo,outRegist); list.Add(outRegistInfo); } //生成缓存 if (CachedEntityCommander.IsTypeRegistered(typeof(OutRegistInfo))) { CachedEntityCommander.SetCache(cacheKey, list); } return list; } }
public List <OutRegistInfo> GetOutRegistInfoList() { return(OutRegistInfo.GetList()); }
public List <OutRegistInfo> GetPagedList(int pPageIndex, int pPageSize, SortDirection pOrderBy, string pSortExpression, out int pRecordCount) { return(OutRegistInfo.GetPagedList(pPageIndex, pPageSize, pOrderBy, pSortExpression, out pRecordCount)); }
public object SaveOutRegistInfo(OutRegistInfo outRegistInfo) { outRegistInfo.Save(); return(outRegistInfo.OutRegistId); }
public object SaveOutRegistInfo(OutRegistInfo outRegistInfo) { outRegistInfo.Save(); return outRegistInfo . OutRegistId; }
/// <summary> /// 复制一个对象,采用硬编码的方式,避免反射的低效 /// </summary> /// <param name="pIndustryTypeInfoFrom"></param> /// <param name="pIndustryTypeInfoTo"></param> public static void Copy(OutRegistInfo pOutRegistInfoFrom, OutRegistInfo pOutRegistInfoTo) { pOutRegistInfoTo.OutRegistId = pOutRegistInfoFrom.outRegistId; pOutRegistInfoTo.OutDate = pOutRegistInfoFrom.outDate; pOutRegistInfoTo.OutTime = pOutRegistInfoFrom.outTime; pOutRegistInfoTo.OutContent = pOutRegistInfoFrom.outContent; pOutRegistInfoTo.BackTime = pOutRegistInfoFrom.backTime; pOutRegistInfoTo.OutTool = pOutRegistInfoFrom.outTool; pOutRegistInfoTo.Memo = pOutRegistInfoFrom.memo; pOutRegistInfoTo.ApplyName = pOutRegistInfoFrom.applyName; pOutRegistInfoTo.DepartName = pOutRegistInfoFrom.departName; pOutRegistInfoTo.State = pOutRegistInfoFrom.state; pOutRegistInfoTo.Loaded=pOutRegistInfoFrom.Loaded; }