예제 #1
0
        //数据持久化
        internal static void  SaveToDb(WeekScoreInfo pWeekScoreInfo, WeekScore pWeekScore, bool pIsNew)
        {
            pWeekScore.WeekScoreId  = pWeekScoreInfo.weekScoreId;
            pWeekScore.WeekScoreNum = pWeekScoreInfo.weekScoreNum;
            pWeekScore.IsSubmit     = pWeekScoreInfo.isSubmit;
            pWeekScore.EmployeeId   = pWeekScoreInfo.employeeId;
            pWeekScore.TotalScore   = pWeekScoreInfo.totalScore;
            pWeekScore.IsNew        = pIsNew;
            string UserName = SubsonicHelper.GetUserName();

            try
            {
                pWeekScore.Save(UserName);
            }
            catch (Exception ex)
            {
                LogManager.getInstance().getLogger(typeof(WeekScoreInfo)).Error(ex);
                if (ex.Message.Contains("插入重复键"))               //违反了唯一键
                {
                    throw new AppException("此对象已经存在");          //此处等待优化可以从唯一约束中直接取出提示来,如果没有的话,默认为原始的出错提示
                }
                throw new AppException("保存失败");
            }
            pWeekScoreInfo.weekScoreId = pWeekScore.WeekScoreId;
            //如果缓存存在,更新缓存
            if (CachedEntityCommander.IsTypeRegistered(typeof(WeekScoreInfo)))
            {
                ResetCache();
            }
        }
예제 #2
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        /// <returns></returns>
        public static List <WeekScoreInfo> GetList()
        {
            string cacheKey = GetCacheKey();

            //本实体已经注册成缓存实体,并且缓存存在的时候,直接从缓存取
            if (CachedEntityCommander.IsTypeRegistered(typeof(WeekScoreInfo)) && CachedEntityCommander.GetCache(cacheKey) != null)
            {
                return(CachedEntityCommander.GetCache(cacheKey) as List <WeekScoreInfo>);
            }
            else
            {
                List <WeekScoreInfo> list       = new List <WeekScoreInfo>();
                WeekScoreCollection  collection = new  WeekScoreCollection();
                Query qry = new Query(WeekScore.Schema);
                collection.LoadAndCloseReader(qry.ExecuteReader());
                foreach (WeekScore weekScore in collection)
                {
                    WeekScoreInfo weekScoreInfo = new WeekScoreInfo();
                    LoadFromDAL(weekScoreInfo, weekScore);
                    list.Add(weekScoreInfo);
                }
                //生成缓存
                if (CachedEntityCommander.IsTypeRegistered(typeof(WeekScoreInfo)))
                {
                    CachedEntityCommander.SetCache(cacheKey, list);
                }
                return(list);
            }
        }
예제 #3
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 <WeekScoreInfo> GetPagedList(int pPageIndex, int pPageSize, SortDirection pOrderBy, string pSortExpression, out int pRecordCount)
        {
            if (pPageIndex <= 1)
            {
                pPageIndex = 1;
            }
            List <WeekScoreInfo> list = new List <WeekScoreInfo>();

            Query q = WeekScore.CreateQuery();

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

            collection.LoadAndCloseReader(q.ExecuteReader());

            foreach (WeekScore weekScore  in collection)
            {
                WeekScoreInfo weekScoreInfo = new WeekScoreInfo();
                LoadFromDAL(weekScoreInfo, weekScore);
                list.Add(weekScoreInfo);
            }
            pRecordCount = q.GetRecordCount();

            return(list);
        }
예제 #4
0
 protected void gvScore_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(gvScore.DataKeys[e.Row.RowIndex].Value))
         {
             int wkid = Convert.ToInt32(gvScore.DataKeys[e.Row.RowIndex].Value);
             WeekScoreInfo wk = new WeekScoreInfo(wkid);
             if (wk.IsSubmit != 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;
             }
         }
     }
 }
예제 #5
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>");
        }
예제 #6
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     WeekScoreInfo wks = new WeekScoreInfo(Convert.ToInt32(ViewState["wksid"]));
     wks.IsSubmit = 1;
     wks.Save();
     Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('�ύ�ɹ���');</script>");
 }
