Ejemplo n.º 1
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        /// <returns></returns>
        public static List <DayScoreInfo> GetList()
        {
            string cacheKey = GetCacheKey();

            //本实体已经注册成缓存实体,并且缓存存在的时候,直接从缓存取
            if (CachedEntityCommander.IsTypeRegistered(typeof(DayScoreInfo)) && CachedEntityCommander.GetCache(cacheKey) != null)
            {
                return(CachedEntityCommander.GetCache(cacheKey) as List <DayScoreInfo>);
            }
            else
            {
                List <DayScoreInfo> list       = new List <DayScoreInfo>();
                DayScoreCollection  collection = new  DayScoreCollection();
                Query qry = new Query(DayScore.Schema);
                collection.LoadAndCloseReader(qry.ExecuteReader());
                foreach (DayScore dayScore in collection)
                {
                    DayScoreInfo dayScoreInfo = new DayScoreInfo();
                    LoadFromDAL(dayScoreInfo, dayScore);
                    list.Add(dayScoreInfo);
                }
                //生成缓存
                if (CachedEntityCommander.IsTypeRegistered(typeof(DayScoreInfo)))
                {
                    CachedEntityCommander.SetCache(cacheKey, list);
                }
                return(list);
            }
        }
Ejemplo n.º 2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            WeekScoreInfo wk = new WeekScoreInfo(Convert.ToInt32(ViewState["wkid"]));
            float sum = 0;

            foreach(GridViewRow row in gvScore.Rows)
            {
                if (row.RowType == DataControlRowType.DataRow)
                {
                    int dayid = Convert.ToInt32(gvScore.DataKeys[row.RowIndex].Value);
                    DayScoreInfo days = new DayScoreInfo(dayid);

                    TextBox txtScore = gvScore.Rows[row.RowIndex].FindControl("txtScore") as TextBox;
                    days.Score = txtScore.Text.ToString();
                    days.Save();
                    if (txtScore.Text.ToString() != "")
                    {
                        sum = sum + float.Parse(txtScore.Text.ToString());
                    }

                }

            }
            wk.TotalScore = sum.ToString();
            wk.IsSubmit = 2;
            wk.Save();

            Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('����ɹ���');</script>");
        }
Ejemplo n.º 3
0
        //数据持久化
        internal static void  SaveToDb(DayScoreInfo pDayScoreInfo, DayScore pDayScore, bool pIsNew)
        {
            pDayScore.DayScoreId  = pDayScoreInfo.dayScoreId;
            pDayScore.Today       = pDayScoreInfo.today;
            pDayScore.Item        = pDayScoreInfo.item;
            pDayScore.FinishTime  = pDayScoreInfo.finishTime;
            pDayScore.Roles       = pDayScoreInfo.roles;
            pDayScore.TimeSpan    = pDayScoreInfo.timeSpan;
            pDayScore.Memo        = pDayScoreInfo.memo;
            pDayScore.Score       = pDayScoreInfo.score;
            pDayScore.WeekScoreId = pDayScoreInfo.weekScoreId;
            pDayScore.DayRoleId   = pDayScoreInfo.dayRoleId;
            pDayScore.IsNew       = pIsNew;
            string UserName = SubsonicHelper.GetUserName();

            try
            {
                pDayScore.Save(UserName);
            }
            catch (Exception ex)
            {
                LogManager.getInstance().getLogger(typeof(DayScoreInfo)).Error(ex);
                if (ex.Message.Contains("插入重复键"))               //违反了唯一键
                {
                    throw new AppException("此对象已经存在");          //此处等待优化可以从唯一约束中直接取出提示来,如果没有的话,默认为原始的出错提示
                }
                throw new AppException("保存失败");
            }
            pDayScoreInfo.dayScoreId = pDayScore.DayScoreId;
            //如果缓存存在,更新缓存
            if (CachedEntityCommander.IsTypeRegistered(typeof(DayScoreInfo)))
            {
                ResetCache();
            }
        }
