/// <summary> /// 获得数据列表 /// </summary> /// <returns></returns> public static List <SpecialExpInfo> GetList() { string cacheKey = GetCacheKey(); //本实体已经注册成缓存实体,并且缓存存在的时候,直接从缓存取 if (CachedEntityCommander.IsTypeRegistered(typeof(SpecialExpInfo)) && CachedEntityCommander.GetCache(cacheKey) != null) { return(CachedEntityCommander.GetCache(cacheKey) as List <SpecialExpInfo>); } else { List <SpecialExpInfo> list = new List <SpecialExpInfo>(); SpecialExpCollection collection = new SpecialExpCollection(); Query qry = new Query(SpecialExp.Schema); collection.LoadAndCloseReader(qry.ExecuteReader()); foreach (SpecialExp specialExp in collection) { SpecialExpInfo specialExpInfo = new SpecialExpInfo(); LoadFromDAL(specialExpInfo, specialExp); list.Add(specialExpInfo); } //生成缓存 if (CachedEntityCommander.IsTypeRegistered(typeof(SpecialExpInfo))) { CachedEntityCommander.SetCache(cacheKey, list); } return(list); } }
protected void btnSave_Click(object sender, EventArgs e) { try { int id = Convert.ToInt32(Request["SpecialExpId"].ToString()); SpecialExpInfo sp = new SpecialExpInfo(id); sp.IsApply2 = 1; DateTime dt = DateTime.Now; sp.Apply2Time = dt; if (rblOver.Items[0].Selected) { sp.IsOver2 = 0; sp.IsNewCreate = 1; sp.Save(); Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('����������������');</script>"); } else { sp.IsOver2 = 1; sp.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 <SpecialExpInfo> GetPagedList(int pPageIndex, int pPageSize, SortDirection pOrderBy, string pSortExpression, out int pRecordCount) { if (pPageIndex <= 1) { pPageIndex = 1; } List <SpecialExpInfo> list = new List <SpecialExpInfo>(); Query q = SpecialExp.CreateQuery(); q.PageIndex = pPageIndex; q.PageSize = pPageSize; q.ORDER_BY(pSortExpression, pOrderBy.ToString()); SpecialExpCollection collection = new SpecialExpCollection(); collection.LoadAndCloseReader(q.ExecuteReader()); foreach (SpecialExp specialExp in collection) { SpecialExpInfo specialExpInfo = new SpecialExpInfo(); LoadFromDAL(specialExpInfo, specialExp); list.Add(specialExpInfo); } pRecordCount = q.GetRecordCount(); return(list); }
protected void PageInit() { int wkid = Convert.ToInt32(Request["SpecialExpId"].ToString()); SpecialExpInfo sp = new SpecialExpInfo(wkid); lblApplyDate.Text = sp.ApplyDate.ToString(); lblApplyPeople.Text = sp.ApplyPeople.ToString(); MainProjectCreateInfo project = new MainProjectCreateInfo(Convert.ToInt32(sp.MainProjectCreateId)); lblMoneyNum.Text = project.PreMoney.ToString(); lblProject.Text = project.ProjectName.ToString(); txtReason.Text = sp.ApplyReason.ToString(); if (sp.ProjectStepId.ToString() != "") { ProjectStepInfo step = new ProjectStepInfo(Convert.ToInt32(sp.ProjectStepId)); lblStep.Text = step.ProjectStepName.ToString(); } lblApplyMoney.Text = sp.ApplyMoney.ToString(); lblSheetNum.Text = sp.SheetNum.ToString(); if (sp.SignName == 1) { imgMarket.Visible = true; } else if (sp.SignName == 2) { imgMarket.Visible = true; imgManager.Visible = true; } }
/// <summary> /// 批量装载 /// </summary> internal static void LoadFromDALPatch(List <SpecialExpInfo> pList, SpecialExpCollection pCollection) { foreach (SpecialExp specialExp in pCollection) { SpecialExpInfo specialExpInfo = new SpecialExpInfo(); LoadFromDAL(specialExpInfo, specialExp); pList.Add(specialExpInfo); } }
public SpecialExpInfo GetSpecialExpInfoById(int SpecialExpId) { SpecialExpInfo specialExpInfo = null; // try { specialExpInfo = new SpecialExpInfo(SpecialExpId); } catch (AppException) { return(null); } return(specialExpInfo); }
public SpecialExpInfo GetSpecialExpInfoById(int SpecialExpId) { SpecialExpInfo specialExpInfo = null;// try { specialExpInfo = new SpecialExpInfo(SpecialExpId); } catch (AppException) { return null; } return specialExpInfo; }
//从后台获取数据 internal static void LoadFromDAL(SpecialExpInfo pSpecialExpInfo, SpecialExp pSpecialExp) { pSpecialExpInfo.specialExpId = pSpecialExp.SpecialExpId; pSpecialExpInfo.mainSpecialExpId = pSpecialExp.MainSpecialExpId; pSpecialExpInfo.projectStepId = pSpecialExp.ProjectStepId; pSpecialExpInfo.mainProjectCreateId = pSpecialExp.MainProjectCreateId; pSpecialExpInfo.sheetNum = pSpecialExp.SheetNum; pSpecialExpInfo.applyPeople = pSpecialExp.ApplyPeople; pSpecialExpInfo.applyDate = pSpecialExp.ApplyDate; pSpecialExpInfo.applyReason = pSpecialExp.ApplyReason; pSpecialExpInfo.preIsApply = pSpecialExp.PreIsApply; pSpecialExpInfo.isApprove = pSpecialExp.IsApprove; pSpecialExpInfo.isApply = pSpecialExp.IsApply; pSpecialExpInfo.isApply1 = pSpecialExp.IsApply1; pSpecialExpInfo.isApply2 = pSpecialExp.IsApply2; pSpecialExpInfo.preIsOver = pSpecialExp.PreIsOver; pSpecialExpInfo.isOver1 = pSpecialExp.IsOver1; pSpecialExpInfo.isOver2 = pSpecialExp.IsOver2; pSpecialExpInfo.preApplyTime = pSpecialExp.PreApplyTime; pSpecialExpInfo.approveTime = pSpecialExp.ApproveTime; pSpecialExpInfo.applyTime = pSpecialExp.ApplyTime; pSpecialExpInfo.apply1Time = pSpecialExp.Apply1Time; pSpecialExpInfo.apply2Time = pSpecialExp.Apply2Time; pSpecialExpInfo.preEmployeeId = pSpecialExp.PreEmployeeId; pSpecialExpInfo.sendEmployeeId = pSpecialExp.SendEmployeeId; pSpecialExpInfo.recvEmployeeId = pSpecialExp.RecvEmployeeId; pSpecialExpInfo.recv1EmployeeId = pSpecialExp.Recv1EmployeeId; pSpecialExpInfo.recv2EmployeeId = pSpecialExp.Recv2EmployeeId; pSpecialExpInfo.preEmployeeName = pSpecialExp.PreEmployeeName; pSpecialExpInfo.sendEmployeeName = pSpecialExp.SendEmployeeName; pSpecialExpInfo.recvEmployeeName = pSpecialExp.RecvEmployeeName; pSpecialExpInfo.recv1EmployeeName = pSpecialExp.Recv1EmployeeName; pSpecialExpInfo.recv2EmployeeName = pSpecialExp.Recv2EmployeeName; pSpecialExpInfo.isNewCreate = pSpecialExp.IsNewCreate; pSpecialExpInfo.isMain = pSpecialExp.IsMain; pSpecialExpInfo.isMain1 = pSpecialExp.IsMain1; pSpecialExpInfo.isMain2 = pSpecialExp.IsMain2; pSpecialExpInfo.isMain3 = pSpecialExp.IsMain3; pSpecialExpInfo.applyMoney = pSpecialExp.ApplyMoney; pSpecialExpInfo.today = pSpecialExp.Today; pSpecialExpInfo.signName = pSpecialExp.SignName; pSpecialExpInfo.Loaded = true; }
/// <summary> /// 复制一个对象,采用硬编码的方式,避免反射的低效 /// </summary> /// <param name="pIndustryTypeInfoFrom"></param> /// <param name="pIndustryTypeInfoTo"></param> public static void Copy(SpecialExpInfo pSpecialExpInfoFrom, SpecialExpInfo pSpecialExpInfoTo) { pSpecialExpInfoTo.SpecialExpId = pSpecialExpInfoFrom.specialExpId; pSpecialExpInfoTo.MainSpecialExpId = pSpecialExpInfoFrom.mainSpecialExpId; pSpecialExpInfoTo.ProjectStepId = pSpecialExpInfoFrom.projectStepId; pSpecialExpInfoTo.MainProjectCreateId = pSpecialExpInfoFrom.mainProjectCreateId; pSpecialExpInfoTo.SheetNum = pSpecialExpInfoFrom.sheetNum; pSpecialExpInfoTo.ApplyPeople = pSpecialExpInfoFrom.applyPeople; pSpecialExpInfoTo.ApplyDate = pSpecialExpInfoFrom.applyDate; pSpecialExpInfoTo.ApplyReason = pSpecialExpInfoFrom.applyReason; pSpecialExpInfoTo.PreIsApply = pSpecialExpInfoFrom.preIsApply; pSpecialExpInfoTo.IsApprove = pSpecialExpInfoFrom.isApprove; pSpecialExpInfoTo.IsApply = pSpecialExpInfoFrom.isApply; pSpecialExpInfoTo.IsApply1 = pSpecialExpInfoFrom.isApply1; pSpecialExpInfoTo.IsApply2 = pSpecialExpInfoFrom.isApply2; pSpecialExpInfoTo.PreIsOver = pSpecialExpInfoFrom.preIsOver; pSpecialExpInfoTo.IsOver1 = pSpecialExpInfoFrom.isOver1; pSpecialExpInfoTo.IsOver2 = pSpecialExpInfoFrom.isOver2; pSpecialExpInfoTo.PreApplyTime = pSpecialExpInfoFrom.preApplyTime; pSpecialExpInfoTo.ApproveTime = pSpecialExpInfoFrom.approveTime; pSpecialExpInfoTo.ApplyTime = pSpecialExpInfoFrom.applyTime; pSpecialExpInfoTo.Apply1Time = pSpecialExpInfoFrom.apply1Time; pSpecialExpInfoTo.Apply2Time = pSpecialExpInfoFrom.apply2Time; pSpecialExpInfoTo.PreEmployeeId = pSpecialExpInfoFrom.preEmployeeId; pSpecialExpInfoTo.SendEmployeeId = pSpecialExpInfoFrom.sendEmployeeId; pSpecialExpInfoTo.RecvEmployeeId = pSpecialExpInfoFrom.recvEmployeeId; pSpecialExpInfoTo.Recv1EmployeeId = pSpecialExpInfoFrom.recv1EmployeeId; pSpecialExpInfoTo.Recv2EmployeeId = pSpecialExpInfoFrom.recv2EmployeeId; pSpecialExpInfoTo.PreEmployeeName = pSpecialExpInfoFrom.preEmployeeName; pSpecialExpInfoTo.SendEmployeeName = pSpecialExpInfoFrom.sendEmployeeName; pSpecialExpInfoTo.RecvEmployeeName = pSpecialExpInfoFrom.recvEmployeeName; pSpecialExpInfoTo.Recv1EmployeeName = pSpecialExpInfoFrom.recv1EmployeeName; pSpecialExpInfoTo.Recv2EmployeeName = pSpecialExpInfoFrom.recv2EmployeeName; pSpecialExpInfoTo.IsNewCreate = pSpecialExpInfoFrom.isNewCreate; pSpecialExpInfoTo.IsMain = pSpecialExpInfoFrom.isMain; pSpecialExpInfoTo.IsMain1 = pSpecialExpInfoFrom.isMain1; pSpecialExpInfoTo.IsMain2 = pSpecialExpInfoFrom.isMain2; pSpecialExpInfoTo.IsMain3 = pSpecialExpInfoFrom.isMain3; pSpecialExpInfoTo.ApplyMoney = pSpecialExpInfoFrom.applyMoney; pSpecialExpInfoTo.Today = pSpecialExpInfoFrom.today; pSpecialExpInfoTo.SignName = pSpecialExpInfoFrom.signName; pSpecialExpInfoTo.Loaded = pSpecialExpInfoFrom.Loaded; }
protected void SpecialBind() { int wkid = Convert.ToInt32(Request["SpecialExpId"].ToString()); SpecialExpInfo sp = new SpecialExpInfo(wkid); lblApplyDate.Text = sp.ApplyDate.ToString(); lblApplyPeople.Text = sp.ApplyPeople.ToString(); lblApplyMoney.Text = sp.ApplyMoney.ToString(); lblSheetNum.Text = sp.SheetNum.ToString(); MainProjectCreateInfo project = new MainProjectCreateInfo(Convert.ToInt32(sp.MainProjectCreateId)); lblMoneyNum.Text = project.PreMoney.ToString(); lblProject.Text = project.ProjectName.ToString(); lblReason.Text = sp.ApplyReason.ToString(); if (sp.ProjectStepId.ToString() != "") { ProjectStepInfo step = new ProjectStepInfo(Convert.ToInt32(sp.ProjectStepId)); lblStep.Text = step.ProjectStepName.ToString(); } }
private void LoadFromId(int specialExpId) { if (CachedEntityCommander.IsTypeRegistered(typeof(SpecialExpInfo))) { SpecialExpInfo specialExpInfo = Find(GetList(), specialExpId); if (specialExpInfo == null) { throw new AppException("未能在缓存中找到相应的键值对象"); } Copy(specialExpInfo, this); } else { SpecialExp specialExp = new SpecialExp(specialExpId); if (specialExp.IsNew) { throw new AppException("尚未初始化"); } LoadFromDAL(this, specialExp); } }
protected void btnSave_Click(object sender, EventArgs e) { if (IsPageValid()) { try { EmployeeInfo em = (EmployeeInfo)Session["Employee"]; int wkid = Convert.ToInt32(Request["SpecialExpId"].ToString()); SpecialExpInfo pc = new SpecialExpInfo(wkid); pc.IsApprove = 1; pc.SignName = 1; DateTime date = DateTime.Now; pc.ApproveTime = date; if (rblOver.Items[0].Selected) { pc.PreIsOver = 0; pc.IsNewCreate = 1; pc.Save(); Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('����������������');</script>"); } else if (rblOver.Items[1].Selected) { pc.PreIsOver = 1; int emid = Convert.ToInt32(Common.getEmployeeIdOfManager());//�ܾ������ pc.Recv1EmployeeId = emid; pc.Save(); Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('����ͨ����');</script>"); } } catch (Exception Ex) { ClientScript.RegisterStartupScript(this.GetType(), "Save", "alert('����ʧ�ܣ�" + Ex.Message + "');", true); } } }
protected void btnSubmit_Click(object sender, EventArgs e) { int wksumId = Convert.ToInt32(((Button)sender).CommandArgument.ToString()); SpecialExpInfo wksum = new SpecialExpInfo(wksumId); wksum.IsApply = 1; DateTime date = DateTime.Now; wksum.ApplyTime = date; int recvemid = Convert.ToInt32(Common.getEmployeeIdOfManager());//ֻ���ܾ����ܽ��շ�������� wksum.Recv1EmployeeId = recvemid; wksum.Save(); gvDataBind(); Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('����ɹ���');</script>"); }
/// <summary> /// 批量装载 /// </summary> internal static void LoadFromDALPatch(List< SpecialExpInfo> pList, SpecialExpCollection pCollection) { foreach (SpecialExp specialExp in pCollection) { SpecialExpInfo specialExpInfo = new SpecialExpInfo(); LoadFromDAL(specialExpInfo, specialExp ); pList.Add(specialExpInfo); } }
//数据持久化 internal static void SaveToDb(SpecialExpInfo pSpecialExpInfo, SpecialExp pSpecialExp,bool pIsNew) { pSpecialExp.SpecialExpId = pSpecialExpInfo.specialExpId; pSpecialExp.MainSpecialExpId = pSpecialExpInfo.mainSpecialExpId; pSpecialExp.ProjectStepId = pSpecialExpInfo.projectStepId; pSpecialExp.MainProjectCreateId = pSpecialExpInfo.mainProjectCreateId; pSpecialExp.SheetNum = pSpecialExpInfo.sheetNum; pSpecialExp.ApplyPeople = pSpecialExpInfo.applyPeople; pSpecialExp.ApplyDate = pSpecialExpInfo.applyDate; pSpecialExp.ApplyReason = pSpecialExpInfo.applyReason; pSpecialExp.PreIsApply = pSpecialExpInfo.preIsApply; pSpecialExp.IsApprove = pSpecialExpInfo.isApprove; pSpecialExp.IsApply = pSpecialExpInfo.isApply; pSpecialExp.IsApply1 = pSpecialExpInfo.isApply1; pSpecialExp.IsApply2 = pSpecialExpInfo.isApply2; pSpecialExp.PreIsOver = pSpecialExpInfo.preIsOver; pSpecialExp.IsOver1 = pSpecialExpInfo.isOver1; pSpecialExp.IsOver2 = pSpecialExpInfo.isOver2; pSpecialExp.PreApplyTime = pSpecialExpInfo.preApplyTime; pSpecialExp.ApproveTime = pSpecialExpInfo.approveTime; pSpecialExp.ApplyTime = pSpecialExpInfo.applyTime; pSpecialExp.Apply1Time = pSpecialExpInfo.apply1Time; pSpecialExp.Apply2Time = pSpecialExpInfo.apply2Time; pSpecialExp.PreEmployeeId = pSpecialExpInfo.preEmployeeId; pSpecialExp.SendEmployeeId = pSpecialExpInfo.sendEmployeeId; pSpecialExp.RecvEmployeeId = pSpecialExpInfo.recvEmployeeId; pSpecialExp.Recv1EmployeeId = pSpecialExpInfo.recv1EmployeeId; pSpecialExp.Recv2EmployeeId = pSpecialExpInfo.recv2EmployeeId; pSpecialExp.PreEmployeeName = pSpecialExpInfo.preEmployeeName; pSpecialExp.SendEmployeeName = pSpecialExpInfo.sendEmployeeName; pSpecialExp.RecvEmployeeName = pSpecialExpInfo.recvEmployeeName; pSpecialExp.Recv1EmployeeName = pSpecialExpInfo.recv1EmployeeName; pSpecialExp.Recv2EmployeeName = pSpecialExpInfo.recv2EmployeeName; pSpecialExp.IsNewCreate = pSpecialExpInfo.isNewCreate; pSpecialExp.IsMain = pSpecialExpInfo.isMain; pSpecialExp.IsMain1 = pSpecialExpInfo.isMain1; pSpecialExp.IsMain2 = pSpecialExpInfo.isMain2; pSpecialExp.IsMain3 = pSpecialExpInfo.isMain3; pSpecialExp.ApplyMoney = pSpecialExpInfo.applyMoney; pSpecialExp.Today = pSpecialExpInfo.today; pSpecialExp.SignName = pSpecialExpInfo.signName; pSpecialExp.IsNew=pIsNew; string UserName = SubsonicHelper.GetUserName(); try { pSpecialExp.Save(UserName); } catch(Exception ex) { LogManager.getInstance().getLogger(typeof(SpecialExpInfo)).Error(ex); if(ex.Message.Contains("插入重复键"))//违反了唯一键 { throw new AppException("此对象已经存在");//此处等待优化可以从唯一约束中直接取出提示来,如果没有的话,默认为原始的出错提示 } throw new AppException("保存失败"); } pSpecialExpInfo.specialExpId = pSpecialExp.SpecialExpId; //如果缓存存在,更新缓存 if (CachedEntityCommander.IsTypeRegistered(typeof(SpecialExpInfo))) { ResetCache(); } }
/// <summary> /// 复制为另一个对象 /// </summary> /// <param name="pIndustryTypeInfoTo"></param> public void CopyTo(SpecialExpInfo pSpecialExpInfoTo) { Copy(this, pSpecialExpInfoTo); }
//从后台获取数据 internal static void LoadFromDAL(SpecialExpInfo pSpecialExpInfo, SpecialExp pSpecialExp) { pSpecialExpInfo.specialExpId = pSpecialExp.SpecialExpId; pSpecialExpInfo.mainSpecialExpId = pSpecialExp.MainSpecialExpId; pSpecialExpInfo.projectStepId = pSpecialExp.ProjectStepId; pSpecialExpInfo.mainProjectCreateId = pSpecialExp.MainProjectCreateId; pSpecialExpInfo.sheetNum = pSpecialExp.SheetNum; pSpecialExpInfo.applyPeople = pSpecialExp.ApplyPeople; pSpecialExpInfo.applyDate = pSpecialExp.ApplyDate; pSpecialExpInfo.applyReason = pSpecialExp.ApplyReason; pSpecialExpInfo.preIsApply = pSpecialExp.PreIsApply; pSpecialExpInfo.isApprove = pSpecialExp.IsApprove; pSpecialExpInfo.isApply = pSpecialExp.IsApply; pSpecialExpInfo.isApply1 = pSpecialExp.IsApply1; pSpecialExpInfo.isApply2 = pSpecialExp.IsApply2; pSpecialExpInfo.preIsOver = pSpecialExp.PreIsOver; pSpecialExpInfo.isOver1 = pSpecialExp.IsOver1; pSpecialExpInfo.isOver2 = pSpecialExp.IsOver2; pSpecialExpInfo.preApplyTime = pSpecialExp.PreApplyTime; pSpecialExpInfo.approveTime = pSpecialExp.ApproveTime; pSpecialExpInfo.applyTime = pSpecialExp.ApplyTime; pSpecialExpInfo.apply1Time = pSpecialExp.Apply1Time; pSpecialExpInfo.apply2Time = pSpecialExp.Apply2Time; pSpecialExpInfo.preEmployeeId = pSpecialExp.PreEmployeeId; pSpecialExpInfo.sendEmployeeId = pSpecialExp.SendEmployeeId; pSpecialExpInfo.recvEmployeeId = pSpecialExp.RecvEmployeeId; pSpecialExpInfo.recv1EmployeeId = pSpecialExp.Recv1EmployeeId; pSpecialExpInfo.recv2EmployeeId = pSpecialExp.Recv2EmployeeId; pSpecialExpInfo.preEmployeeName = pSpecialExp.PreEmployeeName; pSpecialExpInfo.sendEmployeeName = pSpecialExp.SendEmployeeName; pSpecialExpInfo.recvEmployeeName = pSpecialExp.RecvEmployeeName; pSpecialExpInfo.recv1EmployeeName = pSpecialExp.Recv1EmployeeName; pSpecialExpInfo.recv2EmployeeName = pSpecialExp.Recv2EmployeeName; pSpecialExpInfo.isNewCreate = pSpecialExp.IsNewCreate; pSpecialExpInfo.isMain = pSpecialExp.IsMain; pSpecialExpInfo.isMain1 = pSpecialExp.IsMain1; pSpecialExpInfo.isMain2 = pSpecialExp.IsMain2; pSpecialExpInfo.isMain3 = pSpecialExp.IsMain3; pSpecialExpInfo.applyMoney = pSpecialExp.ApplyMoney; pSpecialExpInfo.today = pSpecialExp.Today; pSpecialExpInfo.signName = pSpecialExp.SignName; pSpecialExpInfo.Loaded=true; }
//数据持久化 internal static void SaveToDb(SpecialExpInfo pSpecialExpInfo, SpecialExp pSpecialExp, bool pIsNew) { pSpecialExp.SpecialExpId = pSpecialExpInfo.specialExpId; pSpecialExp.MainSpecialExpId = pSpecialExpInfo.mainSpecialExpId; pSpecialExp.ProjectStepId = pSpecialExpInfo.projectStepId; pSpecialExp.MainProjectCreateId = pSpecialExpInfo.mainProjectCreateId; pSpecialExp.SheetNum = pSpecialExpInfo.sheetNum; pSpecialExp.ApplyPeople = pSpecialExpInfo.applyPeople; pSpecialExp.ApplyDate = pSpecialExpInfo.applyDate; pSpecialExp.ApplyReason = pSpecialExpInfo.applyReason; pSpecialExp.PreIsApply = pSpecialExpInfo.preIsApply; pSpecialExp.IsApprove = pSpecialExpInfo.isApprove; pSpecialExp.IsApply = pSpecialExpInfo.isApply; pSpecialExp.IsApply1 = pSpecialExpInfo.isApply1; pSpecialExp.IsApply2 = pSpecialExpInfo.isApply2; pSpecialExp.PreIsOver = pSpecialExpInfo.preIsOver; pSpecialExp.IsOver1 = pSpecialExpInfo.isOver1; pSpecialExp.IsOver2 = pSpecialExpInfo.isOver2; pSpecialExp.PreApplyTime = pSpecialExpInfo.preApplyTime; pSpecialExp.ApproveTime = pSpecialExpInfo.approveTime; pSpecialExp.ApplyTime = pSpecialExpInfo.applyTime; pSpecialExp.Apply1Time = pSpecialExpInfo.apply1Time; pSpecialExp.Apply2Time = pSpecialExpInfo.apply2Time; pSpecialExp.PreEmployeeId = pSpecialExpInfo.preEmployeeId; pSpecialExp.SendEmployeeId = pSpecialExpInfo.sendEmployeeId; pSpecialExp.RecvEmployeeId = pSpecialExpInfo.recvEmployeeId; pSpecialExp.Recv1EmployeeId = pSpecialExpInfo.recv1EmployeeId; pSpecialExp.Recv2EmployeeId = pSpecialExpInfo.recv2EmployeeId; pSpecialExp.PreEmployeeName = pSpecialExpInfo.preEmployeeName; pSpecialExp.SendEmployeeName = pSpecialExpInfo.sendEmployeeName; pSpecialExp.RecvEmployeeName = pSpecialExpInfo.recvEmployeeName; pSpecialExp.Recv1EmployeeName = pSpecialExpInfo.recv1EmployeeName; pSpecialExp.Recv2EmployeeName = pSpecialExpInfo.recv2EmployeeName; pSpecialExp.IsNewCreate = pSpecialExpInfo.isNewCreate; pSpecialExp.IsMain = pSpecialExpInfo.isMain; pSpecialExp.IsMain1 = pSpecialExpInfo.isMain1; pSpecialExp.IsMain2 = pSpecialExpInfo.isMain2; pSpecialExp.IsMain3 = pSpecialExpInfo.isMain3; pSpecialExp.ApplyMoney = pSpecialExpInfo.applyMoney; pSpecialExp.Today = pSpecialExpInfo.today; pSpecialExp.SignName = pSpecialExpInfo.signName; pSpecialExp.IsNew = pIsNew; string UserName = SubsonicHelper.GetUserName(); try { pSpecialExp.Save(UserName); } catch (Exception ex) { LogManager.getInstance().getLogger(typeof(SpecialExpInfo)).Error(ex); if (ex.Message.Contains("插入重复键")) //违反了唯一键 { throw new AppException("此对象已经存在"); //此处等待优化可以从唯一约束中直接取出提示来,如果没有的话,默认为原始的出错提示 } throw new AppException("保存失败"); } pSpecialExpInfo.specialExpId = pSpecialExp.SpecialExpId; //如果缓存存在,更新缓存 if (CachedEntityCommander.IsTypeRegistered(typeof(SpecialExpInfo))) { ResetCache(); } }
public List <SpecialExpInfo> GetPagedList(int pPageIndex, int pPageSize, SortDirection pOrderBy, string pSortExpression, out int pRecordCount) { return(SpecialExpInfo.GetPagedList(pPageIndex, pPageSize, pOrderBy, pSortExpression, out pRecordCount)); }
public object SaveSpecialExpInfo(SpecialExpInfo specialExpInfo) { specialExpInfo.Save(); return specialExpInfo . SpecialExpId; }
/// <summary> /// 复制一个对象,采用硬编码的方式,避免反射的低效 /// </summary> /// <param name="pIndustryTypeInfoFrom"></param> /// <param name="pIndustryTypeInfoTo"></param> public static void Copy(SpecialExpInfo pSpecialExpInfoFrom, SpecialExpInfo pSpecialExpInfoTo) { pSpecialExpInfoTo.SpecialExpId = pSpecialExpInfoFrom.specialExpId; pSpecialExpInfoTo.MainSpecialExpId = pSpecialExpInfoFrom.mainSpecialExpId; pSpecialExpInfoTo.ProjectStepId = pSpecialExpInfoFrom.projectStepId; pSpecialExpInfoTo.MainProjectCreateId = pSpecialExpInfoFrom.mainProjectCreateId; pSpecialExpInfoTo.SheetNum = pSpecialExpInfoFrom.sheetNum; pSpecialExpInfoTo.ApplyPeople = pSpecialExpInfoFrom.applyPeople; pSpecialExpInfoTo.ApplyDate = pSpecialExpInfoFrom.applyDate; pSpecialExpInfoTo.ApplyReason = pSpecialExpInfoFrom.applyReason; pSpecialExpInfoTo.PreIsApply = pSpecialExpInfoFrom.preIsApply; pSpecialExpInfoTo.IsApprove = pSpecialExpInfoFrom.isApprove; pSpecialExpInfoTo.IsApply = pSpecialExpInfoFrom.isApply; pSpecialExpInfoTo.IsApply1 = pSpecialExpInfoFrom.isApply1; pSpecialExpInfoTo.IsApply2 = pSpecialExpInfoFrom.isApply2; pSpecialExpInfoTo.PreIsOver = pSpecialExpInfoFrom.preIsOver; pSpecialExpInfoTo.IsOver1 = pSpecialExpInfoFrom.isOver1; pSpecialExpInfoTo.IsOver2 = pSpecialExpInfoFrom.isOver2; pSpecialExpInfoTo.PreApplyTime = pSpecialExpInfoFrom.preApplyTime; pSpecialExpInfoTo.ApproveTime = pSpecialExpInfoFrom.approveTime; pSpecialExpInfoTo.ApplyTime = pSpecialExpInfoFrom.applyTime; pSpecialExpInfoTo.Apply1Time = pSpecialExpInfoFrom.apply1Time; pSpecialExpInfoTo.Apply2Time = pSpecialExpInfoFrom.apply2Time; pSpecialExpInfoTo.PreEmployeeId = pSpecialExpInfoFrom.preEmployeeId; pSpecialExpInfoTo.SendEmployeeId = pSpecialExpInfoFrom.sendEmployeeId; pSpecialExpInfoTo.RecvEmployeeId = pSpecialExpInfoFrom.recvEmployeeId; pSpecialExpInfoTo.Recv1EmployeeId = pSpecialExpInfoFrom.recv1EmployeeId; pSpecialExpInfoTo.Recv2EmployeeId = pSpecialExpInfoFrom.recv2EmployeeId; pSpecialExpInfoTo.PreEmployeeName = pSpecialExpInfoFrom.preEmployeeName; pSpecialExpInfoTo.SendEmployeeName = pSpecialExpInfoFrom.sendEmployeeName; pSpecialExpInfoTo.RecvEmployeeName = pSpecialExpInfoFrom.recvEmployeeName; pSpecialExpInfoTo.Recv1EmployeeName = pSpecialExpInfoFrom.recv1EmployeeName; pSpecialExpInfoTo.Recv2EmployeeName = pSpecialExpInfoFrom.recv2EmployeeName; pSpecialExpInfoTo.IsNewCreate = pSpecialExpInfoFrom.isNewCreate; pSpecialExpInfoTo.IsMain = pSpecialExpInfoFrom.isMain; pSpecialExpInfoTo.IsMain1 = pSpecialExpInfoFrom.isMain1; pSpecialExpInfoTo.IsMain2 = pSpecialExpInfoFrom.isMain2; pSpecialExpInfoTo.IsMain3 = pSpecialExpInfoFrom.isMain3; pSpecialExpInfoTo.ApplyMoney = pSpecialExpInfoFrom.applyMoney; pSpecialExpInfoTo.Today = pSpecialExpInfoFrom.today; pSpecialExpInfoTo.SignName = pSpecialExpInfoFrom.signName; pSpecialExpInfoTo.Loaded=pSpecialExpInfoFrom.Loaded; }
public void DeleteById(SpecialExpInfo pSpecialExpInfo) { SpecialExpInfo specialExpInfo = new SpecialExpInfo(pSpecialExpInfo.SpecialExpId); specialExpInfo.Delete(); }
public List <SpecialExpInfo> GetSpecialExpInfoList() { return(SpecialExpInfo.GetList()); }
protected void btnSave_Click(object sender, EventArgs e) { if (IsPageValid()) { try { int id = Convert.ToInt32(Request["SpecialExpId"].ToString()); SpecialExpInfo sp = new SpecialExpInfo(id); if (sp.IsNewCreate == 1) { sp.IsMain = 0; sp.IsMain1 = 0; sp.IsMain2 = 0; sp.IsMain3 = 0; SpecialExpInfo spnew = new SpecialExpInfo(); spnew.IsNewCreate = 0; spnew.IsMain = 1; spnew.IsMain1 = 1; spnew.IsMain2 = 1; spnew.IsMain3 = 1; spnew.MainSpecialExpId = sp.MainSpecialExpId; string strRoleName = Session["RoleName"].ToString(); if (strRoleName == "���ž���") { spnew.SendEmployeeId = sp.SendEmployeeId; spnew.SendEmployeeName = sp.SendEmployeeName; spnew.PreIsApply = 1; spnew.PreIsOver = 1; spnew.SignName = 1; } else { spnew.PreEmployeeId = sp.PreEmployeeId; spnew.PreEmployeeName = sp.PreEmployeeName; spnew.PreIsApply = 0; spnew.PreIsOver = 0; spnew.SignName = 0; } spnew.IsApply = 0; spnew.IsApprove = 0; spnew.IsApply1 = 0; spnew.IsApply2 = 0; spnew.IsOver1 = 0; spnew.IsOver2 = 0; DateTime date = DateTime.Now; string strtoday = DateTime.Now.ToString("yyyyMMdd").Substring(2); spnew.Today = strtoday; spnew.SheetNum = txtSheetNum.Text.ToString(); spnew.ApplyDate = Convert.ToDateTime(txtApplyDate.Text.ToString()); spnew.ApplyPeople = lblApplyPeople.Text.ToString(); spnew.ApplyReason = txtReason.Text.ToString(); spnew.ApplyMoney = txtApplyMoney.Text.ToString(); if (ddlProject.SelectedValue != "") { spnew.MainProjectCreateId = Convert.ToInt32(ddlProject.SelectedValue); } if (ddlProjectStep.SelectedValue != "") { spnew.ProjectStepId = Convert.ToInt32(ddlProjectStep.SelectedValue); } spnew.Save(); sp.Save(); Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('�����ɹ���');</script>"); } else { sp.ApplyDate = Convert.ToDateTime(txtApplyDate.Text.ToString()); sp.ApplyPeople = lblApplyPeople.Text.ToString(); sp.ApplyReason = txtReason.Text.ToString(); sp.ApplyMoney = txtApplyMoney.Text.ToString(); if (ddlProject.SelectedValue != "") { sp.MainProjectCreateId = Convert.ToInt32(ddlProject.SelectedValue); } if (ddlProjectStep.SelectedValue != "") { sp.ProjectStepId = Convert.ToInt32(ddlProjectStep.SelectedValue); } sp.Save(); Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('�༭�ɹ���');</script>"); } Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('��ӳɹ���');</script>"); } catch (Exception Ex) { ClientScript.RegisterStartupScript(this.GetType(), "Save", "alert('���ʧ�ܣ�" + Ex.Message + "');", true); } } }
protected void PageInit() { EmployeeInfo em = (EmployeeInfo)Session["Employee"]; lblApplyPeople.Text = em.EmployeeName; int id = Convert.ToInt32(Request["SpecialExpId"].ToString()); SpecialExpInfo sp = new SpecialExpInfo(id); txtApplyMoney.Text = sp.ApplyMoney.ToString(); txtApplyDate.Text = sp.ApplyDate.ToString(); txtReason.Text = sp.ApplyReason.ToString(); if (sp.MainProjectCreateId.ToString() !="") { ddlProject.SelectedValue = sp.MainProjectCreateId.ToString(); } if (sp.ProjectStepId.ToString() != "") { ddlProjectStep.SelectedValue = sp.ProjectStepId.ToString(); } MainProjectCreateInfo project = new MainProjectCreateInfo(Convert.ToInt32(sp.MainProjectCreateId)); lblMoneyNum.Text = project.PreMoney.ToString(); txtSheetNum.Text = sp.SheetNum.ToString(); string strRoleName = Session["RoleName"].ToString(); PositionInfo position = new PositionInfo(Convert.ToInt32(em.PositionId)); if (strRoleName == "Ա��" || position.PositionName == "�ۺ�����") { btnSign.Enabled = false; btnSign.Visible = false; } }
protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e) { //Check if this is our Blank Row being databound, if so make the row invisible if (e.Row.RowType == DataControlRowType.DataRow) { if (((DataRowView)e.Row.DataItem)["SpecialExpId"].ToString() == String.Empty) e.Row.Visible = false; } 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 (e.Row.RowType == DataControlRowType.DataRow) { Label lblState = e.Row.FindControl("lblState") as Label; GridView gvTemp = (GridView)sender; if (!Convert.IsDBNull(gvTemp.DataKeys[e.Row.RowIndex].Value)) { int SaleId = Convert.ToInt32(gvTemp.DataKeys[e.Row.RowIndex].Value); SpecialExpInfo pc = new SpecialExpInfo(SaleId); if (pc.IsApply == 1 && pc.IsApply1 == 0) { lblState.Text = "�ܾ���:����"; } else if (pc.IsApply1 == 1 && pc.IsApply2 == 0) { if (pc.IsOver1 == 1) { lblState.Text = "�ܾ���:ͨ��"; } else { lblState.Text = "�ܾ���:����"; } } } } }
/// <summary> /// 获得数据列表 /// </summary> /// <returns></returns> public static List<SpecialExpInfo> GetList() { string cacheKey = GetCacheKey(); //本实体已经注册成缓存实体,并且缓存存在的时候,直接从缓存取 if (CachedEntityCommander.IsTypeRegistered(typeof(SpecialExpInfo)) && CachedEntityCommander.GetCache(cacheKey) != null) { return CachedEntityCommander.GetCache(cacheKey) as List< SpecialExpInfo>; } else { List< SpecialExpInfo> list =new List< SpecialExpInfo>(); SpecialExpCollection collection=new SpecialExpCollection(); Query qry = new Query(SpecialExp.Schema); collection.LoadAndCloseReader(qry.ExecuteReader()); foreach(SpecialExp specialExp in collection) { SpecialExpInfo specialExpInfo= new SpecialExpInfo(); LoadFromDAL(specialExpInfo,specialExp); list.Add(specialExpInfo); } //生成缓存 if (CachedEntityCommander.IsTypeRegistered(typeof(SpecialExpInfo))) { CachedEntityCommander.SetCache(cacheKey, list); } return list; } }
protected void gvSpecial_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { Label lblState = e.Row.FindControl("lblState") as Label; Button btnSubmit = e.Row.FindControl("btnSubmit") as Button; Button btnEdit = e.Row.FindControl("btnEdit") as Button; if (!Convert.IsDBNull(gvSpecial.DataKeys[e.Row.RowIndex].Value)) { //����GridView GridView gv = e.Row.FindControl("GridView2") as GridView; int emid = Convert.ToInt32(Session["EmployeeId"]); int SaleId = Convert.ToInt32(gvSpecial.DataKeys[e.Row.RowIndex].Value); SpecialExpInfo pc = new SpecialExpInfo(SaleId); int mainid = Convert.ToInt32(pc.MainSpecialExpId); DataTable dt = SpecialExpInfo.getSpecialExpListOfEmployee2(emid, mainid); if (dt.Rows.Count == 0) { dt.Rows.Add(dt.NewRow()); UI.BindCtrl(dt.DefaultView, gv, AspNetPager2); gv.Rows[0].Visible = false; } else { UI.BindCtrl(dt.DefaultView, gv, AspNetPager2); } //button���� if (pc.IsApply == 1) { btnSubmit.Enabled = false; if (pc.IsNewCreate == 1)//����δͨ���������� { btnEdit.Enabled = true; } else//Ĭ��IsNewCreate==0�������룬�༭��ť�����á� { btnEdit.Enabled = false; } } if (pc.IsApply == 1 && pc.IsApply1 == 0) { lblState.Text = "�ܾ���:����"; } else if (pc.IsApply1 == 1 && pc.IsApply2 == 0) { if (pc.IsOver1 == 1) { lblState.Text = "�ܾ���:ͨ��"; } else { lblState.Text = "�ܾ���:����"; } } } 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"; } } }
/// <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<SpecialExpInfo> GetPagedList(int pPageIndex,int pPageSize,SortDirection pOrderBy,string pSortExpression,out int pRecordCount) { if(pPageIndex<=1) pPageIndex=1; List< SpecialExpInfo> list = new List< SpecialExpInfo>(); Query q = SpecialExp .CreateQuery(); q.PageIndex = pPageIndex; q.PageSize = pPageSize; q.ORDER_BY(pSortExpression,pOrderBy.ToString()); SpecialExpCollection collection=new SpecialExpCollection(); collection.LoadAndCloseReader(q.ExecuteReader()); foreach (SpecialExp specialExp in collection) { SpecialExpInfo specialExpInfo = new SpecialExpInfo(); LoadFromDAL(specialExpInfo, specialExp); list.Add(specialExpInfo); } pRecordCount=q.GetRecordCount(); return list; }
public object SaveSpecialExpInfo(SpecialExpInfo specialExpInfo) { specialExpInfo.Save(); return(specialExpInfo.SpecialExpId); }