예제 #7
0
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     int WkScoreId = Convert.ToInt32(((Button)sender).CommandArgument.ToString());
     WeekScoreInfo wk = new WeekScoreInfo(WkScoreId);
     wk.IsSubmit = 1;
     wk.Save();
     gvDataBind();
 }
예제 #8
0
 /// <summary>
 /// 复制一个对象,采用硬编码的方式,避免反射的低效
 /// </summary>
 /// <param name="pIndustryTypeInfoFrom"></param>
 /// <param name="pIndustryTypeInfoTo"></param>
 public static void Copy(WeekScoreInfo pWeekScoreInfoFrom, WeekScoreInfo pWeekScoreInfoTo)
 {
     pWeekScoreInfoTo.WeekScoreId  = pWeekScoreInfoFrom.weekScoreId;
     pWeekScoreInfoTo.WeekScoreNum = pWeekScoreInfoFrom.weekScoreNum;
     pWeekScoreInfoTo.IsSubmit     = pWeekScoreInfoFrom.isSubmit;
     pWeekScoreInfoTo.EmployeeId   = pWeekScoreInfoFrom.employeeId;
     pWeekScoreInfoTo.TotalScore   = pWeekScoreInfoFrom.totalScore;
     pWeekScoreInfoTo.Loaded       = pWeekScoreInfoFrom.Loaded;
 }
예제 #9
0
 /// <summary>
 /// 批量装载
 /// </summary>
 internal static void LoadFromDALPatch(List <WeekScoreInfo> pList, WeekScoreCollection pCollection)
 {
     foreach (WeekScore weekScore in pCollection)
     {
         WeekScoreInfo weekScoreInfo = new WeekScoreInfo();
         LoadFromDAL(weekScoreInfo, weekScore);
         pList.Add(weekScoreInfo);
     }
 }
예제 #10
0
 //从后台获取数据
 internal static void  LoadFromDAL(WeekScoreInfo pWeekScoreInfo, WeekScore pWeekScore)
 {
     pWeekScoreInfo.weekScoreId  = pWeekScore.WeekScoreId;
     pWeekScoreInfo.weekScoreNum = pWeekScore.WeekScoreNum;
     pWeekScoreInfo.isSubmit     = pWeekScore.IsSubmit;
     pWeekScoreInfo.employeeId   = pWeekScore.EmployeeId;
     pWeekScoreInfo.totalScore   = pWeekScore.TotalScore;
     pWeekScoreInfo.Loaded       = true;
 }
예제 #11
0
        public WeekScoreInfo GetWeekScoreInfoById(int WeekScoreId)
        {
            WeekScoreInfo weekScoreInfo  = null;//
            try
            {
                 weekScoreInfo = new WeekScoreInfo(WeekScoreId);

            }
            catch (AppException)
            {
                return null;
            }

            return  weekScoreInfo;
        }
예제 #12
0
        public WeekScoreInfo GetWeekScoreInfoById(int WeekScoreId)
        {
            WeekScoreInfo weekScoreInfo = null;             //

            try
            {
                weekScoreInfo = new WeekScoreInfo(WeekScoreId);
            }
            catch (AppException)
            {
                return(null);
            }

            return(weekScoreInfo);
        }
예제 #13
0
 private void LoadFromId(int weekScoreId)
 {
     if (CachedEntityCommander.IsTypeRegistered(typeof(WeekScoreInfo)))
     {
         WeekScoreInfo weekScoreInfo = Find(GetList(), weekScoreId);
         if (weekScoreInfo == null)
         {
             throw new AppException("未能在缓存中找到相应的键值对象");
         }
         Copy(weekScoreInfo, this);
     }
     else
     {
         WeekScore weekScore = new WeekScore(weekScoreId);
         if (weekScore.IsNew)
         {
             throw new AppException("尚未初始化");
         }
         LoadFromDAL(this, weekScore);
     }
 }
예제 #14
0
 public void DeleteById(WeekScoreInfo pWeekScoreInfo)
 {
     WeekScoreInfo weekScoreInfo = new WeekScoreInfo(pWeekScoreInfo.WeekScoreId);
     weekScoreInfo.Delete();
 }