Ejemplo n.º 4
0
        /// <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 <DayScoreInfo> GetPagedList(int pPageIndex, int pPageSize, SortDirection pOrderBy, string pSortExpression, out int pRecordCount)
        {
            if (pPageIndex <= 1)
            {
                pPageIndex = 1;
            }
            List <DayScoreInfo> list = new List <DayScoreInfo>();

            Query q = DayScore.CreateQuery();

            q.PageIndex = pPageIndex;
            q.PageSize  = pPageSize;
            q.ORDER_BY(pSortExpression, pOrderBy.ToString());
            DayScoreCollection collection = new  DayScoreCollection();

            collection.LoadAndCloseReader(q.ExecuteReader());

            foreach (DayScore dayScore  in collection)
            {
                DayScoreInfo dayScoreInfo = new DayScoreInfo();
                LoadFromDAL(dayScoreInfo, dayScore);
                list.Add(dayScoreInfo);
            }
            pRecordCount = q.GetRecordCount();

            return(list);
        }
Ejemplo n.º 5
0
 protected void btnAdd_Click(object sender, EventArgs e)
 {
     DayScoreInfo das = new DayScoreInfo();
     das.WeekScoreId = Convert.ToInt32(ViewState["wksid"]);
     das.DayRoleId = Convert.ToInt32("1");
     das.Save();
     gvDataBind();
 }
Ejemplo n.º 6
0
 /// <summary>
 /// 批量装载
 /// </summary>
 internal static void LoadFromDALPatch(List <DayScoreInfo> pList, DayScoreCollection pCollection)
 {
     foreach (DayScore dayScore in pCollection)
     {
         DayScoreInfo dayScoreInfo = new DayScoreInfo();
         LoadFromDAL(dayScoreInfo, dayScore);
         pList.Add(dayScoreInfo);
     }
 }
Ejemplo n.º 7
0
 //从后台获取数据
 internal static void  LoadFromDAL(DayScoreInfo pDayScoreInfo, DayScore pDayScore)
 {
     pDayScoreInfo.dayScoreId  = pDayScore.DayScoreId;
     pDayScoreInfo.today       = pDayScore.Today;
     pDayScoreInfo.item        = pDayScore.Item;
     pDayScoreInfo.finishTime  = pDayScore.FinishTime;
     pDayScoreInfo.roles       = pDayScore.Roles;
     pDayScoreInfo.timeSpan    = pDayScore.TimeSpan;
     pDayScoreInfo.memo        = pDayScore.Memo;
     pDayScoreInfo.score       = pDayScore.Score;
     pDayScoreInfo.weekScoreId = pDayScore.WeekScoreId;
     pDayScoreInfo.dayRoleId   = pDayScore.DayRoleId;
     pDayScoreInfo.Loaded      = true;
 }
Ejemplo n.º 8
0
 /// <summary>
 /// 复制一个对象,采用硬编码的方式,避免反射的低效
 /// </summary>
 /// <param name="pIndustryTypeInfoFrom"></param>
 /// <param name="pIndustryTypeInfoTo"></param>
 public static void Copy(DayScoreInfo pDayScoreInfoFrom, DayScoreInfo pDayScoreInfoTo)
 {
     pDayScoreInfoTo.DayScoreId  = pDayScoreInfoFrom.dayScoreId;
     pDayScoreInfoTo.Today       = pDayScoreInfoFrom.today;
     pDayScoreInfoTo.Item        = pDayScoreInfoFrom.item;
     pDayScoreInfoTo.FinishTime  = pDayScoreInfoFrom.finishTime;
     pDayScoreInfoTo.Roles       = pDayScoreInfoFrom.roles;
     pDayScoreInfoTo.TimeSpan    = pDayScoreInfoFrom.timeSpan;
     pDayScoreInfoTo.Memo        = pDayScoreInfoFrom.memo;
     pDayScoreInfoTo.Score       = pDayScoreInfoFrom.score;
     pDayScoreInfoTo.WeekScoreId = pDayScoreInfoFrom.weekScoreId;
     pDayScoreInfoTo.DayRoleId   = pDayScoreInfoFrom.dayRoleId;
     pDayScoreInfoTo.Loaded      = pDayScoreInfoFrom.Loaded;
 }
Ejemplo n.º 9
0
        public DayScoreInfo GetDayScoreInfoById(int DayScoreId)
        {
            DayScoreInfo dayScoreInfo = null;             //

            try
            {
                dayScoreInfo = new DayScoreInfo(DayScoreId);
            }
            catch (AppException)
            {
                return(null);
            }

            return(dayScoreInfo);
        }
