コード例 #1
0
ファイル: ReportEatApp.cs プロジェクト: jockiewong/TongHao
 public void SubmitForm(ReportEatEntity userEntity, string keyValue)
 {
     if (!string.IsNullOrEmpty(keyValue))
     {
         userEntity.Modify(keyValue);
         service.Update(userEntity);
     }
     else
     {
         userEntity.Create();
         service.Insert(userEntity);
     }
 }
コード例 #2
0
        public ActionResult SubmitForm(EatForm organizeEntity)
        {
            int i = DateTime.Now.DayOfWeek - DayOfWeek.Monday;

            if (i == -1)
            {
                i = 6;
            }
            TimeSpan ts        = new TimeSpan(i, 0, 0, 0);
            DateTime startWeek = DateTime.Now.Subtract(ts);
            int      dd        = 0;

            if (organizeEntity.week.Contains("zhong"))
            {
                dd = 1;
            }
            else if (organizeEntity.week.Contains("wan"))
            {
                dd = 2;
            }
            if (organizeEntity.week.Contains("2"))
            {
                startWeek = startWeek.AddDays(1);
            }
            else if (organizeEntity.week.Contains("3"))
            {
                startWeek = startWeek.AddDays(2);
            }
            else if (organizeEntity.week.Contains("4"))
            {
                startWeek = startWeek.AddDays(3);
            }
            else if (organizeEntity.week.Contains("5"))
            {
                startWeek = startWeek.AddDays(4);
            }
            else if (organizeEntity.week.Contains("6"))
            {
                startWeek = startWeek.AddDays(5);
            }
            else if (organizeEntity.week.Contains("7"))
            {
                startWeek = startWeek.AddDays(6);
            }
            var today = reportApp.GetCurrentTime(OperatorProvider.Provider.GetCurrent().UserId, startWeek, dd);

            if (today != null)
            {
                if (organizeEntity.ck == false)
                {
                    reportApp.DeleteForm(today.F_Id);
                }
            }
            else
            {
                today          = new ReportEatEntity();
                today.F_Time   = startWeek;
                today.F_IsEat  = dd;
                today.F_UserId = OperatorProvider.Provider.GetCurrent().UserId;
                reportApp.SubmitForm(today, "");
            }
            return(Content(new AjaxResult {
                state = ResultType.success.ToString(), message = "操作成功。"
            }.ToJson()));
        }
コード例 #3
0
        public ActionResult SubmitForm(DataForm organizeEntity, string keyValue, string starttime)
        {
            DateTime now = DateTime.Now;

            if (!string.IsNullOrEmpty(starttime))
            {
                now = starttime.ToDate();
            }
            var item  = userApp.GetForm(keyValue);
            var today = reportApp.GetCurrentTime(keyValue, now, 1);

            if (today != null)
            {
                if (organizeEntity.baocan == "0")
                {
                    reportApp.DeleteForm(today.F_Id);
                }
            }
            else
            {
                if (organizeEntity.baocan == "1")
                {
                    today          = new ReportEatEntity();
                    today.F_Time   = now;
                    today.F_IsEat  = 1;
                    today.F_UserId = keyValue;
                    reportApp.SubmitForm(today, "");
                }
            }
            var attl = attlApp.GetCurrentTime(item.F_AttCard, now, true);

            if (attl == null && organizeEntity.shangban == "1")
            {
                attl         = new AttLogEntity();
                attl.AttDate = new DateTime(now.Year, now.Month, now.Day, 8, 0, 0);
                attl.CardNo  = item.F_AttCard;
                attlApp.SubmitForm(attl, "");
            }
            else if (attl != null && organizeEntity.shangban == "0")
            {
                attlApp.DeleteForm(attl.F_Id);
            }
            var attl2 = attlApp.GetCurrentTime(item.F_AttCard, now, false);

            if (attl2 == null && organizeEntity.xiaban == "1")
            {
                attl2         = new AttLogEntity();
                attl2.AttDate = new DateTime(now.Year, now.Month, now.Day, 17, 0, 0);
                attl2.CardNo  = item.F_AttCard;
                attlApp.SubmitForm(attl2, "");
            }
            else if (attl2 != null && organizeEntity.xiaban == "0")
            {
                attlApp.DeleteForm(attl2.F_Id);
            }
            if (string.IsNullOrEmpty(item.F_PosCard))
            {
                return(Error(item.F_NickName + "-此用户未填餐卡编号!"));
            }
            var pos = posApp.GetCurrentTime(item.F_PosCard, now, 0);

            if (pos == null && organizeEntity.zaocan == "1")
            {
                pos         = new PosLogEntity();
                pos.PosTime = new DateTime(now.Year, now.Month, now.Day, 8, 0, 0);
                pos.CardNo  = item.F_PosCard;
                posApp.SubmitForm(pos, "");
            }
            else if (pos != null && organizeEntity.zaocan == "0")
            {
                posApp.DeleteForm(pos.F_Id);
            }
            var pos1 = posApp.GetCurrentTime(item.F_PosCard, now, 1);

            if (pos1 == null && organizeEntity.wucan == "1")
            {
                pos1         = new PosLogEntity();
                pos1.PosTime = new DateTime(now.Year, now.Month, now.Day, 12, 0, 0);
                pos1.CardNo  = item.F_PosCard;
                posApp.SubmitForm(pos1, "");
            }
            else if (pos1 != null && organizeEntity.wucan == "0")
            {
                posApp.DeleteForm(pos1.F_Id);
            }
            var pos2 = posApp.GetCurrentTime(item.F_PosCard, now, 2);

            if (pos2 == null && organizeEntity.wancan == "1")
            {
                pos2         = new PosLogEntity();
                pos2.PosTime = new DateTime(now.Year, now.Month, now.Day, 17, 0, 0);
                pos2.CardNo  = item.F_PosCard;
                posApp.SubmitForm(pos2, "");
            }
            else if (pos2 != null)
            {
                posApp.DeleteForm(pos2.F_Id);
            }
            return(Success("操作成功。"));
        }