protected void btnSave_Click(object sender, EventArgs e) { if (IsPageValid()) { try { int wtid = Convert.ToInt32(Request["OfficeApplyId"].ToString()); WorkToolSumInfo wt = new WorkToolSumInfo(wtid); wt.DepartView = txtDepartView.Text.ToString(); if (rblOver.Items[0].Selected) { wt.State = 2; wt.Save(); Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('您让申请人修正!');</script>"); } else if (rblOver.Items[1].Selected) { wt.State = 3; wt.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 <WorkToolSumInfo> GetPagedList(int pPageIndex, int pPageSize, SortDirection pOrderBy, string pSortExpression, out int pRecordCount) { if (pPageIndex <= 1) { pPageIndex = 1; } List <WorkToolSumInfo> list = new List <WorkToolSumInfo>(); Query q = WorkToolSum.CreateQuery(); q.PageIndex = pPageIndex; q.PageSize = pPageSize; q.ORDER_BY(pSortExpression, pOrderBy.ToString()); WorkToolSumCollection collection = new WorkToolSumCollection(); collection.LoadAndCloseReader(q.ExecuteReader()); foreach (WorkToolSum workToolSum in collection) { WorkToolSumInfo workToolSumInfo = new WorkToolSumInfo(); LoadFromDAL(workToolSumInfo, workToolSum); list.Add(workToolSumInfo); } pRecordCount = q.GetRecordCount(); return(list); }
/// <summary> /// 获得数据列表 /// </summary> /// <returns></returns> public static List <WorkToolSumInfo> GetList() { string cacheKey = GetCacheKey(); //本实体已经注册成缓存实体,并且缓存存在的时候,直接从缓存取 if (CachedEntityCommander.IsTypeRegistered(typeof(WorkToolSumInfo)) && CachedEntityCommander.GetCache(cacheKey) != null) { return(CachedEntityCommander.GetCache(cacheKey) as List <WorkToolSumInfo>); } else { List <WorkToolSumInfo> list = new List <WorkToolSumInfo>(); WorkToolSumCollection collection = new WorkToolSumCollection(); Query qry = new Query(WorkToolSum.Schema); collection.LoadAndCloseReader(qry.ExecuteReader()); foreach (WorkToolSum workToolSum in collection) { WorkToolSumInfo workToolSumInfo = new WorkToolSumInfo(); LoadFromDAL(workToolSumInfo, workToolSum); list.Add(workToolSumInfo); } //生成缓存 if (CachedEntityCommander.IsTypeRegistered(typeof(WorkToolSumInfo))) { CachedEntityCommander.SetCache(cacheKey, list); } return(list); } }
protected void btnSubmit_Click(object sender, EventArgs e) { int id = Convert.ToInt32(((Button)sender).CommandArgument.ToString()); WorkToolSumInfo wt = new WorkToolSumInfo(id); wt.State = 1; wt.ApplyTime = DateTime.Now.ToString(); wt.Save(); gvDataBind(); }
/// <summary> /// 批量装载 /// </summary> internal static void LoadFromDALPatch(List <WorkToolSumInfo> pList, WorkToolSumCollection pCollection) { foreach (WorkToolSum workToolSum in pCollection) { WorkToolSumInfo workToolSumInfo = new WorkToolSumInfo(); LoadFromDAL(workToolSumInfo, workToolSum); pList.Add(workToolSumInfo); } }
protected void gvOffice_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(gvOffice.DataKeys[e.Row.RowIndex].Value)) { int id = Convert.ToInt32(gvOffice.DataKeys[e.Row.RowIndex].Value); WorkToolSumInfo wt = new WorkToolSumInfo(id); if (wt.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 (wt.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() { int wtid = Convert.ToInt32(Request["OfficeApplyId"].ToString()); WorkToolSumInfo wt = new WorkToolSumInfo(wtid); lblFuTime.Text = wt.FuTime.ToString(); lblBanDepart.Text = wt.DepartName.ToString(); lblBigMoney.Text = wt.BigMoney.ToString(); lblJieDepart.Text = wt.DepartName.ToString(); lblJinEmployee.Text = wt.ApplyName.ToString(); lblMoneyStyle.Text = wt.MoneyStyle.ToString(); lblSmallMoney.Text = wt.SmaMoney.ToString(); lblUseDepart.Text = wt.UseDepartName.ToString(); lblReason.Text = wt.Reason.ToString(); }
public WorkToolSumInfo GetWorkToolSumInfoById(int WorkToolSumId) { WorkToolSumInfo workToolSumInfo = null; // try { workToolSumInfo = new WorkToolSumInfo(WorkToolSumId); } catch (AppException) { return(null); } return(workToolSumInfo); }
public WorkToolSumInfo GetWorkToolSumInfoById(int WorkToolSumId) { WorkToolSumInfo workToolSumInfo = null;// try { workToolSumInfo = new WorkToolSumInfo(WorkToolSumId); } catch (AppException) { return null; } return workToolSumInfo; }
//从后台获取数据 internal static void LoadFromDAL(WorkToolSumInfo pWorkToolSumInfo, WorkToolSum pWorkToolSum) { pWorkToolSumInfo.workToolSumId = pWorkToolSum.WorkToolSumId; pWorkToolSumInfo.departName = pWorkToolSum.DepartName; pWorkToolSumInfo.reason = pWorkToolSum.Reason; pWorkToolSumInfo.bigMoney = pWorkToolSum.BigMoney; pWorkToolSumInfo.smaMoney = pWorkToolSum.SmaMoney; pWorkToolSumInfo.moneyStyle = pWorkToolSum.MoneyStyle; pWorkToolSumInfo.useDepartName = pWorkToolSum.UseDepartName; pWorkToolSumInfo.fuTime = pWorkToolSum.FuTime; pWorkToolSumInfo.applyName = pWorkToolSum.ApplyName; pWorkToolSumInfo.state = pWorkToolSum.State; pWorkToolSumInfo.applyTime = pWorkToolSum.ApplyTime; pWorkToolSumInfo.departView = pWorkToolSum.DepartView; pWorkToolSumInfo.managerView = pWorkToolSum.ManagerView; pWorkToolSumInfo.Loaded = true; }
/// <summary> /// 复制一个对象,采用硬编码的方式,避免反射的低效 /// </summary> /// <param name="pIndustryTypeInfoFrom"></param> /// <param name="pIndustryTypeInfoTo"></param> public static void Copy(WorkToolSumInfo pWorkToolSumInfoFrom, WorkToolSumInfo pWorkToolSumInfoTo) { pWorkToolSumInfoTo.WorkToolSumId = pWorkToolSumInfoFrom.workToolSumId; pWorkToolSumInfoTo.DepartName = pWorkToolSumInfoFrom.departName; pWorkToolSumInfoTo.Reason = pWorkToolSumInfoFrom.reason; pWorkToolSumInfoTo.BigMoney = pWorkToolSumInfoFrom.bigMoney; pWorkToolSumInfoTo.SmaMoney = pWorkToolSumInfoFrom.smaMoney; pWorkToolSumInfoTo.MoneyStyle = pWorkToolSumInfoFrom.moneyStyle; pWorkToolSumInfoTo.UseDepartName = pWorkToolSumInfoFrom.useDepartName; pWorkToolSumInfoTo.FuTime = pWorkToolSumInfoFrom.fuTime; pWorkToolSumInfoTo.ApplyName = pWorkToolSumInfoFrom.applyName; pWorkToolSumInfoTo.State = pWorkToolSumInfoFrom.state; pWorkToolSumInfoTo.ApplyTime = pWorkToolSumInfoFrom.applyTime; pWorkToolSumInfoTo.DepartView = pWorkToolSumInfoFrom.departView; pWorkToolSumInfoTo.ManagerView = pWorkToolSumInfoFrom.managerView; pWorkToolSumInfoTo.Loaded = pWorkToolSumInfoFrom.Loaded; }
private void LoadFromId(int workToolSumId) { if (CachedEntityCommander.IsTypeRegistered(typeof(WorkToolSumInfo))) { WorkToolSumInfo workToolSumInfo = Find(GetList(), workToolSumId); if (workToolSumInfo == null) { throw new AppException("未能在缓存中找到相应的键值对象"); } Copy(workToolSumInfo, this); } else { WorkToolSum workToolSum = new WorkToolSum(workToolSumId); if (workToolSum.IsNew) { throw new AppException("尚未初始化"); } LoadFromDAL(this, workToolSum); } }
protected void btnSave_Click(object sender, EventArgs e) { try { int wtid = Convert.ToInt32(Request["OfficeApplyId"].ToString()); WorkToolSumInfo wt = new WorkToolSumInfo(wtid); wt.FuTime = txtFuTime.Text.ToString(); wt.UseDepartName = txtUseDepart.Text.ToString(); wt.Reason = txtReason.Text.ToString(); wt.BigMoney = txtBigMoney.Text.ToString(); wt.SmaMoney = txtSmallMoney.Text.ToString(); wt.MoneyStyle = txtFuMoney.Text.ToString(); wt.DepartView = txtDepartView.Text.ToString(); wt.Save(); Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('�༭�ɹ���');</script>"); } catch (Exception Ex) { ClientScript.RegisterStartupScript(this.GetType(), "Save", "alert('�༭ʧ�ܣ�" + Ex.Message + "');", true); } }
//数据持久化 internal static void SaveToDb(WorkToolSumInfo pWorkToolSumInfo, WorkToolSum pWorkToolSum, bool pIsNew) { pWorkToolSum.WorkToolSumId = pWorkToolSumInfo.workToolSumId; pWorkToolSum.DepartName = pWorkToolSumInfo.departName; pWorkToolSum.Reason = pWorkToolSumInfo.reason; pWorkToolSum.BigMoney = pWorkToolSumInfo.bigMoney; pWorkToolSum.SmaMoney = pWorkToolSumInfo.smaMoney; pWorkToolSum.MoneyStyle = pWorkToolSumInfo.moneyStyle; pWorkToolSum.UseDepartName = pWorkToolSumInfo.useDepartName; pWorkToolSum.FuTime = pWorkToolSumInfo.fuTime; pWorkToolSum.ApplyName = pWorkToolSumInfo.applyName; pWorkToolSum.State = pWorkToolSumInfo.state; pWorkToolSum.ApplyTime = pWorkToolSumInfo.applyTime; pWorkToolSum.DepartView = pWorkToolSumInfo.departView; pWorkToolSum.ManagerView = pWorkToolSumInfo.managerView; pWorkToolSum.IsNew = pIsNew; string UserName = SubsonicHelper.GetUserName(); try { pWorkToolSum.Save(UserName); } catch (Exception ex) { LogManager.getInstance().getLogger(typeof(WorkToolSumInfo)).Error(ex); if (ex.Message.Contains("插入重复键")) //违反了唯一键 { throw new AppException("此对象已经存在"); //此处等待优化可以从唯一约束中直接取出提示来,如果没有的话,默认为原始的出错提示 } throw new AppException("保存失败"); } pWorkToolSumInfo.workToolSumId = pWorkToolSum.WorkToolSumId; //如果缓存存在,更新缓存 if (CachedEntityCommander.IsTypeRegistered(typeof(WorkToolSumInfo))) { ResetCache(); } }
protected void btnSave_Click(object sender, EventArgs e) { try { WorkToolSumInfo wt = new WorkToolSumInfo(); wt.DepartName = Session["DepartName"].ToString(); wt.ApplyName = Session["EmployeeName"].ToString(); wt.State = 0; wt.FuTime = txtFuTime.Text.ToString(); wt.UseDepartName = txtUseDepart.Text.ToString(); wt.Reason = txtReason.Text.ToString(); wt.BigMoney = txtBigMoney.Text.ToString(); wt.SmaMoney = txtSmallMoney.Text.ToString(); wt.MoneyStyle = txtFuMoney.Text.ToString(); wt.DepartView = txtDepartView.Text.ToString(); wt.Save(); Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('��ӳɹ���');</script>"); } catch (Exception Ex) { ClientScript.RegisterStartupScript(this.GetType(), "Save", "alert('���ʧ�ܣ�" + Ex.Message + "');", true); } }
//数据持久化 internal static void SaveToDb(WorkToolSumInfo pWorkToolSumInfo, WorkToolSum pWorkToolSum,bool pIsNew) { pWorkToolSum.WorkToolSumId = pWorkToolSumInfo.workToolSumId; pWorkToolSum.DepartName = pWorkToolSumInfo.departName; pWorkToolSum.Reason = pWorkToolSumInfo.reason; pWorkToolSum.BigMoney = pWorkToolSumInfo.bigMoney; pWorkToolSum.SmaMoney = pWorkToolSumInfo.smaMoney; pWorkToolSum.MoneyStyle = pWorkToolSumInfo.moneyStyle; pWorkToolSum.UseDepartName = pWorkToolSumInfo.useDepartName; pWorkToolSum.FuTime = pWorkToolSumInfo.fuTime; pWorkToolSum.ApplyName = pWorkToolSumInfo.applyName; pWorkToolSum.State = pWorkToolSumInfo.state; pWorkToolSum.ApplyTime = pWorkToolSumInfo.applyTime; pWorkToolSum.DepartView = pWorkToolSumInfo.departView; pWorkToolSum.ManagerView = pWorkToolSumInfo.managerView; pWorkToolSum.IsNew=pIsNew; string UserName = SubsonicHelper.GetUserName(); try { pWorkToolSum.Save(UserName); } catch(Exception ex) { LogManager.getInstance().getLogger(typeof(WorkToolSumInfo)).Error(ex); if(ex.Message.Contains("插入重复键"))//违反了唯一键 { throw new AppException("此对象已经存在");//此处等待优化可以从唯一约束中直接取出提示来,如果没有的话,默认为原始的出错提示 } throw new AppException("保存失败"); } pWorkToolSumInfo.workToolSumId = pWorkToolSum.WorkToolSumId; //如果缓存存在,更新缓存 if (CachedEntityCommander.IsTypeRegistered(typeof(WorkToolSumInfo))) { ResetCache(); } }
/// <summary> /// 复制一个对象,采用硬编码的方式,避免反射的低效 /// </summary> /// <param name="pIndustryTypeInfoFrom"></param> /// <param name="pIndustryTypeInfoTo"></param> public static void Copy(WorkToolSumInfo pWorkToolSumInfoFrom, WorkToolSumInfo pWorkToolSumInfoTo) { pWorkToolSumInfoTo.WorkToolSumId = pWorkToolSumInfoFrom.workToolSumId; pWorkToolSumInfoTo.DepartName = pWorkToolSumInfoFrom.departName; pWorkToolSumInfoTo.Reason = pWorkToolSumInfoFrom.reason; pWorkToolSumInfoTo.BigMoney = pWorkToolSumInfoFrom.bigMoney; pWorkToolSumInfoTo.SmaMoney = pWorkToolSumInfoFrom.smaMoney; pWorkToolSumInfoTo.MoneyStyle = pWorkToolSumInfoFrom.moneyStyle; pWorkToolSumInfoTo.UseDepartName = pWorkToolSumInfoFrom.useDepartName; pWorkToolSumInfoTo.FuTime = pWorkToolSumInfoFrom.fuTime; pWorkToolSumInfoTo.ApplyName = pWorkToolSumInfoFrom.applyName; pWorkToolSumInfoTo.State = pWorkToolSumInfoFrom.state; pWorkToolSumInfoTo.ApplyTime = pWorkToolSumInfoFrom.applyTime; pWorkToolSumInfoTo.DepartView = pWorkToolSumInfoFrom.departView; pWorkToolSumInfoTo.ManagerView = pWorkToolSumInfoFrom.managerView; pWorkToolSumInfoTo.Loaded=pWorkToolSumInfoFrom.Loaded; }
/// <summary> /// 复制为另一个对象 /// </summary> /// <param name="pIndustryTypeInfoTo"></param> public void CopyTo(WorkToolSumInfo pWorkToolSumInfoTo) { Copy(this, pWorkToolSumInfoTo); }
/// <summary> /// 获得数据列表 /// </summary> /// <returns></returns> public static List<WorkToolSumInfo> GetList() { string cacheKey = GetCacheKey(); //本实体已经注册成缓存实体,并且缓存存在的时候,直接从缓存取 if (CachedEntityCommander.IsTypeRegistered(typeof(WorkToolSumInfo)) && CachedEntityCommander.GetCache(cacheKey) != null) { return CachedEntityCommander.GetCache(cacheKey) as List< WorkToolSumInfo>; } else { List< WorkToolSumInfo> list =new List< WorkToolSumInfo>(); WorkToolSumCollection collection=new WorkToolSumCollection(); Query qry = new Query(WorkToolSum.Schema); collection.LoadAndCloseReader(qry.ExecuteReader()); foreach(WorkToolSum workToolSum in collection) { WorkToolSumInfo workToolSumInfo= new WorkToolSumInfo(); LoadFromDAL(workToolSumInfo,workToolSum); list.Add(workToolSumInfo); } //生成缓存 if (CachedEntityCommander.IsTypeRegistered(typeof(WorkToolSumInfo))) { CachedEntityCommander.SetCache(cacheKey, list); } return list; } }
public object SaveWorkToolSumInfo(WorkToolSumInfo workToolSumInfo) { workToolSumInfo.Save(); return workToolSumInfo . WorkToolSumId; }
/// <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<WorkToolSumInfo> GetPagedList(int pPageIndex,int pPageSize,SortDirection pOrderBy,string pSortExpression,out int pRecordCount) { if(pPageIndex<=1) pPageIndex=1; List< WorkToolSumInfo> list = new List< WorkToolSumInfo>(); Query q = WorkToolSum .CreateQuery(); q.PageIndex = pPageIndex; q.PageSize = pPageSize; q.ORDER_BY(pSortExpression,pOrderBy.ToString()); WorkToolSumCollection collection=new WorkToolSumCollection(); collection.LoadAndCloseReader(q.ExecuteReader()); foreach (WorkToolSum workToolSum in collection) { WorkToolSumInfo workToolSumInfo = new WorkToolSumInfo(); LoadFromDAL(workToolSumInfo, workToolSum); list.Add(workToolSumInfo); } pRecordCount=q.GetRecordCount(); return list; }
public void DeleteById(WorkToolSumInfo pWorkToolSumInfo) { WorkToolSumInfo workToolSumInfo = new WorkToolSumInfo(pWorkToolSumInfo.WorkToolSumId); workToolSumInfo.Delete(); }
public object SaveWorkToolSumInfo(WorkToolSumInfo workToolSumInfo) { workToolSumInfo.Save(); return(workToolSumInfo.WorkToolSumId); }
public List <WorkToolSumInfo> GetPagedList(int pPageIndex, int pPageSize, SortDirection pOrderBy, string pSortExpression, out int pRecordCount) { return(WorkToolSumInfo.GetPagedList(pPageIndex, pPageSize, pOrderBy, pSortExpression, out pRecordCount)); }
public List <WorkToolSumInfo> GetWorkToolSumInfoList() { return(WorkToolSumInfo.GetList()); }
//从后台获取数据 internal static void LoadFromDAL(WorkToolSumInfo pWorkToolSumInfo, WorkToolSum pWorkToolSum) { pWorkToolSumInfo.workToolSumId = pWorkToolSum.WorkToolSumId; pWorkToolSumInfo.departName = pWorkToolSum.DepartName; pWorkToolSumInfo.reason = pWorkToolSum.Reason; pWorkToolSumInfo.bigMoney = pWorkToolSum.BigMoney; pWorkToolSumInfo.smaMoney = pWorkToolSum.SmaMoney; pWorkToolSumInfo.moneyStyle = pWorkToolSum.MoneyStyle; pWorkToolSumInfo.useDepartName = pWorkToolSum.UseDepartName; pWorkToolSumInfo.fuTime = pWorkToolSum.FuTime; pWorkToolSumInfo.applyName = pWorkToolSum.ApplyName; pWorkToolSumInfo.state = pWorkToolSum.State; pWorkToolSumInfo.applyTime = pWorkToolSum.ApplyTime; pWorkToolSumInfo.departView = pWorkToolSum.DepartView; pWorkToolSumInfo.managerView = pWorkToolSum.ManagerView; pWorkToolSumInfo.Loaded=true; }
/// <summary> /// 批量装载 /// </summary> internal static void LoadFromDALPatch(List< WorkToolSumInfo> pList, WorkToolSumCollection pCollection) { foreach (WorkToolSum workToolSum in pCollection) { WorkToolSumInfo workToolSumInfo = new WorkToolSumInfo(); LoadFromDAL(workToolSumInfo, workToolSum ); pList.Add(workToolSumInfo); } }