Ejemplo n.º 10
0
        public DayScoreInfo GetDayScoreInfoById(int DayScoreId)
        {
            DayScoreInfo dayScoreInfo  = null;//
            try
            {
                 dayScoreInfo = new DayScoreInfo(DayScoreId);

            }
            catch (AppException)
            {
                return null;
            }

            return  dayScoreInfo;
        }
Ejemplo n.º 11
0
 private void LoadFromId(int dayScoreId)
 {
     if (CachedEntityCommander.IsTypeRegistered(typeof(DayScoreInfo)))
     {
         DayScoreInfo dayScoreInfo = Find(GetList(), dayScoreId);
         if (dayScoreInfo == null)
         {
             throw new AppException("未能在缓存中找到相应的键值对象");
         }
         Copy(dayScoreInfo, this);
     }
     else
     {
         DayScore dayScore = new DayScore(dayScoreId);
         if (dayScore.IsNew)
         {
             throw new AppException("尚未初始化");
         }
         LoadFromDAL(this, dayScore);
     }
 }
Ejemplo n.º 12
0
        /// <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<DayScoreInfo> GetPagedList(int pPageIndex,int pPageSize,SortDirection pOrderBy,string pSortExpression,out int pRecordCount)
        {
            if(pPageIndex<=1)
            pPageIndex=1;
            List< DayScoreInfo> list = new List< DayScoreInfo>();

            Query q = DayScore .CreateQuery();
            q.PageIndex = pPageIndex;
            q.PageSize = pPageSize;
            q.ORDER_BY(pSortExpression,pOrderBy.ToString());
            DayScoreCollection  collection=new  DayScoreCollection();
             	collection.LoadAndCloseReader(q.ExecuteReader());

            foreach (DayScore  dayScore  in collection)
            {
                DayScoreInfo dayScoreInfo = new DayScoreInfo();
                LoadFromDAL(dayScoreInfo,   dayScore);
                list.Add(dayScoreInfo);
            }
            pRecordCount=q.GetRecordCount();

            return list;
        }
Ejemplo n.º 13
0
 /// <summary>
 /// 复制为另一个对象
 /// </summary>
 /// <param name="pIndustryTypeInfoTo"></param>
 public void CopyTo(DayScoreInfo pDayScoreInfoTo)
 {
     Copy(this,  pDayScoreInfoTo);
 }
Ejemplo n.º 14
0
 protected void Init()
 {
     WeekScoreInfo weekscore = new WeekScoreInfo();
     weekscore.IsSubmit = 0;
     int emid = Convert.ToInt32(Request["EmployeeId"]);
     weekscore.EmployeeId = emid;
     weekscore.Save();
     WeekScoreInfo wk = new WeekScoreInfo(weekscore.WeekScoreId);
     wk.WeekScoreNum = DateTime.Now.Date.ToString("yyyyMMdd") + weekscore.WeekScoreId.ToString();
     wk.Save();
     ViewState["wksid"] = weekscore.WeekScoreId;
     for (int i = 0; i < 5; i++)
     {
         DayScoreInfo dayscore = new DayScoreInfo();
         dayscore.WeekScoreId =(int)ViewState["wksid"];
         dayscore.DayRoleId = Convert.ToInt32("1");
         dayscore.Save();
     }
 }
Ejemplo n.º 15
0
        protected void gvScore_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            int daysid = Convert.ToInt32(gvScore.DataKeys[e.RowIndex].Value);
            DayScoreInfo days = new DayScoreInfo(daysid);
            TextBox txtToday = gvScore.Rows[e.RowIndex].FindControl("txtToday") as TextBox;
            TextBox txtItem = gvScore.Rows[e.RowIndex].FindControl("txtItem") as TextBox;
            TextBox txtFinishTime = gvScore.Rows[e.RowIndex].FindControl("txtFinishTime") as TextBox;
            TextBox txtTimeSpan = gvScore.Rows[e.RowIndex].FindControl("txtTimeSpan") as TextBox;
            TextBox txtMemo = gvScore.Rows[e.RowIndex].FindControl("txtMemo") as TextBox;
            DropDownList ddlRole = gvScore.Rows[e.RowIndex].FindControl("ddlRole") as DropDownList;

            try
            {
                days.Today = txtToday.Text.ToString();
                days.Item = txtItem.Text.ToString();
                days.FinishTime = txtFinishTime.Text.ToString();
                days.TimeSpan = txtTimeSpan.Text.ToString();
                days.Memo = txtMemo.Text.ToString();
                days.DayRoleId = Convert.ToInt32(ddlRole.SelectedValue);
                days.Save();
                gvScore.EditIndex = -1;
                gvDataBind();

            }
            catch(Exception ex)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "Save", "alert('����ʧ�ܣ�" + ex.Message + "');", true);
            }
        }
