Example #1
0
        /// <summary>
        /// 导入工人当天工作信息
        /// </summary>
        /// <param name="selectName"></param>
        /// <param name="date"></param>
        /// <param name="selectWorkSite"></param>
        /// <param name="work">当天工时</param>
        /// <param name="workMore">加班工时</param>
        /// <param name="remark">工作日志</param>
        /// <returns></returns>
        public HttpResponseMessage GetImportWork(string selectWeather, string selectName, string date, string selectWorkSite,
                                                 string work, string workMore, string remark)
        {
            using (WorkDataClassesDataContext db = new WorkDataClassesDataContext())
            {
                string workId     = BasicMethods.GetWorkerId(selectName);
                int    workSiteId = BasicMethods.GetWorkerSiteId(selectWorkSite);


                Attendance att = new Attendance
                {
                    RecordTime  = DateTime.Now,
                    WorkId      = workId,
                    WorkSiteId  = workSiteId,
                    WorkDate    = Convert.ToDateTime(date),
                    WorkTime    = Convert.ToDouble(work),
                    WorkMore    = Convert.ToDouble(workMore),
                    WorkQuality = remark,
                    Weather     = selectWeather
                };

                string json = InsertAttendance(att);
                json = JsonConvert.SerializeObject(json);
                return(HttpResponseMessageToJson.ToJson(json));
            }
        }
Example #2
0
        /// <summary>
        /// 导入工人工资支付情况
        /// </summary>
        /// <param name="selectName"></param>
        /// <param name="date"></param>
        /// <param name="selectWorkSite"></param>
        /// <param name="wageCard">CCB、JS、Cash </param>
        /// <param name="pay">金额</param>
        /// <param name="payType">支付方式</param>
        /// <param name="remark">缘由</param>
        /// <returns></returns>
        public HttpResponseMessage GetImportPay(string selectName, string date, string selectWorkSite,
                                                string wageCard, string pay, string payType, string remark)
        {
            using (WorkDataClassesDataContext db = new WorkDataClassesDataContext())
            {
                string workId     = BasicMethods.GetWorkerId(selectName);
                int    workSiteId = BasicMethods.GetWorkerSiteId(selectWorkSite);


                Payment p = new Payment
                {
                    RecordTime      = DateTime.Now,
                    WorkId          = workId,
                    WorkSiteId      = workSiteId,
                    WagePaymentDate = Convert.ToDateTime(date),
                    WageAmount      = Convert.ToInt16(pay),
                    PaymentType     = payType,
                    WageCard        = wageCard,
                    Remark          = remark
                };

                string json = InsertPayment(p);
                json = JsonConvert.SerializeObject(json);
                return(HttpResponseMessageToJson.ToJson(json));
            }
        }
Example #3
0
        /// <summary>
        /// 导入数据稽核表格数据请求
        /// </summary>
        /// <param name="limit">页面大小</param>
        /// <param name="offset">偏移量</param>
        /// <param name="sort">排序字段</param>
        /// <param name="sortOrder">升序或降序</param>
        /// <returns></returns>
        public HttpResponseMessage GetCheckImport(int limit, int offset, string sort, string sortOrder)
        {
            string date       = HttpContext.Current.Request["date"];
            string workSite   = HttpContext.Current.Request["workSite"];
            int    workSiteId = 0;
            bool   siteEffect = false;

            if (workSite == "all")
            {
                siteEffect = true;
                workSiteId = 0;
            }
            else
            {
                workSiteId = BasicMethods.GetWorkerSiteId(workSite);
            }

            using (WorkDataClassesDataContext db = new WorkDataClassesDataContext())
            {
                var data = from s in db.Attendance
                           where s.WorkDate == Convert.ToDateTime(date) && (siteEffect || s.WorkSiteId == workSiteId)
                           select new
                {
                    wSiteName = s.WorkSite.WorkSiteName,
                    wName     = s.Worker.WorkName,
                    wDate     = s.WorkDate.ToString(),
                    work      = s.WorkTime,
                    workMore  = s.WorkMore,
                    workQua   = s.WorkQuality,
                    s.Weather
                };

                //sortName排序的名称 sortType排序类型 (desc asc)
                var orderExpression = string.Format("{0} {1}", sort, sortOrder);
                //此处应从数据库中取得数据:
                string json  = "{ \"total\":";
                var    total = data.Count();
                json += total + ",\"rows\":";
                var rows = data.OrderBy(orderExpression).Skip(offset).Take(limit).ToList();
                json += JsonConvert.SerializeObject(rows);
                json += "}";
                return(HttpResponseMessageToJson.ToJson(json));
            }
        }
Example #4
0
        /// <summary>
        /// 修改工人当天工作信息
        /// </summary>
        /// <param name="selectName"></param>
        /// <param name="date"></param>
        /// <param name="selectWorkSite"></param>
        /// <param name="work">当天工时</param>
        /// <param name="workMore">加班工时</param>
        /// <param name="remark">工作日志</param>
        /// <returns></returns>
        public HttpResponseMessage GetUpdateWork(string name, string date, string selectWorkSite,
                                                 string work, string workMore, string remark)
        {
            using (WorkDataClassesDataContext db = new WorkDataClassesDataContext())
            {
                string workId     = BasicMethods.GetWorkerId(name);
                int    workSiteId = BasicMethods.GetWorkerSiteId(selectWorkSite);


                Attendance att = new Attendance
                {
                    RecordTime  = DateTime.Now,
                    WorkId      = workId,
                    WorkSiteId  = workSiteId,
                    WorkDate    = Convert.ToDateTime(date),
                    WorkTime    = Convert.ToDouble(work),
                    WorkMore    = Convert.ToDouble(workMore),
                    WorkQuality = remark
                };
                Attendance modifyAtt = db.Attendance.Where(n => n.WorkDate == att.WorkDate &&
                                                           n.WorkId == att.WorkId && n.WorkSiteId == att.WorkSiteId).SingleOrDefault();

                string json;
                if (modifyAtt != null)
                {
                    //不能直接更新在原表里,放在remark
                    //modifyAtt.WorkTime = att.WorkTime;
                    //modifyAtt.WorkMore = att.WorkMore;
                    modifyAtt.Remark = att.RecordTime + "+" + att.WorkTime + "+" + att.WorkMore + "+" + att.WorkQuality;
                    db.SubmitChanges();
                    json = "ok";
                }
                else
                {
                    json = "error";
                }

                json = JsonConvert.SerializeObject(json);
                return(HttpResponseMessageToJson.ToJson(json));
            }
        }