예제 #15
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<WeekScoreInfo> GetPagedList(int pPageIndex,int pPageSize,SortDirection pOrderBy,string pSortExpression,out int pRecordCount)
        {
            if(pPageIndex<=1)
            pPageIndex=1;
            List< WeekScoreInfo> list = new List< WeekScoreInfo>();

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

            foreach (WeekScore  weekScore  in collection)
            {
                WeekScoreInfo weekScoreInfo = new WeekScoreInfo();
                LoadFromDAL(weekScoreInfo,   weekScore);
                list.Add(weekScoreInfo);
            }
            pRecordCount=q.GetRecordCount();

            return list;
        }
예제 #16
0
 /// <summary>
 /// 复制为另一个对象
 /// </summary>
 /// <param name="pIndustryTypeInfoTo"></param>
 public void CopyTo(WeekScoreInfo pWeekScoreInfoTo)
 {
     Copy(this,  pWeekScoreInfoTo);
 }
예제 #17
0
 //从后台获取数据
 internal static void LoadFromDAL(WeekScoreInfo pWeekScoreInfo, WeekScore  pWeekScore)
 {
     pWeekScoreInfo.weekScoreId = pWeekScore.WeekScoreId;
      		pWeekScoreInfo.weekScoreNum = pWeekScore.WeekScoreNum;
      		pWeekScoreInfo.isSubmit = pWeekScore.IsSubmit;
      		pWeekScoreInfo.employeeId = pWeekScore.EmployeeId;
      		pWeekScoreInfo.totalScore = pWeekScore.TotalScore;
     pWeekScoreInfo.Loaded=true;
 }
예제 #18
0
 /// <summary>
 /// 复制为另一个对象
 /// </summary>
 /// <param name="pIndustryTypeInfoTo"></param>
 public void CopyTo(WeekScoreInfo pWeekScoreInfoTo)
 {
     Copy(this, pWeekScoreInfoTo);
 }
예제 #19
0
 public List <WeekScoreInfo> GetPagedList(int pPageIndex, int pPageSize, SortDirection pOrderBy, string pSortExpression, out int pRecordCount)
 {
     return(WeekScoreInfo.GetPagedList(pPageIndex, pPageSize, pOrderBy, pSortExpression, out pRecordCount));
 }
예제 #20
0
 //数据持久化
 internal static void SaveToDb(WeekScoreInfo pWeekScoreInfo, WeekScore  pWeekScore,bool pIsNew)
 {
     pWeekScore.WeekScoreId = pWeekScoreInfo.weekScoreId;
      		pWeekScore.WeekScoreNum = pWeekScoreInfo.weekScoreNum;
      		pWeekScore.IsSubmit = pWeekScoreInfo.isSubmit;
      		pWeekScore.EmployeeId = pWeekScoreInfo.employeeId;
      		pWeekScore.TotalScore = pWeekScoreInfo.totalScore;
     pWeekScore.IsNew=pIsNew;
     string UserName = SubsonicHelper.GetUserName();
     try
     {
         pWeekScore.Save(UserName);
     }
     catch(Exception ex)
     {
         LogManager.getInstance().getLogger(typeof(WeekScoreInfo)).Error(ex);
         if(ex.Message.Contains("插入重复键"))//违反了唯一键
         {
             throw new AppException("此对象已经存在");//此处等待优化可以从唯一约束中直接取出提示来,如果没有的话,默认为原始的出错提示
         }
         throw new AppException("保存失败");
     }
     pWeekScoreInfo.weekScoreId = pWeekScore.WeekScoreId;
     //如果缓存存在,更新缓存
     if (CachedEntityCommander.IsTypeRegistered(typeof(WeekScoreInfo)))
     {
         ResetCache();
     }
 }
예제 #21
0
        public void DeleteById(WeekScoreInfo pWeekScoreInfo)
        {
            WeekScoreInfo weekScoreInfo = new WeekScoreInfo(pWeekScoreInfo.WeekScoreId);

            weekScoreInfo.Delete();
        }