Ejemplo n.º 16
0
 //从后台获取数据
 internal static void LoadFromDAL(DayScoreInfo pDayScoreInfo, DayScore  pDayScore)
 {
     pDayScoreInfo.dayScoreId = pDayScore.DayScoreId;
      		pDayScoreInfo.today = pDayScore.Today;
      		pDayScoreInfo.item = pDayScore.Item;
      		pDayScoreInfo.finishTime = pDayScore.FinishTime;
      		pDayScoreInfo.roles = pDayScore.Roles;
      		pDayScoreInfo.timeSpan = pDayScore.TimeSpan;
      		pDayScoreInfo.memo = pDayScore.Memo;
      		pDayScoreInfo.score = pDayScore.Score;
      		pDayScoreInfo.weekScoreId = pDayScore.WeekScoreId;
      		pDayScoreInfo.dayRoleId = pDayScore.DayRoleId;
     pDayScoreInfo.Loaded=true;
 }
Ejemplo n.º 17
0
 public object  SaveDayScoreInfo(DayScoreInfo dayScoreInfo)
 {
     dayScoreInfo.Save();
     return(dayScoreInfo.DayScoreId);
 }
Ejemplo n.º 18
0
 /// <summary>
 /// 获得数据列表
 /// </summary>
 /// <returns></returns>
 public static List<DayScoreInfo> GetList()
 {
     string cacheKey = GetCacheKey();
     //本实体已经注册成缓存实体,并且缓存存在的时候,直接从缓存取
     if (CachedEntityCommander.IsTypeRegistered(typeof(DayScoreInfo)) && CachedEntityCommander.GetCache(cacheKey) != null)
     {
         return CachedEntityCommander.GetCache(cacheKey) as List< DayScoreInfo>;
     }
     else
     {
         List< DayScoreInfo>  list =new List< DayScoreInfo>();
         DayScoreCollection  collection=new  DayScoreCollection();
         Query qry = new Query(DayScore.Schema);
         collection.LoadAndCloseReader(qry.ExecuteReader());
         foreach(DayScore dayScore in collection)
         {
             DayScoreInfo dayScoreInfo= new DayScoreInfo();
             LoadFromDAL(dayScoreInfo,dayScore);
             list.Add(dayScoreInfo);
         }
       	//生成缓存
         if (CachedEntityCommander.IsTypeRegistered(typeof(DayScoreInfo)))
         {
             CachedEntityCommander.SetCache(cacheKey, list);
         }
         return list;
     }
 }
Ejemplo n.º 19
0
 /// <summary>
 /// 批量装载
 /// </summary>
 internal static void LoadFromDALPatch(List< DayScoreInfo> pList, DayScoreCollection pCollection)
 {
     foreach (DayScore dayScore in pCollection)
     {
         DayScoreInfo dayScoreInfo = new DayScoreInfo();
         LoadFromDAL(dayScoreInfo, dayScore );
         pList.Add(dayScoreInfo);
     }
 }
