public void ProcessRequest(HttpContext context)
 {
     context.Response.ContentType = "text/plain";
     YuanGongKaoQinManager manager = new YuanGongKaoQinManager();
     HttpRequest rp = context.Request;
     DataTable dt = manager.GetDataTable(DateTime.Parse(rp["KQRQ"]));
     string result = JsonConvert.Convert2Json(dt);
     context.Response.Write(result);
     context.Response.End();
 }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

            if (context.Session["UserID"] != null)
            {
                string userid = context.Session["UserID"].ToString();
                PersonInfo p = new PersonInfoManager().GetItemById(new Guid(userid));
                if (!p.MarryStatus.HasValue || p.MarryStatus.Value != 3)
                {
                    context.Response.Write("{\"total\":\"0\",\"rows\": 没有考勤数据}");
                    context.Response.End();
                    return;
                }
            }

            YuanGongKaoQinManager manager = new YuanGongKaoQinManager();
            int pageNum = int.Parse(context.Request.QueryString.Get("pagenum"));
            int pagesize = int.Parse(context.Request.QueryString.Get("pagesize"));
            int recordCount = 0;
            WhereClip where = new WhereClip();
            if (!string.IsNullOrEmpty(context.Request["USER"]))
            {
                where = YuanGongKaoQin._.UserName.Contains(context.Request["USER"]);

            }

            if (!string.IsNullOrEmpty(context.Request["begindate"]))
            {

                string begin = context.Request["begindate"];
                if (!string.IsNullOrEmpty(begin))
                {
                    where = where && YuanGongKaoQin._.KQRQ >= begin;

                }
            }
            if (!string.IsNullOrEmpty(context.Request["enddate"]))
            {

                string enddate = context.Request["enddate"];
                if (!string.IsNullOrEmpty(enddate))
                {
                    where = where && YuanGongKaoQin._.KQRQ <= enddate;

                }
            }
            if (!string.IsNullOrEmpty(context.Request["swstatus"]))
            {
                where = YuanGongKaoQin._.SWStatus == context.Request["swstatus"];

            }

            if (!string.IsNullOrEmpty(context.Request["status"]))
            {
                where = YuanGongKaoQin._.Status == context.Request["status"];

            }

            if (!string.IsNullOrEmpty(context.Request["KQRQ"]))
            {
                string[] datestr = context.Request["KQRQ"].ToString().Split('@');
                string begin = datestr[0];
                if (!string.IsNullOrEmpty(begin))
                {
                    where.And(YuanGongKaoQin._.KQRQ >= begin);
                }
                string end = datestr[1];
                if (!string.IsNullOrEmpty(end))
                {
                    where.And(YuanGongKaoQin._.KQRQ <= end);
                }
            }
            string or = "UserName";
            if (!string.IsNullOrEmpty(context.Request["sortdatafield"]))
            {
                if (!string.IsNullOrEmpty(context.Request["sortorder"]) && context.Request["sortorder"] == "desc")
                {
                    or = context.Request["sortdatafield"] + " desc";
                }
                else
                {
                    or = context.Request["sortdatafield"];
                }

            }
            DataTable dt = manager.GetDataTable(pageNum + 1, pagesize, where, or, ref pagesize, ref recordCount);
            //manager.GetDataTable();
            string result = JsonConvert.Convert2Json(dt);
            context.Response.Write("{\"total\":\"" + recordCount.ToString() + "\",\"rows\":" + result + "}");
            context.Response.End();
        }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            NameValueCollection rp = context.Request.Form;
            string msg = string.Empty;
            try
            {
                string succesmsg = "";
                List<BaseEntity> list = new List<BaseEntity>();
                if (rp.AllKeys.Contains("ID"))
                {
                    //单条记录保存
                    YuanGongKaoQin entity = new YuanGongKaoQin();
                    if (string.IsNullOrEmpty(rp["ID"]))
                    {
                        entity.ID = Guid.NewGuid();
                        entity.CreateDate = DateTime.Now;
                        if (!string.IsNullOrEmpty(context.Session["UserName"] as string))
                        {
                            entity.CreaterID = new Guid(context.Session["UserID"].ToString());

                        }
                        else
                        {
                            entity.CreaterID = Guid.NewGuid();
                        }
                    }
                    else
                    {
                        entity.ID = new Guid(rp["ID"]);
                        entity.RecordStatus = StatusType.update;
                        if (!string.IsNullOrEmpty(context.Session["UserName"] as string))
                        {
                            entity.UpdaterID = new Guid(context.Session["UserID"].ToString());
                            entity.Updatedate = DateTime.Now;
                        }
                    }
                    entity.UserID = new Guid(rp["PersonID"]);
                    entity.UserName = rp["RealName"];
                    entity.StartTime = rp["StartTime"];
                    entity.EndTime = rp["EndTime"];
                    entity.KQRQ = DateTime.Parse(rp["KQRQ"]);
                    entity.SWStatus = rp["SWStatus"];
                    entity.Status = rp["Status"];
                    entity.Note = rp["Note"];
                    list.Add(entity);
                    succesmsg = "{\"success\":\"true\",\"ID\":\"" + entity.ID + "\"}";
                }
                else
                {
                    //多条记录保存
                    int rows = 0;
                    int.TryParse(rp["count"], out rows);
                    for (int i = 0; i < rows; i++)
                    {
                        string rowpix = string.Format("row[{0}]", i);
                        YuanGongKaoQin entity = new YuanGongKaoQin();
                        if (string.IsNullOrEmpty(rp[rowpix + "[ID]"]))
                        {
                            entity.ID = Guid.NewGuid();
                            entity.CreateDate = DateTime.Now;
                            if (!string.IsNullOrEmpty(context.Session["UserName"] as string))
                            {
                                entity.CreaterID = new Guid(context.Session["UserID"].ToString());

                            }
                            else
                            {
                                entity.CreaterID = Guid.NewGuid();
                            }
                        }
                        else
                        {
                            entity.ID = new Guid(rp[rowpix + "[ID]"]);
                            entity.RecordStatus = StatusType.update;
                            if (!string.IsNullOrEmpty(context.Session["UserName"] as string))
                            {
                                entity.UpdaterID = new Guid(context.Session["UserID"].ToString());
                                entity.Updatedate = DateTime.Now;
                            }
                        }
                        entity.UserID = new Guid(rp[rowpix + "[PersonID]"]);
                        entity.UserName = rp[rowpix + "[RealName]"];
                        entity.StartTime = rp[rowpix + "[StartTime]"];
                        entity.EndTime = rp[rowpix + "[EndTime]"];
                        entity.KQRQ = DateTime.Parse(rp["KQRQ"]);
                        entity.SWStatus = rp[rowpix + "[SWStatus]"];
                        entity.Status = rp[rowpix + "[Status]"];
                        entity.Note = rp[rowpix + "[Note]"];
                        list.Add(entity);
                    }
                    succesmsg = "{\"success\":\"true\" }";
                }

                YuanGongKaoQinManager manager = new YuanGongKaoQinManager();
                manager.Save(list);
                context.Response.Write(succesmsg);

            }
            catch (Exception ex)
            {
                msg = ex.Message;
            }
            if (!string.IsNullOrEmpty(msg))
            {
                byte[] bytes = Encoding.UTF8.GetBytes(msg.Replace("\r\n", "<br/>"));
                string encode = Convert.ToBase64String(bytes);
                context.Response.Write("{\"success\":\"false\",\"msg\":\"" + encode + "\"}");
            }
            context.Response.End();
        }