예제 #22
0
 /// <summary>
 /// 获得数据列表
 /// </summary>
 /// <returns></returns>
 public static List<WeekScoreInfo> GetList()
 {
     string cacheKey = GetCacheKey();
     //本实体已经注册成缓存实体,并且缓存存在的时候,直接从缓存取
     if (CachedEntityCommander.IsTypeRegistered(typeof(WeekScoreInfo)) && CachedEntityCommander.GetCache(cacheKey) != null)
     {
         return CachedEntityCommander.GetCache(cacheKey) as List< WeekScoreInfo>;
     }
     else
     {
         List< WeekScoreInfo>  list =new List< WeekScoreInfo>();
         WeekScoreCollection  collection=new  WeekScoreCollection();
         Query qry = new Query(WeekScore.Schema);
         collection.LoadAndCloseReader(qry.ExecuteReader());
         foreach(WeekScore weekScore in collection)
         {
             WeekScoreInfo weekScoreInfo= new WeekScoreInfo();
             LoadFromDAL(weekScoreInfo,weekScore);
             list.Add(weekScoreInfo);
         }
       	//生成缓存
         if (CachedEntityCommander.IsTypeRegistered(typeof(WeekScoreInfo)))
         {
             CachedEntityCommander.SetCache(cacheKey, list);
         }
         return list;
     }
 }
예제 #23
0
 public object  SaveWeekScoreInfo(WeekScoreInfo weekScoreInfo)
 {
     weekScoreInfo.Save();
     return(weekScoreInfo.WeekScoreId);
 }
예제 #24
0
 public object SaveWeekScoreInfo(WeekScoreInfo weekScoreInfo)
 {
     weekScoreInfo.Save();
     return weekScoreInfo . WeekScoreId;
 }
예제 #25
0
 /// <summary>
 /// 批量装载
 /// </summary>
 internal static void LoadFromDALPatch(List< WeekScoreInfo> pList, WeekScoreCollection pCollection)
 {
     foreach (WeekScore weekScore in pCollection)
     {
         WeekScoreInfo weekScoreInfo = new WeekScoreInfo();
         LoadFromDAL(weekScoreInfo, weekScore );
         pList.Add(weekScoreInfo);
     }
 }
예제 #26
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();
     }
 }
예제 #27
0
 public List <WeekScoreInfo> GetWeekScoreInfoList()
 {
     return(WeekScoreInfo.GetList());
 }
예제 #28
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ViewState["SortExpression"] = "Today";
                ViewState["SortDir"] = "ASC";
                ViewState["BackUrl"] = Request.UrlReferrer.ToString();
                ViewState["wkid"] = Convert.ToInt32(Request["WeekScoreId"]);
                gvDataBind();

                WeekScoreInfo wk = new WeekScoreInfo(Convert.ToInt32(ViewState["wkid"]));
                lblNum.Text = wk.WeekScoreNum.ToString();
                EmployeeInfo em = new EmployeeInfo(Convert.ToInt32(wk.EmployeeId));
                lblEm.Text = em.EmployeeName.ToString();
            }
        }
예제 #29
0
 /// <summary>
 /// 复制一个对象,采用硬编码的方式,避免反射的低效
 /// </summary>
 /// <param name="pIndustryTypeInfoFrom"></param>
 /// <param name="pIndustryTypeInfoTo"></param>
 public static void Copy(WeekScoreInfo pWeekScoreInfoFrom, WeekScoreInfo pWeekScoreInfoTo)
 {
     pWeekScoreInfoTo.WeekScoreId = pWeekScoreInfoFrom.weekScoreId;
      		pWeekScoreInfoTo.WeekScoreNum = pWeekScoreInfoFrom.weekScoreNum;
      		pWeekScoreInfoTo.IsSubmit = pWeekScoreInfoFrom.isSubmit;
      		pWeekScoreInfoTo.EmployeeId = pWeekScoreInfoFrom.employeeId;
      		pWeekScoreInfoTo.TotalScore = pWeekScoreInfoFrom.totalScore;
     pWeekScoreInfoTo.Loaded=pWeekScoreInfoFrom.Loaded;
 }