Ejemplo n.º 20
0
 //数据持久化
 internal static void SaveToDb(DayScoreInfo pDayScoreInfo, DayScore  pDayScore,bool pIsNew)
 {
     pDayScore.DayScoreId = pDayScoreInfo.dayScoreId;
      		pDayScore.Today = pDayScoreInfo.today;
      		pDayScore.Item = pDayScoreInfo.item;
      		pDayScore.FinishTime = pDayScoreInfo.finishTime;
      		pDayScore.Roles = pDayScoreInfo.roles;
      		pDayScore.TimeSpan = pDayScoreInfo.timeSpan;
      		pDayScore.Memo = pDayScoreInfo.memo;
      		pDayScore.Score = pDayScoreInfo.score;
      		pDayScore.WeekScoreId = pDayScoreInfo.weekScoreId;
      		pDayScore.DayRoleId = pDayScoreInfo.dayRoleId;
     pDayScore.IsNew=pIsNew;
     string UserName = SubsonicHelper.GetUserName();
     try
     {
         pDayScore.Save(UserName);
     }
     catch(Exception ex)
     {
         LogManager.getInstance().getLogger(typeof(DayScoreInfo)).Error(ex);
         if(ex.Message.Contains("插入重复键"))//违反了唯一键
         {
             throw new AppException("此对象已经存在");//此处等待优化可以从唯一约束中直接取出提示来,如果没有的话,默认为原始的出错提示
         }
         throw new AppException("保存失败");
     }
     pDayScoreInfo.dayScoreId = pDayScore.DayScoreId;
     //如果缓存存在,更新缓存
     if (CachedEntityCommander.IsTypeRegistered(typeof(DayScoreInfo)))
     {
         ResetCache();
     }
 }
Ejemplo n.º 21
0
        public void DeleteById(DayScoreInfo pDayScoreInfo)
        {
            DayScoreInfo dayScoreInfo = new DayScoreInfo(pDayScoreInfo.DayScoreId);

            dayScoreInfo.Delete();
        }
Ejemplo n.º 22
0
 public object SaveDayScoreInfo(DayScoreInfo dayScoreInfo)
 {
     dayScoreInfo.Save();
     return dayScoreInfo . DayScoreId;
 }
Ejemplo n.º 23
0
 public void DeleteById(DayScoreInfo pDayScoreInfo)
 {
     DayScoreInfo dayScoreInfo = new DayScoreInfo(pDayScoreInfo.DayScoreId);
     dayScoreInfo.Delete();
 }
Ejemplo n.º 24
0
 public List <DayScoreInfo> GetDayScoreInfoList()
 {
     return(DayScoreInfo.GetList());
 }
Ejemplo n.º 25
0
 public List <DayScoreInfo> GetPagedList(int pPageIndex, int pPageSize, SortDirection pOrderBy, string pSortExpression, out int pRecordCount)
 {
     return(DayScoreInfo.GetPagedList(pPageIndex, pPageSize, pOrderBy, pSortExpression, out pRecordCount));
 }
Ejemplo n.º 26
0
 /// <summary>
 /// 复制为另一个对象
 /// </summary>
 /// <param name="pIndustryTypeInfoTo"></param>
 public void CopyTo(DayScoreInfo pDayScoreInfoTo)
 {
     Copy(this, pDayScoreInfoTo);
 }
Ejemplo n.º 27
0
 /// <summary>
 /// 复制一个对象,采用硬编码的方式,避免反射的低效
 /// </summary>
 /// <param name="pIndustryTypeInfoFrom"></param>
 /// <param name="pIndustryTypeInfoTo"></param>
 public static void Copy(DayScoreInfo pDayScoreInfoFrom, DayScoreInfo pDayScoreInfoTo)
 {
     pDayScoreInfoTo.DayScoreId = pDayScoreInfoFrom.dayScoreId;
      		pDayScoreInfoTo.Today = pDayScoreInfoFrom.today;
      		pDayScoreInfoTo.Item = pDayScoreInfoFrom.item;
      		pDayScoreInfoTo.FinishTime = pDayScoreInfoFrom.finishTime;
      		pDayScoreInfoTo.Roles = pDayScoreInfoFrom.roles;
      		pDayScoreInfoTo.TimeSpan = pDayScoreInfoFrom.timeSpan;
      		pDayScoreInfoTo.Memo = pDayScoreInfoFrom.memo;
      		pDayScoreInfoTo.Score = pDayScoreInfoFrom.score;
      		pDayScoreInfoTo.WeekScoreId = pDayScoreInfoFrom.weekScoreId;
      		pDayScoreInfoTo.DayRoleId = pDayScoreInfoFrom.dayRoleId;
     pDayScoreInfoTo.Loaded=pDayScoreInfoFrom.Loaded;
 }