コード例 #1
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            HttpRequest request = context.Request;

            Model.hr_employee model = new Model.hr_employee();

            var    cookie     = context.Request.Cookies[FormsAuthentication.FormsCookieName];
            var    ticket     = FormsAuthentication.Decrypt(cookie.Value);
            string CoockiesID = ticket.UserData;

            BLL.hr_employee emp     = new BLL.hr_employee();
            int             emp_id  = int.Parse(CoockiesID);
            DataSet         dsemp   = emp.GetList("id=" + emp_id);
            string          empname = dsemp.Tables[0].Rows[0]["name"].ToString();
            string          uid     = dsemp.Tables[0].Rows[0]["uid"].ToString();

            if (request["Action"] == "grid")
            {
                int    PageIndex = int.Parse(request["page"] == null ? "1" : request["page"]);
                int    PageSize  = int.Parse(request["pagesize"] == null ? "30" : request["pagesize"]);
                string sortname  = request["sortname"];
                string sortorder = request["sortorder"];

                if (string.IsNullOrEmpty(sortname))
                {
                    sortname = " ID";
                }
                if (string.IsNullOrEmpty(sortorder))
                {
                    sortorder = " desc";
                }

                string sorttext = " " + sortname + " " + sortorder;

                string Total;
                string serchtxt = "uid!='admin'";

                string did = request["did"];
                if (!string.IsNullOrEmpty(did) && did != null && did != "null")
                {
                    serchtxt += " and d_id=" + int.Parse(did);
                }

                string authtxt = request["auth"];
                if (authtxt == "1")
                {
                    Data.GetDataAuth dataauth = new Data.GetDataAuth();
                    string           txt      = dataauth.GetDataAuthByid("1", "Sys_add", emp_id.ToString());
                    string[]         arr      = txt.Split(':');
                    switch (arr[0])
                    {
                    case "my": serchtxt += " and ID=" + emp_id;
                        break;
                    }
                }
                if (!string.IsNullOrEmpty(request["stext"]))
                {
                    if (request["stext"] != "输入姓名搜索")
                    {
                        serchtxt += " and name like N'%" + PageValidate.InputText(request["stext"], 255) + "%'";
                    }
                }
                //权限
                DataSet ds = emp.GetList(PageSize, PageIndex, serchtxt, sorttext, out Total);

                string dt = Common.GetGridJSON.DataTableToJSON1(ds.Tables[0], Total);
                context.Response.Write(dt);
            }
            //表格json
            if (request["Action"] == "getRole")
            {
                int     r_empid = int.Parse(request["empid"]);
                DataSet ds      = emp.GetRole(r_empid);

                string dt = Common.GetGridJSON.DataTableToJSON(ds.Tables[0]);

                context.Response.Write(dt);
            }
            //validate
            if (request["Action"] == "Exist")
            {
                string user_id  = request["T_uid"];
                string T_emp_id = request["emp_id"];
                if (string.IsNullOrEmpty(T_emp_id) || T_emp_id == "null")
                {
                    T_emp_id = "0";
                }

                DataSet ds1 = emp.GetList(" uid='" + PageValidate.InputText(user_id, 250) + "' and  ID!=" + int.Parse(T_emp_id));

                context.Response.Write(ds1.Tables[0].Rows.Count > 0 ? "false" : "true");
            }

            //Form JSON
            if (request["Action"] == "form")
            {
                string eid = PageValidate.InputText(request["id"], 50);

                if (eid == "epu")
                {
                    eid = emp_id.ToString();
                }

                DataSet ds = emp.GetList("id=" + int.Parse(eid));

                string dt = Common.DataToJson.DataToJSON(ds);

                context.Response.Write(dt);
            }
            //save
            if (request["Action"] == "save")
            {
                model.uid          = PageValidate.InputText(request["T_uid"], 255);
                model.email        = PageValidate.InputText(request["T_email"], 255);
                model.name         = PageValidate.InputText(request["T_name"], 255);
                model.birthday     = PageValidate.InputText(request["T_birthday"], 255);
                model.sex          = PageValidate.InputText(request["T_sex"], 255);
                model.idcard       = PageValidate.InputText(request["T_idcard"], 255);
                model.tel          = PageValidate.InputText(request["T_tel"], 255);
                model.status       = PageValidate.InputText(request["T_status"], 255);
                model.EntryDate    = PageValidate.InputText(request["T_entryDate"], 255);
                model.address      = PageValidate.InputText(request["T_Adress"], 255);
                model.schools      = PageValidate.InputText(request["T_school"], 255);
                model.education    = PageValidate.InputText(request["T_edu"], 255);
                model.professional = PageValidate.InputText(request["T_professional"], 255);
                model.remarks      = PageValidate.InputText(request["T_remarks"], 255);
                model.title        = PageValidate.InputText(request["headurl"], 255);
                model.canlogin     = int.Parse(request["canlogin"]);

                int    empid;
                string id = PageValidate.InputText(request["id"], 50);
                if (!string.IsNullOrEmpty(id) && id != "null")
                {
                    DataSet ds = emp.GetList(" ID=" + int.Parse(id));
                    DataRow dr = ds.Tables[0].Rows[0];
                    model.ID = int.Parse(id);
                    empid    = model.ID;

                    emp.Update(model);

                    C_Sys_log log = new C_Sys_log();

                    int    UserID     = emp_id;
                    string UserName   = empname;
                    string IPStreet   = request.UserHostAddress;
                    string EventTitle = model.name;
                    string EventType  = "员工修改";
                    int    EventID    = model.ID;

                    if (dr["email"].ToString() != request["T_email"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "邮箱", dr["email"].ToString(), request["T_email"]);
                    }

                    if (dr["name"].ToString() != request["T_name"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "员工姓名", dr["name"].ToString(), request["T_name"]);
                    }

                    if (dr["birthday"].ToString() != request["T_birthday"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "员工生日", dr["birthday"].ToString(), request["T_birthday"]);
                    }

                    if (dr["sex"].ToString() != request["T_sex"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "员工性别", dr["sex"].ToString(), request["T_sex"]);
                    }

                    if (dr["status"].ToString() != request["T_status"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "状态", dr["status"].ToString(), request["T_status"]);
                    }

                    if (dr["idcard"].ToString() != request["T_idcard"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "身份证", dr["idcard"].ToString(), request["T_idcard"]);
                    }

                    if (dr["tel"].ToString() != request["T_tel"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "手机", dr["tel"].ToString(), request["T_tel"]);
                    }

                    if (dr["EntryDate"].ToString() != request["T_entryDate"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "入职日期", dr["EntryDate"].ToString(), request["T_entryDate"]);
                    }

                    if (dr["address"].ToString() != request["T_Adress"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "地址", dr["address"].ToString(), request["T_Adress"]);
                    }

                    if (dr["schools"].ToString() != request["T_school"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "毕业学校", dr["schools"].ToString(), request["T_school"]);
                    }

                    if (dr["education"].ToString() != request["T_edu"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "学历", dr["education"].ToString(), request["T_edu"]);
                    }

                    if (dr["professional"].ToString() != request["T_professional"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "专业", dr["professional"].ToString(), request["T_professional"]);
                    }

                    if (dr["remarks"].ToString() != request["T_remarks"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "备注", dr["remarks"].ToString(), request["T_remarks"]);
                    }

                    if (dr["canlogin"].ToString() != request["canlogin"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "能否登录", dr["canlogin"].ToString(), request["canlogin"]);
                    }


                    context.Response.Write(id + "|" + model.name);
                }
                else
                {
                    model.isDelete = 0;
                    model.pwd      = FormsAuthentication.HashPasswordForStoringInConfigFile("123456", "MD5");
                    empid          = emp.Add(model);
                    context.Response.Write("{success:success}");
                }

                //post
                string json             = request["PostData"].ToLower();
                JavaScriptSerializer js = new JavaScriptSerializer();

                PostData[] postdata;
                postdata = js.Deserialize <PostData[]>(json);

                BLL.hr_post   hp        = new BLL.hr_post();
                Model.hr_post modelpost = new Model.hr_post();

                modelpost.emp_id   = empid;
                model.ID           = empid;
                modelpost.emp_name = PageValidate.InputText(request["T_name"], 255);

                for (int i = 0; i < postdata.Length; i++)
                {
                    modelpost.post_id      = postdata[i].Post_id;
                    modelpost.default_post = postdata[i].Default_post;

                    if (postdata[i].Default_post == 1)
                    {
                        model.d_id    = postdata[i].dep_id;
                        model.dname   = postdata[i].Depname;
                        model.zhiwuid = postdata[i].Position_id;
                        model.zhiwu   = postdata[i].Position_name;
                        model.postid  = postdata[i].Post_id;
                        model.post    = postdata[i].Post_name;
                        //context.Response.Write(postdata[i].Depname + "@");
                        //更新默认岗位
                        emp.UpdatePost(model);

                        // 更新客户,订单,合同,收款,开票 人员
                        emp.UpdateCOCRI(model);

                        //清除员工
                        hp.UpdatePostEmpbyEid(empid);
                    }

                    //设置员工
                    hp.UpdatePostEmp(modelpost);
                    //context.Response.Write("{success:success}");
                }
            }
            if (request["Action"] == "PersonalUpdate")
            {
                model.email    = PageValidate.InputText(request["T_email"], 255);
                model.name     = PageValidate.InputText(request["T_name"], 255);
                model.birthday = PageValidate.InputText(request["T_birthday"], 255);
                model.sex      = PageValidate.InputText(request["T_sex"], 255);
                model.idcard   = PageValidate.InputText(request["T_idcard"], 255);
                model.tel      = PageValidate.InputText(request["T_tel"], 255);


                model.address      = PageValidate.InputText(request["T_Adress"], 255);
                model.schools      = PageValidate.InputText(request["T_school"], 255);
                model.education    = PageValidate.InputText(request["T_edu"], 255);
                model.professional = PageValidate.InputText(request["T_professional"], 255);
                model.remarks      = PageValidate.InputText(request["T_remarks"], 255);
                model.title        = PageValidate.InputText(request["headurl"], 255);

                DataRow dr = dsemp.Tables[0].Rows[0];
                model.ID = emp_id;

                bool isup = emp.PersonalUpdate(model);

                if (isup)
                {
                    context.Response.Write("true");
                }
                else
                {
                    context.Response.Write("false");
                }

                C_Sys_log log = new C_Sys_log();

                int    UserID     = emp_id;
                string UserName   = empname;
                string IPStreet   = request.UserHostAddress;
                string EventTitle = model.name;
                string EventType  = "个人信息修改";
                int    EventID    = emp_id;

                if (dr["email"].ToString() != request["T_email"])
                {
                    log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "邮箱", dr["email"].ToString(), request["T_email"]);
                }

                if (dr["name"].ToString() != request["T_name"])
                {
                    log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "员工姓名", dr["name"].ToString(), request["T_name"]);
                }

                if (dr["birthday"].ToString() != request["T_birthday"])
                {
                    log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "员工生日", dr["birthday"].ToString(), request["T_birthday"]);
                }

                if (dr["sex"].ToString() != request["T_sex"])
                {
                    log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "员工性别", dr["sex"].ToString(), request["T_sex"]);
                }

                if (dr["idcard"].ToString() != request["T_idcard"])
                {
                    log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "身份证", dr["idcard"].ToString(), request["T_idcard"]);
                }

                if (dr["tel"].ToString() != request["T_tel"])
                {
                    log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "手机", dr["tel"].ToString(), request["T_tel"]);
                }

                if (dr["address"].ToString() != request["T_Adress"])
                {
                    log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "地址", dr["address"].ToString(), request["T_Adress"]);
                }

                if (dr["schools"].ToString() != request["T_school"])
                {
                    log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "毕业学校", dr["schools"].ToString(), request["T_school"]);
                }

                if (dr["education"].ToString() != request["T_edu"])
                {
                    log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "学历", dr["education"].ToString(), request["T_edu"]);
                }

                if (dr["professional"].ToString() != request["T_professional"])
                {
                    log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "专业", dr["professional"].ToString(), request["T_professional"]);
                }
            }
            //combo
            if (request["Action"] == "combo")
            {
                string serchtxt = " 1=1 ";

                string did = request["did"];
                if (!string.IsNullOrEmpty(did) && did != null && did != "null")
                {
                    serchtxt += " and d_id=" + int.Parse(did);
                }

                string authtxt = request["auth"];
                if (authtxt == "1")
                {
                    Data.GetDataAuth dataauth = new Data.GetDataAuth();
                    string           txt      = dataauth.GetDataAuthByid("1", "Sys_add", emp_id.ToString());
                    string[]         arr      = txt.Split(':');
                    switch (arr[0])
                    {
                    case "my": serchtxt += " and ID=" + emp_id;
                        break;
                    }
                }

                DataSet ds = emp.GetList(serchtxt);

                StringBuilder str = new StringBuilder();

                str.Append("[");
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    str.Append("{id:" + ds.Tables[0].Rows[i]["id"].ToString() + ",text:'" + ds.Tables[0].Rows[i]["name"] + "'},");
                }
                str.Replace(",", "", str.Length - 1, 1);
                str.Append("]");

                context.Response.Write(str);
            }
            //init
            if (request["Action"] == "init")
            {
                DataSet ds = emp.GetList("and ID=" + emp_id);

                StringBuilder str = new StringBuilder();

                if (ds.Tables[0].Rows.Count > 0)
                {
                    str.Append(ds.Tables[0].Rows[0]["ID"].ToString() + "|" + ds.Tables[0].Rows[0]["d_id"]);
                }


                context.Response.Write(str);
            }
            //changepwd
            if (request["Action"] == "changepwd")
            {
                DataSet ds = emp.GetPWD(emp_id);

                string oldpwd = FormsAuthentication.HashPasswordForStoringInConfigFile(request["T_oldpwd"], "MD5");
                string newpwd = FormsAuthentication.HashPasswordForStoringInConfigFile(request["T_newpwd"], "MD5");

                if (ds.Tables[0].Rows[0]["pwd"].ToString() == oldpwd)
                {
                    model.pwd = newpwd;
                    model.ID  = (emp_id);
                    emp.changepwd(model);
                    context.Response.Write("true");
                }
                else
                {
                    context.Response.Write("false");
                }
            }

            //allchangepwd
            if (request["Action"] == "allchangepwd")
            {
                string empid = request["empid"];

                string newpwd = FormsAuthentication.HashPasswordForStoringInConfigFile(request["T_newpwd"], "MD5");

                model.pwd = newpwd;
                model.ID  = int.Parse(empid);
                emp.changepwd(model);
            }
            //del
            if (request["Action"] == "del")
            {
                BLL.hr_post hp    = new BLL.hr_post();
                string      empid = PageValidate.InputText(request["id"], 50);

                string EventType = "员工删除";

                DataSet          ds       = emp.GetList(" id=" + int.Parse(empid));
                BLL.CRM_Customer customer = new BLL.CRM_Customer();
                int cc = customer.GetList("Employee_id=" + int.Parse(empid)).Tables[0].Rows.Count;

                if (cc > 0)
                {
                    context.Response.Write("false:customer");
                }
                else
                {
                    bool isdel = false;
                    isdel = emp.Delete(int.Parse(request["id"]));
                    //update post
                    hp.UpdatePostEmpbyEid(int.Parse(empid));


                    if (isdel)
                    {
                        int       UserID       = emp_id;
                        string    UserName     = empname;
                        string    IPStreet     = request.UserHostAddress;
                        int       EventID      = int.Parse(empid);
                        string    EventTitle   = ds.Tables[0].Rows[0]["name"].ToString();
                        string    Original_txt = null;
                        string    Current_txt  = null;
                        C_Sys_log log          = new C_Sys_log();
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, null, Original_txt, Current_txt);

                        context.Response.Write("true");
                    }
                    else
                    {
                        context.Response.Write("false");
                    }
                }
            }
        }
コード例 #2
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            HttpRequest request = context.Request;

            BLL.hr_employee   emp   = new BLL.hr_employee();
            Model.hr_employee model = new Model.hr_employee();
            int     emp_id          = int.Parse(request.Cookies["UserID"].Value.ToString());
            DataSet dsemp           = emp.GetList("id=" + emp_id);

            string empname = dsemp.Tables[0].Rows[0]["name"].ToString();
            string uid     = dsemp.Tables[0].Rows[0]["uid"].ToString();

            if (request["Action"] == "grid")
            {
                int    PageIndex = int.Parse(request["page"] == null ? "1" : request["page"]);
                int    PageSize  = int.Parse(request["pagesize"] == null ? "30" : request["pagesize"]);
                string sortname  = request["sortname"];
                string sortorder = request["sortorder"];

                if (string.IsNullOrEmpty(sortname))
                {
                    sortname = " ID";
                }
                if (string.IsNullOrEmpty(sortorder))
                {
                    sortorder = " desc";
                }

                string sorttext = " " + sortname + " " + sortorder;

                string Total;
                string serchtxt  = "uid!='admin'";
                string serchtype = request["isdel"];
                if (serchtype == "1")
                {
                    serchtxt += " and ISNULL(isDelete,0)=1";
                }
                else
                {
                    serchtxt += " and ISNULL(isDelete,0)=0 ";
                }


                if (!string.IsNullOrEmpty(request["stext"]))
                {
                    if (request["stext"] != "输入姓名搜索")
                    {
                        serchtxt += " and name like N'%" + PageValidate.InputText(request["stext"], 255) + "%'";
                    }
                }
                //权限
                DataSet ds = emp.GetList(PageSize, PageIndex, serchtxt, sorttext, out Total);

                string dt = Common.GetGridJSON.DataTableToJSON1(ds.Tables[0], Total);
                context.Response.Write(dt);
            }

            //validate
            if (request["Action"] == "Exist")
            {
                DataSet ds1 = emp.GetList(" uid='" + Common.PageValidate.InputText(request["T_uid"], 250) + "' ");

                context.Response.Write(ds1.Tables[0].Rows.Count > 0 ? "false" : "true");
            }

            //Form JSON
            if (request["Action"] == "form")
            {
                string eid = request["id"];
                if (!string.IsNullOrEmpty(eid))
                {
                    DataSet ds = emp.GetList("id=" + (Common.PageValidate.IsNumber(eid) ? eid : "-1"));

                    string dt = Common.DataToJson.DataToJSON(ds);

                    context.Response.Write(dt);
                }
            }
            //save
            if (request["Action"] == "save")
            {
                model.uid          = Common.PageValidate.InputText(request["T_uid"], 255);
                model.email        = Common.PageValidate.InputText(request["T_email"], 255);
                model.name         = Common.PageValidate.InputText(request["T_name"], 255);
                model.birthday     = Common.PageValidate.InputText(request["T_birthday"], 255);
                model.sex          = Common.PageValidate.InputText(request["T_sex"], 255);
                model.idcard       = Common.PageValidate.InputText(request["T_idcard"], 255);
                model.tel          = Common.PageValidate.InputText(request["T_tel"], 255);
                model.status       = Common.PageValidate.InputText(request["T_status"], 255);
                model.EntryDate    = Common.PageValidate.InputText(request["T_entryDate"], 255);
                model.address      = Common.PageValidate.InputText(request["T_Adress"], 255);
                model.schools      = Common.PageValidate.InputText(request["T_school"], 255);
                model.education    = Common.PageValidate.InputText(request["T_edu"], 255);
                model.professional = Common.PageValidate.InputText(request["T_professional"], 255);
                model.remarks      = Common.PageValidate.InputText(request["T_remarks"], 255);
                model.title        = Common.PageValidate.InputText(request["headurl"], 255);
                model.canlogin     = int.Parse(request["canlogin"]);



                int    empid;
                string id = request["id"];
                if (!string.IsNullOrEmpty(id) && id != "null")
                {
                    DataSet ds = emp.GetList(" ID=" + int.Parse(id));
                    DataRow dr = ds.Tables[0].Rows[0];
                    model.ID = int.Parse(id);
                    empid    = model.ID;


                    emp.Update(model);


                    C_Sys_log log = new C_Sys_log();

                    int    UserID     = emp_id;
                    string UserName   = empname;
                    string IPStreet   = request.UserHostAddress;
                    string EventTitle = model.name;
                    string EventType  = "员工修改";
                    int    EventID    = model.ID;

                    if (dr["email"].ToString() != request["T_email"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "邮箱", dr["email"].ToString(), request["T_email"]);
                    }
                    if (dr["name"].ToString() != request["T_name"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "员工姓名", dr["name"].ToString(), request["T_name"]);
                    }
                    if (dr["birthday"].ToString() != request["T_birthday"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "员工生日", dr["birthday"].ToString(), request["T_birthday"]);
                    }
                    if (dr["sex"].ToString() != request["T_sex"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "员工性别", dr["sex"].ToString(), request["T_sex"]);
                    }
                    if (dr["status"].ToString() != request["T_status"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "状态", dr["status"].ToString(), request["T_status"]);
                    }
                    if (dr["idcard"].ToString() != request["T_idcard"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "身份证", dr["idcard"].ToString(), request["T_idcard"]);
                    }
                    if (dr["tel"].ToString() != request["T_tel"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "手机", dr["tel"].ToString(), request["T_tel"]);
                    }
                    if (dr["EntryDate"].ToString() != request["T_entryDate"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "入职日期", dr["EntryDate"].ToString(), request["T_entryDate"]);
                    }
                    if (dr["address"].ToString() != request["T_Adress"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "地址", dr["address"].ToString(), request["T_Adress"]);
                    }
                    if (dr["schools"].ToString() != request["T_school"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "毕业学校", dr["schools"].ToString(), request["T_school"]);
                    }
                    if (dr["education"].ToString() != request["T_edu"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "学历", dr["education"].ToString(), request["T_edu"]);
                    }
                    if (dr["professional"].ToString() != request["T_professional"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "专业", dr["professional"].ToString(), request["T_professional"]);
                    }
                    if (dr["remarks"].ToString() != request["T_remarks"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "备注", dr["remarks"].ToString(), request["T_remarks"]);
                    }
                    if (dr["canlogin"].ToString() != request["canlogin"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "能否登录", dr["canlogin"].ToString(), request["canlogin"]);
                    }
                    //if (dr["headimages"].ToString() != request["headurl"])
                    //{
                    //    log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "形象照", dr["headimages"].ToString(), request["headurl"]);
                    //}

                    context.Response.Write(id + "|" + model.name);
                }
                else
                {
                    model.pwd = FormsAuthentication.HashPasswordForStoringInConfigFile("123456", "MD5");
                    empid     = emp.Add(model);
                    context.Response.Write("{success:success}");
                }

                //post
                string json             = request["PostData"].ToLower();
                JavaScriptSerializer js = new JavaScriptSerializer();

                PostData[] postdata;
                postdata = js.Deserialize <PostData[]>(json);

                BLL.hr_post   hp        = new BLL.hr_post();
                Model.hr_post modelpost = new Model.hr_post();

                modelpost.emp_id   = empid;
                model.ID           = empid;
                modelpost.emp_name = Common.PageValidate.InputText(request["T_name"], 255);

                for (int i = 0; i < postdata.Length; i++)
                {
                    modelpost.post_id      = postdata[i].Post_id;
                    modelpost.default_post = postdata[i].Default_post;

                    if (postdata[i].Default_post == 1)
                    {
                        model.d_id    = postdata[i].dep_id;
                        model.dname   = postdata[i].Depname;
                        model.zhiwuid = postdata[i].Position_id;
                        model.zhiwu   = postdata[i].Position_name;
                        model.postid  = postdata[i].Post_id;
                        model.post    = postdata[i].Post_name;
                        //context.Response.Write(postdata[i].Depname + "@");
                        emp.UpdatePost(model);
                    }

                    hp.UpdatePostEmp(modelpost);
                    //context.Response.Write("{success:success}");
                }
            }

            //combo
            if (request["Action"] == "combo")
            {
                string did = request["did"];
                if (!string.IsNullOrEmpty(did))
                {
                    DataSet ds = emp.GetList(" ISNULL(isDelete,0)=0 and d_id=" + (Common.PageValidate.IsNumber(did) ? did : "-1"));

                    StringBuilder str = new StringBuilder();

                    str.Append("[");
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        str.Append("{id:" + ds.Tables[0].Rows[i]["id"].ToString() + ",text:'" + ds.Tables[0].Rows[i]["name"] + "'},");
                    }
                    str.Replace(",", "", str.Length - 1, 1);
                    str.Append("]");

                    context.Response.Write(str);
                }
            }
            //init
            if (request["Action"] == "init")
            {
                DataSet ds = emp.GetList(" ISNULL(isDelete,0)=0 and ID=" + emp_id);

                StringBuilder str = new StringBuilder();

                if (ds.Tables[0].Rows.Count > 0)
                {
                    str.Append(ds.Tables[0].Rows[0]["ID"].ToString() + "|" + ds.Tables[0].Rows[0]["d_id"]);
                }


                context.Response.Write(str);
            }
            //changepwd
            if (request["Action"] == "changepwd")
            {
                DataSet ds = emp.GetPWD(emp_id);

                string oldpwd = FormsAuthentication.HashPasswordForStoringInConfigFile(request["T_oldpwd"], "MD5");
                string newpwd = FormsAuthentication.HashPasswordForStoringInConfigFile(request["T_newpwd"], "MD5");

                if (ds.Tables[0].Rows[0]["pwd"].ToString() == oldpwd)
                {
                    model.pwd = newpwd;
                    model.ID  = int.Parse(request.Cookies["UserID"].Value);
                    emp.changepwd(model);
                    context.Response.Write("true");
                }
                else
                {
                    context.Response.Write("false");
                }
            }

            //allchangepwd
            if (request["Action"] == "allchangepwd")
            {
                string empid = request["empid"];


                string newpwd = FormsAuthentication.HashPasswordForStoringInConfigFile(request["T_newpwd"], "MD5");

                model.pwd = newpwd;
                model.ID  = int.Parse(empid);
                emp.changepwd(model);
            }
            //del
            if (request["Action"] == "AdvanceDelete")
            {
                BLL.hr_post hp    = new BLL.hr_post();
                string      empid = request["id"];

                string EventType = "员工预删除";

                DataSet ds = emp.GetList(" id=" + int.Parse(empid));

                bool isdel = false;
                if (!string.IsNullOrEmpty(empid))
                {
                    if (Common.PageValidate.IsNumber(empid))
                    {
                        isdel = emp.AdvanceDelete(int.Parse(request["id"]), 1, DateTime.Now.ToString(StaticStr.yyyy_MM_dd_HH_mm_ss));
                        //update post
                        hp.UpdatePostEmpbyEid(int.Parse(empid));
                    }
                }

                if (isdel)
                {
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        int       UserID       = emp_id;
                        string    UserName     = empname;
                        string    IPStreet     = request.UserHostAddress;
                        int       EventID      = int.Parse(empid);
                        string    EventTitle   = ds.Tables[0].Rows[i]["name"].ToString();
                        string    Original_txt = null;
                        string    Current_txt  = null;
                        C_Sys_log log          = new C_Sys_log();
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, null, Original_txt, Current_txt);
                    }
                    context.Response.Write("true");
                }
                else
                {
                    context.Response.Write("false");
                }
            }

            if (request["Action"] == "regain")
            {
                string   idlist = PageValidate.InputText(request["idlist"], 100000);
                string[] arr    = idlist.Split(',');

                DataSet ds = emp.GetList("ID in (" + idlist.Trim() + ")");

                for (int i = 0; i < arr.Length; i++)
                {
                    emp.AdvanceDelete(int.Parse(arr[i]), 0, DateTime.Now.ToString(StaticStr.yyyy_MM_dd_HH_mm_ss));
                }

                if (true)
                {
                    //日志

                    string EventType = "恢复删除员工";


                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        int    UserID       = emp_id;
                        string UserName     = empname;
                        int    EventID      = idlist[i];
                        string IPStreet     = request.UserHostAddress;
                        string EventTitle   = ds.Tables[0].Rows[i]["name"].ToString();
                        string Original_txt = null;
                        string Current_txt  = null;

                        C_Sys_log log = new C_Sys_log();
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, null, Original_txt, Current_txt);
                    }

                    context.Response.Write("true");
                }
                else
                {
                    context.Response.Write("false");
                }
            }

            if (request["Action"] == "del")
            {
                bool canDel = false;
                if (dsemp.Tables[0].Rows.Count > 0)
                {
                    if (dsemp.Tables[0].Rows[0]["uid"].ToString() == "admin")
                    {
                        canDel = true;
                    }
                    else
                    {
                        Data.GetAuthorityByUid getauth = new Data.GetAuthorityByUid();
                        string delauth = getauth.GetBtnAuthority(request.Cookies["UserID"].Value, "84");
                        if (delauth == "false")
                        {
                            canDel = false;
                        }
                        else
                        {
                            canDel = true;
                        }
                    }
                }
                if (canDel)
                {
                    string   idlist = PageValidate.InputText(request["idlist"], 100000);
                    string[] arr    = idlist.Split(',');

                    string EventType = "彻底删除员工";

                    DataSet ds = emp.GetList("id in (" + idlist.Trim() + ")");

                    for (int i = 0; i < arr.Length; i++)
                    {
                        emp.Delete(int.Parse(arr[i]));
                    }

                    if (true)
                    {
                        //日志
                        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                        {
                            int    UserID       = emp_id;
                            string UserName     = empname;
                            string IPStreet     = request.UserHostAddress;
                            int    EventID      = idlist[i];
                            string EventTitle   = ds.Tables[0].Rows[0]["name"].ToString();
                            string Original_txt = null;
                            string Current_txt  = null;

                            C_Sys_log log = new C_Sys_log();

                            log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, null, Original_txt, Current_txt);
                        }
                        context.Response.Write("true");
                    }
                }
                else
                {
                    context.Response.Write("auth");
                }
            }
        }
コード例 #3
0
ファイル: hr_employee.ashx.cs プロジェクト: chuing/Push114CRM
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            HttpRequest request = context.Request;

            BLL.hr_employee emp = new BLL.hr_employee();
            Model.hr_employee model = new Model.hr_employee();
            int emp_id = int.Parse(request.Cookies["UserID"].Value.ToString());
            DataSet dsemp = emp.GetList("id=" + emp_id);

            string empname = dsemp.Tables[0].Rows[0]["name"].ToString();
            string uid = dsemp.Tables[0].Rows[0]["uid"].ToString();

            if (request["Action"] == "grid")
            {
                int PageIndex = int.Parse(request["page"] == null ? "1" : request["page"]);
                int PageSize = int.Parse(request["pagesize"] == null ? "30" : request["pagesize"]);
                string sortname = request["sortname"];
                string sortorder = request["sortorder"];

                if (string.IsNullOrEmpty(sortname))
                    sortname = " ID";
                if (string.IsNullOrEmpty(sortorder))
                    sortorder = " desc";

                string sorttext = " " + sortname + " " + sortorder;

                string Total;
                string serchtxt = "uid!='admin'";
                string serchtype = request["isdel"];
                if (serchtype == "1")
                {
                    serchtxt += " and isDelete=1";
                }
                else
                {
                    serchtxt += " and isDelete=0 ";
                }

                if (!string.IsNullOrEmpty(request["stext"]))
                {
                    if (request["stext"] != "输入姓名搜索")
                        serchtxt += " and name like N'%" + PageValidate.InputText(request["stext"], 255) + "%'";
                }
                //权限
                DataSet ds = emp.GetList(PageSize, PageIndex, serchtxt, sorttext, out Total);

                string dt = Common.GetGridJSON.DataTableToJSON1(ds.Tables[0], Total);
                context.Response.Write(dt);
            }
            //表格json
            if (request["Action"] == "getRole")
            {
                int r_empid = int.Parse(request["empid"]);
                DataSet ds = emp.GetRole(r_empid);

                string dt = Common.GetGridJSON.DataTableToJSON(ds.Tables[0]);

                context.Response.Write(dt);
            }
            //validate
            if (request["Action"] == "Exist")
            {
                string user_id = request["T_uid"];
                string T_emp_id = request["emp_id"];
                if (string.IsNullOrEmpty(T_emp_id) || T_emp_id == "null")
                    T_emp_id = "0";

                DataSet ds1 = emp.GetList(" uid='" + PageValidate.InputText(user_id, 250) + "' and  ID!=" + int.Parse(T_emp_id));

                context.Response.Write(ds1.Tables[0].Rows.Count > 0 ? "false" : "true");

            }

            //Form JSON
            if (request["Action"] == "form")
            {

                string eid = request["id"];
                if (!string.IsNullOrEmpty(eid))
                {
                    DataSet ds = emp.GetList("id=" + (PageValidate.IsNumber(eid) ? eid : "-1"));

                    string dt = Common.DataToJson.DataToJSON(ds);

                    context.Response.Write(dt);
                }
            }
            //save
            if (request["Action"] == "save")
            {
                model.uid = PageValidate.InputText(request["T_uid"], 255);
                model.email = PageValidate.InputText(request["T_email"], 255);
                model.name = PageValidate.InputText(request["T_name"], 255);
                model.birthday = PageValidate.InputText(request["T_birthday"], 255);
                model.sex = PageValidate.InputText(request["T_sex"], 255);
                model.idcard = PageValidate.InputText(request["T_idcard"], 255);
                model.tel = PageValidate.InputText(request["T_tel"], 255);
                model.status = PageValidate.InputText(request["T_status"], 255);
                model.EntryDate = PageValidate.InputText(request["T_entryDate"], 255);
                model.address = PageValidate.InputText(request["T_Adress"], 255);
                model.schools = PageValidate.InputText(request["T_school"], 255);
                model.education = PageValidate.InputText(request["T_edu"], 255);
                model.professional = PageValidate.InputText(request["T_professional"], 255);
                model.remarks = PageValidate.InputText(request["T_remarks"], 255);
                model.title = PageValidate.InputText(request["headurl"], 255);
                model.canlogin = int.Parse(request["canlogin"]);

                int empid;
                string id = request["id"];
                if (!string.IsNullOrEmpty(id) && id != "null")
                {
                    DataSet ds = emp.GetList(" ID=" + int.Parse(id));
                    DataRow dr = ds.Tables[0].Rows[0];
                    model.ID = int.Parse(id);
                    empid = model.ID;

                    emp.Update(model);

                    C_Sys_log log = new C_Sys_log();

                    int UserID = emp_id;
                    string UserName = empname;
                    string IPStreet = request.UserHostAddress;
                    string EventTitle = model.name;
                    string EventType = "员工修改";
                    int EventID = model.ID;

                    if (dr["email"].ToString() != request["T_email"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "邮箱", dr["email"].ToString(), request["T_email"]);
                    }
                    if (dr["name"].ToString() != request["T_name"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "员工姓名", dr["name"].ToString(), request["T_name"]);
                    }
                    if (dr["birthday"].ToString() != request["T_birthday"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "员工生日", dr["birthday"].ToString(), request["T_birthday"]);
                    }
                    if (dr["sex"].ToString() != request["T_sex"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "员工性别", dr["sex"].ToString(), request["T_sex"]);
                    }
                    if (dr["status"].ToString() != request["T_status"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "状态", dr["status"].ToString(), request["T_status"]);
                    }
                    if (dr["idcard"].ToString() != request["T_idcard"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "身份证", dr["idcard"].ToString(), request["T_idcard"]);
                    }
                    if (dr["tel"].ToString() != request["T_tel"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "手机", dr["tel"].ToString(), request["T_tel"]);
                    }
                    if (dr["EntryDate"].ToString() != request["T_entryDate"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "入职日期", dr["EntryDate"].ToString(), request["T_entryDate"]);
                    }
                    if (dr["address"].ToString() != request["T_Adress"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "地址", dr["address"].ToString(), request["T_Adress"]);
                    }
                    if (dr["schools"].ToString() != request["T_school"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "毕业学校", dr["schools"].ToString(), request["T_school"]);
                    }
                    if (dr["education"].ToString() != request["T_edu"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "学历", dr["education"].ToString(), request["T_edu"]);
                    }
                    if (dr["professional"].ToString() != request["T_professional"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "专业", dr["professional"].ToString(), request["T_professional"]);
                    }
                    if (dr["remarks"].ToString() != request["T_remarks"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "备注", dr["remarks"].ToString(), request["T_remarks"]);
                    }
                    if (dr["canlogin"].ToString() != request["canlogin"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "能否登录", dr["canlogin"].ToString(), request["canlogin"]);
                    }

                    context.Response.Write(id + "|" + model.name);
                }
                else
                {
                    model.isDelete = 0;
                    model.pwd = FormsAuthentication.HashPasswordForStoringInConfigFile("123456", "MD5");
                    empid = emp.Add(model);
                    context.Response.Write("{success:success}");
                }

                //post
                string json = request["PostData"].ToLower();
                JavaScriptSerializer js = new JavaScriptSerializer();

                PostData[] postdata;
                postdata = js.Deserialize<PostData[]>(json);

                BLL.hr_post hp = new BLL.hr_post();
                Model.hr_post modelpost = new Model.hr_post();

                modelpost.emp_id = empid;
                model.ID = empid;
                modelpost.emp_name = PageValidate.InputText(request["T_name"], 255);

                for (int i = 0; i < postdata.Length; i++)
                {
                    modelpost.post_id = postdata[i].Post_id;
                    modelpost.default_post = postdata[i].Default_post;

                    if (postdata[i].Default_post == 1)
                    {
                        model.d_id = postdata[i].dep_id;
                        model.dname = postdata[i].Depname;
                        model.zhiwuid = postdata[i].Position_id;
                        model.zhiwu = postdata[i].Position_name;
                        model.postid = postdata[i].Post_id;
                        model.post = postdata[i].Post_name;
                        //context.Response.Write(postdata[i].Depname + "@");
                        //更新默认岗位
                        emp.UpdatePost(model);

                        //清除员工
                        hp.UpdatePostEmpbyEid(empid);
                    }

                    //设置员工
                    hp.UpdatePostEmp(modelpost);
                    //context.Response.Write("{success:success}");
                }
            }
            if (request["Action"] == "PersonalUpdate")
            {
                model.email = PageValidate.InputText(request["T_email"], 255);
                model.name = PageValidate.InputText(request["T_name"], 255);
                model.birthday = PageValidate.InputText(request["T_birthday"], 255);
                model.sex = PageValidate.InputText(request["T_sex"], 255);
                model.idcard = PageValidate.InputText(request["T_idcard"], 255);
                model.tel = PageValidate.InputText(request["T_tel"], 255);

                model.address = PageValidate.InputText(request["T_Adress"], 255);
                model.schools = PageValidate.InputText(request["T_school"], 255);
                model.education = PageValidate.InputText(request["T_edu"], 255);
                model.professional = PageValidate.InputText(request["T_professional"], 255);
                model.remarks = PageValidate.InputText(request["T_remarks"], 255);
                model.title = PageValidate.InputText(request["headurl"], 255);

                int empid;
                string id = request["id"];
                if (!string.IsNullOrEmpty(id) && id != "null")
                {
                    DataSet ds = emp.GetList(" ID=" + int.Parse(id));
                    DataRow dr = ds.Tables[0].Rows[0];
                    model.ID = int.Parse(id);
                    empid = model.ID;

                    emp.PersonalUpdate(model);

                    C_Sys_log log = new C_Sys_log();

                    int UserID = emp_id;
                    string UserName = empname;
                    string IPStreet = request.UserHostAddress;
                    string EventTitle = model.name;
                    string EventType = "个人信息修改";
                    int EventID = model.ID;

                    if (dr["email"].ToString() != request["T_email"])
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "邮箱", dr["email"].ToString(), request["T_email"]);

                    if (dr["name"].ToString() != request["T_name"])
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "员工姓名", dr["name"].ToString(), request["T_name"]);

                    if (dr["birthday"].ToString() != request["T_birthday"])
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "员工生日", dr["birthday"].ToString(), request["T_birthday"]);

                    if (dr["sex"].ToString() != request["T_sex"])
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "员工性别", dr["sex"].ToString(), request["T_sex"]);

                    if (dr["idcard"].ToString() != request["T_idcard"])
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "身份证", dr["idcard"].ToString(), request["T_idcard"]);

                    if (dr["tel"].ToString() != request["T_tel"])
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "手机", dr["tel"].ToString(), request["T_tel"]);

                    if (dr["address"].ToString() != request["T_Adress"])
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "地址", dr["address"].ToString(), request["T_Adress"]);

                    if (dr["schools"].ToString() != request["T_school"])
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "毕业学校", dr["schools"].ToString(), request["T_school"]);

                    if (dr["education"].ToString() != request["T_edu"])
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "学历", dr["education"].ToString(), request["T_edu"]);

                    if (dr["professional"].ToString() != request["T_professional"])
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "专业", dr["professional"].ToString(), request["T_professional"]);

                    context.Response.Write("true");
                }
                else
                {
                    context.Response.Write("false");
                }
            }
            //combo
            if (request["Action"] == "combo")
            {
                string serchtxt = " isDelete=0 ";

                string did = request["did"];
                if (!string.IsNullOrEmpty(did) && did != null && did != "null")
                    serchtxt += " and d_id=" + int.Parse(did);

                string authtxt = request["auth"];
                if (authtxt == "1")
                {
                    Data.GetDataAuth dataauth = new Data.GetDataAuth();
                    string txt = dataauth.GetDataAuthByid("1", "Sys_add", emp_id.ToString());
                    string[] arr = txt.Split(':');
                    switch (arr[0])
                    {
                        case "my": serchtxt += " and ID=" + emp_id;
                            break;
                    }
                }

                DataSet ds = emp.GetList(serchtxt);

                StringBuilder str = new StringBuilder();

                str.Append("[");
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    str.Append("{id:" + ds.Tables[0].Rows[i]["id"].ToString() + ",text:'" + ds.Tables[0].Rows[i]["name"] + "'},");
                }
                str.Replace(",", "", str.Length - 1, 1);
                str.Append("]");

                context.Response.Write(str);

            }
            //init
            if (request["Action"] == "init")
            {

                DataSet ds = emp.GetList(" isDelete=0 and ID=" + emp_id);

                StringBuilder str = new StringBuilder();

                if (ds.Tables[0].Rows.Count > 0)
                {
                    str.Append(ds.Tables[0].Rows[0]["ID"].ToString() + "|" + ds.Tables[0].Rows[0]["d_id"]);
                }

                context.Response.Write(str);
            }
            //changepwd
            if (request["Action"] == "changepwd")
            {

                DataSet ds = emp.GetPWD(emp_id);

                string oldpwd = FormsAuthentication.HashPasswordForStoringInConfigFile(request["T_oldpwd"], "MD5");
                string newpwd = FormsAuthentication.HashPasswordForStoringInConfigFile(request["T_newpwd"], "MD5");

                if (ds.Tables[0].Rows[0]["pwd"].ToString() == oldpwd)
                {
                    model.pwd = newpwd;
                    model.ID = int.Parse(request.Cookies["UserID"].Value);
                    emp.changepwd(model);
                    context.Response.Write("true");
                }
                else
                {
                    context.Response.Write("false");
                }
            }

            //allchangepwd
            if (request["Action"] == "allchangepwd")
            {
                string empid = request["empid"];

                string newpwd = FormsAuthentication.HashPasswordForStoringInConfigFile(request["T_newpwd"], "MD5");

                model.pwd = newpwd;
                model.ID = int.Parse(empid);
                emp.changepwd(model);

            }
            //del
            if (request["Action"] == "AdvanceDelete")
            {

                BLL.hr_post hp = new BLL.hr_post();
                string empid = request["id"];

                string EventType = "员工预删除";

                DataSet ds = emp.GetList(" id=" + int.Parse(empid));
                BLL.CRM_Customer customer = new BLL.CRM_Customer();
                int cc = customer.GetList("Employee_id=" + int.Parse(empid)).Tables[0].Rows.Count;

                if (cc > 0)
                {
                    context.Response.Write("false:customer");
                }
                else
                {
                    bool isdel = false;
                    isdel = emp.AdvanceDelete(int.Parse(request["id"]), 1, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                    //update post
                    hp.UpdatePostEmpbyEid(int.Parse(empid));

                    if (isdel)
                    {
                        int UserID = emp_id;
                        string UserName = empname;
                        string IPStreet = request.UserHostAddress;
                        int EventID = int.Parse(empid);
                        string EventTitle = ds.Tables[0].Rows[0]["name"].ToString();
                        string Original_txt = null;
                        string Current_txt = null;
                        C_Sys_log log = new C_Sys_log();
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, null, Original_txt, Current_txt);

                        context.Response.Write("true");
                    }
                    else
                    {
                        context.Response.Write("false");
                    }
                }
            }

            if (request["Action"] == "regain")
            {
                string idlist = PageValidate.InputText(request["idlist"], 100000);
                string[] arr = idlist.Split(',');

                DataSet ds = emp.GetList("ID in (" + idlist.Trim() + ")");

                for (int i = 0; i < arr.Length; i++)
                {
                    emp.AdvanceDelete(int.Parse(arr[i]), 0, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                }

                if (true)
                {
                    //日志

                    string EventType = "恢复删除员工";

                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        int UserID = emp_id;
                        string UserName = empname;
                        int EventID = idlist[i];
                        string IPStreet = request.UserHostAddress;
                        string EventTitle = ds.Tables[0].Rows[i]["name"].ToString();
                        string Original_txt = null;
                        string Current_txt = null;

                        C_Sys_log log = new C_Sys_log();
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, null, Original_txt, Current_txt);
                    }

                    context.Response.Write("true");
                }
                else
                {

                    context.Response.Write("false");
                }
            }

            if (request["Action"] == "del")
            {
                bool canDel = false;
                if (dsemp.Tables[0].Rows.Count > 0)
                {
                    if (dsemp.Tables[0].Rows[0]["uid"].ToString() == "admin")
                    {
                        canDel = true;
                    }
                    else
                    {
                        Data.GetAuthorityByUid getauth = new Data.GetAuthorityByUid();
                        string delauth = getauth.GetBtnAuthority(request.Cookies["UserID"].Value, "84");
                        if (delauth == "false")
                            canDel = false;
                        else
                            canDel = true;
                    }
                }
                if (canDel)
                {
                    string idlist = PageValidate.InputText(request["idlist"], 100000);
                    string[] arr = idlist.Split(',');

                    string EventType = "彻底删除员工";

                    DataSet ds = emp.GetList("id in (" + idlist.Trim() + ")");

                    for (int i = 0; i < arr.Length; i++)
                    {
                        emp.Delete(int.Parse(arr[i]));
                    }

                    if (true)
                    {
                        //日志
                        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                        {
                            int UserID = emp_id;
                            string UserName = empname;
                            string IPStreet = request.UserHostAddress;
                            int EventID = idlist[i];
                            string EventTitle = ds.Tables[0].Rows[0]["name"].ToString();
                            string Original_txt = null;
                            string Current_txt = null;

                            C_Sys_log log = new C_Sys_log();

                            log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, null, Original_txt, Current_txt);
                        }
                        context.Response.Write("true");
                    }
                }
                else
                {
                    context.Response.Write("auth");
                }
            }
        }
コード例 #4
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            HttpRequest request = context.Request;

            BLL.hr_post   post  = new BLL.hr_post();
            Model.hr_post model = new Model.hr_post();

            BLL.hr_employee   emp      = new BLL.hr_employee();
            Model.hr_employee modelemp = new Model.hr_employee();
            int     emp_id             = int.Parse(request.Cookies["UserID"].Value.ToString());
            DataSet dsemp   = emp.GetList("id=" + emp_id);
            string  empname = dsemp.Tables[0].Rows[0]["name"].ToString();
            string  uid     = dsemp.Tables[0].Rows[0]["uid"].ToString();

            if (request["Action"] == "grid")
            {
                int    depid     = Common.PageValidate.IsNumber(request["depid"]) ? int.Parse(request["depid"]) : 0;
                string emps      = request["empstatus"];
                int    empstuats = 0;
                if (!string.IsNullOrEmpty(emps))
                {
                    empstuats = Common.PageValidate.IsNumber(request["empstatus"]) ? int.Parse(request["empstatus"]) : 0;
                }

                string wherestr = " and ";
                switch (empstuats)
                {
                case 0: wherestr += "1=1";
                    break;

                case 1: wherestr += "emp_id=-1";
                    break;

                case 2: wherestr += "emp_id!=-1";
                    break;
                }
                DataSet ds = post.GetList(0, " ISNULL(isDelete,0)=0 and dep_id=" + depid + wherestr, " convert(int,isnull(0,[position_order]))");
                string  dt = Common.GetGridJSON.DataTableToJSON(ds.Tables[0]);
                context.Response.Write(dt);
            }

            if (request["Action"] == "delgrid")
            {
                DataSet ds = post.GetList(0, " ISNULL(isDelete,0)=1 ", " convert(int,isnull(0,[position_order]))");
                string  dt = Common.GetGridJSON.DataTableToJSON(ds.Tables[0]);
                context.Response.Write(dt);
            }
            if (request["Action"] == "save")
            {
                //dep
                model.dep_id  = int.Parse(request["T_depname_val"]);
                model.depname = Common.PageValidate.InputText(request["T_depname"], 250);
                //name
                model.post_name = Common.PageValidate.InputText(request["T_postname"], 250);
                //position
                model.position_id    = int.Parse(request["T_position_val"]);
                model.position_name  = Common.PageValidate.InputText(request["T_position"], 250);
                model.position_order = Common.PageValidate.InputText(request["T_position_leavel"], 50);
                //emp
                int empid = Common.PageValidate.IsNumber(request["T_emp_val"]) ? int.Parse(request["T_emp_val"]) : -1;
                model.emp_id   = empid;
                model.emp_name = Common.PageValidate.InputText(request["T_emp"], 250);
                //note
                model.note = Common.PageValidate.InputText(request["T_descript"], 4000);

                string postid = request["postid"];

                if (!string.IsNullOrEmpty(postid) && postid != "null")
                {
                    model.post_id = int.Parse(postid);
                    DataSet ds = post.GetList(" post_id=" + int.Parse(postid));
                    DataRow dr = ds.Tables[0].Rows[0];
                    post.Update(model);

                    //日志
                    C_Sys_log log = new C_Sys_log();

                    int    UserID     = emp_id;
                    string UserName   = empname;
                    string IPStreet   = request.UserHostAddress;
                    string EventTitle = model.position_name;
                    string EventType  = "岗位修改";
                    int    EventID    = model.post_id;

                    if (dr["post_name"].ToString() != request["T_postname"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "岗位名称", dr["post_name"].ToString(), request["T_postname"]);
                    }
                    if (dr["position_name"].ToString() != request["T_position"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "岗位级别", dr["position_name"].ToString(), request["T_position"]);
                    }
                    if (dr["emp_name"].ToString() != request["T_emp"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "岗位员工", dr["emp_name"].ToString(), request["T_emp"]);
                    }
                    if (dr["note"].ToString() != request["T_descript"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "描述", dr["note"].ToString(), request["T_descript"]);
                    }
                }
                else
                {
                    post.Add(model);
                }
            }
            //Form JSON
            if (request["Action"] == "form")
            {
                int         postid = int.Parse(request["postid"]);
                BLL.hr_post hp     = new BLL.hr_post();
                DataSet     ds     = hp.GetList("post_id=" + postid);

                string dt = Common.DataToJson.DataToJSON(ds);

                context.Response.Write(dt);
            }
            //del
            if (request["Action"] == "AdvanceDelete")
            {
                string postid = request["id"];

                string  EventType = "岗位预删除";
                DataSet ds        = post.GetList(" post_id=" + int.Parse(postid));

                if (emp.GetList(" postid=" + int.Parse(postid)).Tables[0].Rows.Count > 0)
                {
                    //含有员工信息不能删除
                    context.Response.Write("false:emp");
                }
                else
                {
                    bool isdel = post.AdvanceDelete(int.Parse(postid), 1, DateTime.Now.ToString(StaticStr.yyyy_MM_dd_HH_mm_ss));
                    if (isdel)
                    {
                        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                        {
                            int       UserID       = emp_id;
                            string    UserName     = empname;
                            string    IPStreet     = request.UserHostAddress;
                            int       EventID      = int.Parse(postid);
                            string    EventTitle   = ds.Tables[0].Rows[i]["post_name"].ToString();
                            string    Original_txt = null;
                            string    Current_txt  = null;
                            C_Sys_log log          = new C_Sys_log();
                            log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, null, Original_txt, Current_txt);
                        }
                        context.Response.Write("true");
                    }
                    else
                    {
                        context.Response.Write("false");
                    }
                }
            }

            if (request["Action"] == "regain")
            {
                string   idlist = Common.PageValidate.InputText(request["idlist"], 100000);
                string[] arr    = idlist.Split(',');

                DataSet ds = post.GetList("post_id in (" + idlist.Trim() + ")");

                for (int i = 0; i < arr.Length; i++)
                {
                    post.AdvanceDelete(int.Parse(arr[i]), 0, DateTime.Now.ToString(StaticStr.yyyy_MM_dd_HH_mm_ss));
                }

                if (true)
                {
                    //日志
                    string EventType = "恢复删除岗位";

                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        int    UserID       = emp_id;
                        string UserName     = empname;
                        int    EventID      = idlist[i];
                        string IPStreet     = request.UserHostAddress;
                        string EventTitle   = ds.Tables[0].Rows[i]["post_name"].ToString();
                        string Original_txt = null;
                        string Current_txt  = null;

                        C_Sys_log log = new C_Sys_log();
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, null, Original_txt, Current_txt);
                    }

                    context.Response.Write("true");
                }
            }

            if (request["Action"] == "del")
            {
                bool canDel = false;
                if (dsemp.Tables[0].Rows.Count > 0)
                {
                    if (dsemp.Tables[0].Rows[0]["uid"].ToString() == "admin")
                    {
                        canDel = true;
                    }
                    else
                    {
                        Data.GetAuthorityByUid getauth = new Data.GetAuthorityByUid();
                        string delauth = getauth.GetBtnAuthority(request.Cookies["UserID"].Value, "82");
                        if (delauth == "false")
                        {
                            canDel = false;
                        }
                        else
                        {
                            canDel = true;
                        }
                    }
                }
                if (canDel)
                {
                    string   idlist = Common.PageValidate.InputText(request["idlist"], 1000000);
                    string[] arr    = idlist.Split(',');

                    string EventType = "彻底删除岗位";

                    DataSet ds = post.GetList("post_id in (" + idlist.Trim() + ")");

                    for (int i = 0; i < arr.Length; i++)
                    {
                        post.Delete(int.Parse(arr[i]));
                    }

                    if (true)
                    {
                        //日志
                        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                        {
                            int    UserID       = emp_id;
                            string UserName     = empname;
                            string IPStreet     = request.UserHostAddress;
                            int    EventID      = idlist[i];
                            string EventTitle   = ds.Tables[0].Rows[0]["post_name"].ToString();
                            string Original_txt = null;
                            string Current_txt  = null;

                            C_Sys_log log = new C_Sys_log();

                            log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, null, Original_txt, Current_txt);
                        }
                        context.Response.Write("true");
                    }
                }
                else
                {
                    context.Response.Write("auth");
                }
            }


            //get post by empid
            if (request["Action"] == "getpostbyempid")
            {
                BLL.hr_post hp    = new BLL.hr_post();
                int         empid = int.Parse(request["empid"]);
                DataSet     ds    = hp.GetList(" ISNULL(isDelete,0)=0 and emp_id=" + empid);
                if (ds.Tables[0].Rows.Count > 0)
                {
                    string dt = Common.GetGridJSON.DataTableToJSON(ds.Tables[0]);
                    context.Response.Write(dt);
                }
            }
            //serch
            if (request["Action"] == "serch")
            {
                BLL.hr_post hp       = new BLL.hr_post();
                string      serchtxt = Common.PageValidate.InputText(request["Serchtext"], 255);
                DataSet     ds       = hp.GetList(" ISNULL(isDelete,0)=0 and post_name like N'%" + serchtxt + "%'");
                if (ds.Tables[0].Rows.Count > 0)
                {
                    string dt = Common.GetGridJSON.DataTableToJSON(ds.Tables[0]);
                    context.Response.Write(dt);
                }
                else
                {
                    context.Response.Write("post_name like N'%" + serchtxt + "%'");
                }
            }
            //post_emp
            if (request["Action"] == "postemp")
            {
                string json             = request["PostData"].ToLower();
                JavaScriptSerializer js = new JavaScriptSerializer();

                PostData[] postdata;
                postdata = js.Deserialize <PostData[]>(json);

                BLL.hr_post hp = new BLL.hr_post();


                string empid = request["empid"];
                int    Eid   = -1;
                if (!string.IsNullOrEmpty(empid))
                {
                    Eid = Common.PageValidate.IsNumber(empid) ? int.Parse(empid) : -1;
                }

                model.emp_id   = Eid;
                modelemp.ID    = Eid;
                model.emp_name = Common.PageValidate.InputText(request["emp_name"], 255);

                for (int i = 0; i < postdata.Length; i++)
                {
                    model.post_id      = postdata[i].Post_id;
                    model.default_post = postdata[i].Default_post;

                    if (postdata[i].Default_post == 1)
                    {
                        modelemp.d_id    = postdata[i].Dep_id;
                        modelemp.dname   = postdata[i].Depname;
                        modelemp.zhiwuid = postdata[i].Position_id;
                        modelemp.zhiwu   = postdata[i].Position_name;
                        modelemp.postid  = postdata[i].Post_id;
                        modelemp.post    = postdata[i].Post_name;
                        //context.Response.Write(postdata[i].Depname + "@");
                        emp.UpdatePost(modelemp);
                    }

                    hp.UpdatePostEmp(model);
                }
            }
            //combo
            if (request["Action"] == "combo")
            {
                int postid = int.Parse(request["postid"]);

                DataSet ds = post.GetList(" ISNULL(isDelete,0)=0 and dep_id=" + postid);

                StringBuilder str = new StringBuilder();

                str.Append("[");
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    str.Append("{id:" + ds.Tables[0].Rows[i]["post_id"].ToString() + ",text:'" + ds.Tables[0].Rows[i]["post_name"] + "'},");
                }
                str.Replace(",", "", str.Length - 1, 1);
                str.Append("]");

                context.Response.Write(str);
            }
        }
コード例 #5
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Charset     = "utf-8";
            HttpRequest request = context.Request;

            if (request["Action"] == "login")
            {
                BLL.hr_employee     emp = new BLL.hr_employee();
                BLL.Sys_FactoryInfo fty = new BLL.Sys_FactoryInfo();

                string username = PageValidate.InputText(request["username"], 255);
                //string password = FormsAuthentication.HashPasswordForStoringInConfigFile(request["password"], "MD5");
                string password = PageValidate.InputText(request["password"], 255);
                string validate = PageValidate.InputText(request["validate"], 255);

                //SQL注入式攻击过滤===========================================================================================
                string path = context.Server.MapPath(@"../file/SQLFile.txt");
                if (CommonData.getSQLPercolation(username.ToUpper(), path))
                {
                    context.Response.Write("999");//系统错误
                    return;
                }
                //============================================================================================================

                if (!string.IsNullOrEmpty(validate) && !string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password))
                {
                    if (validate == context.Session["CheckCode"].ToString() || validate.ToLower() == context.Session["CheckCode"].ToString().ToLower())
                    {
                        //DataSet ds = emp.GetList(" uid='" + username + "' and pwd='" + password + "'");
                        Model.hr_employee empModel = emp.LoginUser(username);
                        //IP 限制====================================================================================================
                        string vrip = GetClientIPv4Address();

                        List <string> lstIp = new List <string>();
                        lstIp.Add("219.146.197.91");    //电信IP地址
                        lstIp.Add("60.213.50.226");     //联通IP地址

                        lstIp.Add("172.178.1.118");     //本地(邢荣)
                        lstIp.Add("172.178.1.211");     //本地(陈伟)
                        lstIp.Add("172.178.1.100");     //本地(陈伟)
                        lstIp.Add("172.178.1.203");     //本地(robert)
                        lstIp.Add("172.178.1.201");     //本地(李明)
                        lstIp.Add("172.178.1.79");      //本地(王德胜)
                        lstIp.Add("172.178.1.117");     //本地(王立全)
                        lstIp.Add("172.178.1.243");     //本地(王虎)
                        //if (!lstIp.Contains(vrip))
                        //{
                        //    //修改:robert, 2016-06-04     过滤特殊人群,当前:王频频wpp6274========
                        //    if (username.Trim() != "wpp6274" && username.Trim() != "gjc1010")
                        //    {
                        //        context.Response.Write("6");//ip受限制
                        //        return;
                        //    }
                        //    //=======================================================================
                        //}
                        //============================================================================================================

                        if (empModel != null && empModel.pwd == password.ToUpper())
                        {
                            //只允许李辉、郭建传,李艳梅,admin登录
                            //if (username.Trim() != "li5001" && username.Trim() != "1010" && username.Trim() != "lym5007" && username.Trim() != "admin" && username.Trim() != "yqy5062" && username.Trim() != "lgh1128" && username.Trim() != "lc1271" && username.Trim() != "zf6346")
                            //{
                            //    context.Response.Write("6");//ip受限制
                            //    return;
                            //}
                            //=======================================================================
                            //存在该 uid的用户,并且 pwd-密码正确;执行以下内容
                            //if (ds.Tables[0].Rows.Count > 0)
                            //{
                            if (empModel.uid.Trim() == "admin")
                            {
                                #region
                                //string userid = empModel.ID.ToString();
                                FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
                                    1,
                                    empModel.uid,
                                    DateTime.Now,
                                    DateTime.Now.AddMinutes(20),
                                    true,
                                    empModel.ID.ToString(),
                                    "/"
                                    );
                                var cookie = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(ticket));
                                cookie.HttpOnly = true;
                                context.Response.Cookies.Add(cookie);

                                //FormsAuthentication.SetAuthCookie(userid, true);

                                //日志
                                //BLL.Sys_log log = new BLL.Sys_log();
                                //Model.Sys_log modellog = new Model.Sys_log();
                                //modellog.EventType = "系统登录";

                                //modellog.EventDate = DateTime.Now;
                                //modellog.UserID = empModel.ID;
                                //modellog.UserName = empModel.name;
                                //modellog.IPStreet = request.UserHostAddress;
                                //modellog.Factory_Id = empModel.factory_Id;

                                //log.Add(modellog);

                                //online
                                BLL.Sys_online   sol   = new BLL.Sys_online();
                                Model.Sys_online model = new Model.Sys_online();

                                model.UserName    = empModel.name;
                                model.UserID      = empModel.ID;
                                model.LastLogTime = DateTime.Now;

                                DataSet ds1 = sol.GetList(" UserID=" + empModel.ID);

                                //添加当前用户信息
                                if (ds1.Tables[0].Rows.Count > 0)
                                {
                                    sol.Update(model, " UserID=" + empModel.ID);
                                }
                                else
                                {
                                    sol.Add(model);
                                }
                                //删除超时用户
                                //2分钟用户失效,删除 --Robert 2015-11-24
                                sol.Delete(" LastLogTime<date_sub(now(), interval 5 minute)");

                                //验证完毕,允许登录
                                context.Response.Write("2");
                                #endregion
                            }
                            else
                            {
                                #region
                                DataSet dsfty    = fty.GetList("Factory_Id='" + empModel.factory_Id + "'");
                                string  isDelete = dsfty.Tables[0].Rows[0]["IsDelete"].ToString();
                                if (int.Parse(isDelete) == 0)
                                {
                                    if (empModel.canlogin.ToString() == "1")
                                    {
                                        FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
                                            1,
                                            username,
                                            DateTime.Now,
                                            DateTime.Now.AddMinutes(20),
                                            true,
                                            empModel.ID.ToString(),
                                            "/"
                                            );
                                        var cookie = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(ticket));
                                        cookie.HttpOnly = true;
                                        context.Response.Cookies.Add(cookie);

                                        //FormsAuthentication.SetAuthCookie(userid, true);

                                        //日志
                                        BLL.Sys_log   log      = new BLL.Sys_log();
                                        Model.Sys_log modellog = new Model.Sys_log();
                                        modellog.EventType = "系统登录";

                                        modellog.EventDate   = DateTime.Now;
                                        modellog.UserID      = empModel.ID;
                                        modellog.UserName    = empModel.name;
                                        modellog.IPStreet    = request.UserHostAddress;
                                        modellog.Current_txt = "DAS 用户登录";
                                        modellog.Factory_Id  = empModel.factory_Id;

                                        log.Add(modellog);

                                        //online
                                        BLL.Sys_online   sol   = new BLL.Sys_online();
                                        Model.Sys_online model = new Model.Sys_online();

                                        model.UserName    = empModel.name;
                                        model.UserID      = empModel.ID;
                                        model.LastLogTime = DateTime.Now;

                                        DataSet ds1 = sol.GetList(" UserID=" + empModel.ID);

                                        //添加当前用户信息
                                        if (ds1.Tables[0].Rows.Count > 0)
                                        {
                                            sol.Update(model, " UserID=" + empModel.ID);
                                        }
                                        else
                                        {
                                            sol.Add(model);
                                        }
                                        //删除超时用户
                                        //2分钟用户失效,删除 --Robert 2015-11-24
                                        sol.Delete(" LastLogTime<date_sub(now(), interval 5 minute)");


                                        //验证完毕,允许登录
                                        context.Response.Write("2");
                                    }
                                    else
                                    {
                                        context.Response.Write("4");//不允许登录
                                    }
                                }
                                else
                                {
                                    context.Response.Write("5");//不允许登录
                                }
                                #endregion
                            }

                            #region 历史2016-04-15前

                            /*
                             * string factory_Id = ds.Tables[0].Rows[0]["Factory_Id"].ToString();
                             *
                             * if (ds.Tables[0].Rows[0]["uid"].ToString() == "admin")
                             * {
                             #region
                             *  string userid = ds.Tables[0].Rows[0]["ID"].ToString();
                             *  FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
                             *      1,
                             *      username,
                             *      DateTime.Now,
                             *      DateTime.Now.AddMinutes(20),
                             *      true,
                             *      userid,
                             *      "/"
                             *      );
                             *  var cookie = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(ticket));
                             *  cookie.HttpOnly = true;
                             *  context.Response.Cookies.Add(cookie);
                             *
                             *  //FormsAuthentication.SetAuthCookie(userid, true);
                             *
                             *  //日志
                             *  BLL.Sys_log log = new BLL.Sys_log();
                             *  Model.Sys_log modellog = new Model.Sys_log();
                             *  modellog.EventType = "系统登录";
                             *
                             *  modellog.EventDate = DateTime.Now;
                             *  modellog.UserID = int.Parse(userid);
                             *  modellog.UserName = ds.Tables[0].Rows[0]["name"].ToString();
                             *  modellog.IPStreet = request.UserHostAddress;
                             *  modellog.Factory_Id = factory_Id;
                             *
                             *  log.Add(modellog);
                             *
                             *  //online
                             *  BLL.Sys_online sol = new BLL.Sys_online();
                             *  Model.Sys_online model = new Model.Sys_online();
                             *
                             *  model.UserName = ds.Tables[0].Rows[0]["name"].ToString();
                             *  model.UserID = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                             *  model.LastLogTime = DateTime.Now;
                             *
                             *  DataSet ds1 = sol.GetList(" UserID=" + ds.Tables[0].Rows[0]["id"].ToString());
                             *
                             *  //添加当前用户信息
                             *  if (ds1.Tables[0].Rows.Count > 0)
                             *  {
                             *      sol.Update(model, " UserID=" + ds.Tables[0].Rows[0]["id"].ToString());
                             *  }
                             *  else
                             *  {
                             *      sol.Add(model);
                             *  }
                             *  //删除超时用户
                             *  //2分钟用户失效,删除 --Robert 2015-11-24
                             *  sol.Delete(" LastLogTime<date_sub(now(), interval 2 minute)");
                             *
                             *
                             *  //验证完毕,允许登录
                             *  context.Response.Write("2");
                             #endregion
                             * }
                             * else
                             * {
                             #region
                             *  DataSet dsfty = fty.GetList("Factory_Id='" + factory_Id + "'");
                             *  string isDelete = dsfty.Tables[0].Rows[0]["IsDelete"].ToString();
                             *  if (int.Parse(isDelete) == 0)
                             *  {
                             *      if (ds.Tables[0].Rows[0]["canlogin"].ToString() == "1")
                             *      {
                             *          string userid = ds.Tables[0].Rows[0]["ID"].ToString();
                             *          FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
                             *              1,
                             *              username,
                             *              DateTime.Now,
                             *              DateTime.Now.AddMinutes(20),
                             *              true,
                             *              userid,
                             *              "/"
                             *              );
                             *          var cookie = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(ticket));
                             *          cookie.HttpOnly = true;
                             *          context.Response.Cookies.Add(cookie);
                             *
                             *          //FormsAuthentication.SetAuthCookie(userid, true);
                             *
                             *          //日志
                             *          BLL.Sys_log log = new BLL.Sys_log();
                             *          Model.Sys_log modellog = new Model.Sys_log();
                             *          modellog.EventType = "系统登录";
                             *
                             *          modellog.EventDate = DateTime.Now;
                             *          modellog.UserID = int.Parse(userid);
                             *          modellog.UserName = ds.Tables[0].Rows[0]["name"].ToString();
                             *          modellog.IPStreet = request.UserHostAddress;
                             *          modellog.Factory_Id = factory_Id;
                             *
                             *          log.Add(modellog);
                             *
                             *          //online
                             *          BLL.Sys_online sol = new BLL.Sys_online();
                             *          Model.Sys_online model = new Model.Sys_online();
                             *
                             *          model.UserName = ds.Tables[0].Rows[0]["name"].ToString();
                             *          model.UserID = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                             *          model.LastLogTime = DateTime.Now;
                             *
                             *          DataSet ds1 = sol.GetList(" UserID=" + ds.Tables[0].Rows[0]["id"].ToString());
                             *
                             *          //添加当前用户信息
                             *          if (ds1.Tables[0].Rows.Count > 0)
                             *          {
                             *              sol.Update(model, " UserID=" + ds.Tables[0].Rows[0]["id"].ToString());
                             *          }
                             *          else
                             *          {
                             *              sol.Add(model);
                             *          }
                             *          //删除超时用户
                             *          //2分钟用户失效,删除 --Robert 2015-11-24
                             *          sol.Delete(" LastLogTime<date_sub(now(), interval 2 minute)");
                             *
                             *
                             *          //验证完毕,允许登录
                             *          context.Response.Write("2");
                             *      }
                             *      else
                             *      {
                             *          context.Response.Write("4");//不允许登录
                             *      }
                             *  }
                             *  else
                             *  {
                             *      context.Response.Write("5");//不允许登录
                             *  }
                             #endregion
                             * }
                             */
                            #endregion
                        }
                        else
                        {
                            context.Response.Write("1");//用户名或密码错误
                        }
                    }
                    else
                    {
                        context.Response.Write("0");//验证码错误
                    }
                }
                else
                {
                    context.Response.Write("999");//系统数据错误
                }
            }

            else if (request["Action"] == "logout")
            {
                #region
                var cookie = context.Request.Cookies[FormsAuthentication.FormsCookieName];

                if (null != cookie)
                {
                    var    ticket     = FormsAuthentication.Decrypt(cookie.Value);
                    string CoockiesID = ticket.UserData;

                    FormsAuthentication.SignOut();
                    context.Response.Write("true");

                    //online
                    BLL.Sys_online sol = new BLL.Sys_online();
                    try
                    {
                        if (!string.IsNullOrEmpty(CoockiesID))
                        {
                            sol.Delete(" UserID=" + int.Parse(CoockiesID));
                        }
                    }
                    catch
                    {
                    }
                }
                #endregion
            }
            else if (request["Action"] == "checkpwd")
            {
                #region
                var    cookie     = context.Request.Cookies[FormsAuthentication.FormsCookieName];
                var    ticket     = FormsAuthentication.Decrypt(cookie.Value);
                string CoockiesID = ticket.UserData;

                BLL.hr_employee emp = new BLL.hr_employee();

                int    emp_id   = int.Parse(CoockiesID);
                string password = FormsAuthentication.HashPasswordForStoringInConfigFile(request["password"], "MD5");

                DataSet ds = emp.GetList(string.Format("ID={0} and pwd='{1}'", emp_id, password));

                if (ds.Tables[0].Rows.Count > 0)
                {
                    context.Response.Write("{sucess:sucess}");
                }
                else
                {
                    context.Response.Write("{sucess:false}");
                }
                #endregion
            }
        }
コード例 #6
0
ファイル: hr_post.ashx.cs プロジェクト: chuing/Push114CRM
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            HttpRequest request = context.Request;

            BLL.hr_post post = new BLL.hr_post();
            Model.hr_post model = new Model.hr_post();

            BLL.hr_employee emp = new BLL.hr_employee();
            Model.hr_employee modelemp = new Model.hr_employee();
            int emp_id = int.Parse(request.Cookies["UserID"].Value.ToString());
            DataSet dsemp = emp.GetList("id=" + emp_id);
            string empname = dsemp.Tables[0].Rows[0]["name"].ToString();
            string uid = dsemp.Tables[0].Rows[0]["uid"].ToString();

            if (request["Action"] == "grid")
            {
                string depid = request["depid"];
                string emps = request["empstatus"];
                int empstuats = 0;
                if (!string.IsNullOrEmpty(emps))
                {
                    empstuats = Common.PageValidate.IsNumber(request["empstatus"]) ? int.Parse(request["empstatus"]) : 0;
                }

                string serchtxt = "";

                switch (empstuats)
                {
                    case 0: serchtxt += "1=1 ";
                        break;
                    case 1: serchtxt += "emp_id=-1 ";
                        break;
                    case 2: serchtxt += "emp_id!=-1 ";
                        break;
                }

                if (!string.IsNullOrEmpty(depid) && depid != "null")
                    serchtxt += " and dep_id=" + int.Parse(depid);

                string serchtype = request["isdel"];
                if (serchtype == "1")
                    serchtxt += " and isDelete=1";
                else
                    serchtxt += " and isDelete=0 ";

                DataSet ds = post.GetList(0, serchtxt, " convert(int,[position_order])");
                string dt = Common.GetGridJSON.DataTableToJSON(ds.Tables[0]);
                context.Response.Write(dt);
            }

            if (request["Action"] == "save")
            {
                //dep
                model.dep_id = int.Parse(request["T_depname_val"]);
                model.depname = Common.PageValidate.InputText(request["T_depname"], 250);
                //name
                model.post_name = Common.PageValidate.InputText(request["T_postname"], 250);
                //position
                model.position_id = int.Parse(request["T_position_val"]);
                model.position_name = Common.PageValidate.InputText(request["T_position"], 250);
                model.position_order = Common.PageValidate.InputText(request["T_position_leavel"], 50);
                //emp
                int empid = Common.PageValidate.IsNumber(request["T_emp_val"]) ? int.Parse(request["T_emp_val"]) : -1;
                model.emp_id = empid;
                model.emp_name = Common.PageValidate.InputText(request["T_emp"], 250);
                //note
                model.note = Common.PageValidate.InputText(request["T_descript"], 4000);

                //更新员工岗位
                modelemp.d_id = model.dep_id;
                modelemp.dname = model.depname;

                modelemp.post = model.post_name;
                modelemp.zhiwuid = model.position_id;
                modelemp.zhiwu = model.position_name;
                modelemp.ID = empid;

                string postid = request["postid"];
                if (!string.IsNullOrEmpty(postid) && postid != "null")
                {
                    model.post_id = int.Parse(postid);
                    DataSet ds = post.GetList(" post_id=" + int.Parse(postid));
                    DataRow dr = null;
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        dr = ds.Tables[0].Rows[0];

                        //判断默认岗位
                        if (model.emp_id == -1)
                        {
                            model.default_post = 0;
                        }
                        else
                        {
                            DataSet ds1 = post.GetList(string.Format("default_post=1 and emp_id={0} and post_id!={1}", model.emp_id, int.Parse(postid)));
                            if (ds1.Tables[0].Rows.Count > 0)
                                model.default_post = 0; //此员工有默认岗位
                            else
                            {
                                model.default_post = 1; //设置此岗位为此员工默认岗位

                                //更新员工岗位
                                modelemp.postid = model.post_id;
                                emp.UpdatePost(modelemp);
                            }
                        }
                    }
                    post.Update(model);

                    //日志
                    C_Sys_log log = new C_Sys_log();

                    int UserID = emp_id;
                    string UserName = empname;
                    string IPStreet = request.UserHostAddress;
                    string EventTitle = model.position_name;
                    string EventType = "岗位修改";
                    int EventID = model.post_id;

                    if (dr["post_name"].ToString() != request["T_postname"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "岗位名称", dr["post_name"].ToString(), request["T_postname"]);
                    }
                    if (dr["position_name"].ToString() != request["T_position"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "岗位级别", dr["position_name"].ToString(), request["T_position"]);
                    }
                    if (dr["emp_name"].ToString() != request["T_emp"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "岗位员工", dr["emp_name"].ToString(), request["T_emp"]);
                    }
                    if (dr["note"].ToString() != request["T_descript"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "描述", dr["note"].ToString(), request["T_descript"]);
                    }
                }
                else
                {
                    model.isDelete = 0;
                    postid= post.Add(model).ToString();

                    //判断默认岗位
                    if (model.emp_id == -1)
                    {
                        model.default_post = 0;
                    }
                    else
                    {
                        DataSet ds1 = post.GetList(string.Format("default_post=1 and emp_id={0} and post_id!={1}", model.emp_id, int.Parse(postid)));
                        if (ds1.Tables[0].Rows.Count > 0)
                            model.default_post = 0; //此员工有默认岗位
                        else
                        {
                            model.default_post = 1; //设置此岗位为此员工默认岗位

                            //更新员工岗位
                            modelemp.postid = int.Parse(postid);
                            emp.UpdatePost(modelemp);
                        }
                    }
                    post.UpdatePostEmp(model);
                }
            }
            //Form JSON
            if (request["Action"] == "form")
            {
                int postid = int.Parse(request["postid"]);
                BLL.hr_post hp = new BLL.hr_post();
                DataSet ds = hp.GetList("post_id=" + postid);

                string dt = Common.DataToJson.DataToJSON(ds);

                context.Response.Write(dt);
            }
            //del
            if (request["Action"] == "AdvanceDelete")
            {
                string postid = request["id"];

                string EventType = "岗位预删除";
                DataSet ds = post.GetList(" post_id=" + int.Parse(postid));

                if (ds.Tables[0].Rows[0]["emp_id"].ToString()!="-1")
                {
                    //含有员工信息不能删除
                    context.Response.Write("false:emp");
                }
                else
                {
                    bool isdel = post.AdvanceDelete(int.Parse(postid), 1, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                    if (isdel)
                    {
                        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                        {
                            int UserID = emp_id;
                            string UserName = empname;
                            string IPStreet = request.UserHostAddress;
                            int EventID = int.Parse(postid);
                            string EventTitle = ds.Tables[0].Rows[i]["post_name"].ToString();
                            string Original_txt = null;
                            string Current_txt = null;
                            C_Sys_log log = new C_Sys_log();
                            log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, null, Original_txt, Current_txt);
                        }
                        context.Response.Write("true");
                    }
                    else
                    {
                        context.Response.Write("false");
                    }
                }
            }

            if (request["Action"] == "regain")
            {
                string idlist = Common.PageValidate.InputText(request["idlist"], 100000);
                string[] arr = idlist.Split(',');

                DataSet ds = post.GetList("post_id in (" + idlist.Trim() + ")");

                for (int i = 0; i < arr.Length; i++)
                {
                    post.AdvanceDelete(int.Parse(arr[i]), 0, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                }

                if (true)
                {
                    //日志
                    string EventType = "恢复删除岗位";

                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        int UserID = emp_id;
                        string UserName = empname;
                        int EventID = idlist[i];
                        string IPStreet = request.UserHostAddress;
                        string EventTitle = ds.Tables[0].Rows[i]["post_name"].ToString();
                        string Original_txt = null;
                        string Current_txt = null;

                        C_Sys_log log = new C_Sys_log();
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, null, Original_txt, Current_txt);
                    }

                    context.Response.Write("true");
                }

            }

            if (request["Action"] == "del")
            {
                bool canDel = false;
                if (dsemp.Tables[0].Rows.Count > 0)
                {
                    if (dsemp.Tables[0].Rows[0]["uid"].ToString() == "admin")
                    {
                        canDel = true;
                    }
                    else
                    {
                        Data.GetAuthorityByUid getauth = new Data.GetAuthorityByUid();
                        string delauth = getauth.GetBtnAuthority(request.Cookies["UserID"].Value, "82");
                        if (delauth == "false")
                            canDel = false;
                        else
                            canDel = true;
                    }
                }
                if (canDel)
                {
                    string idlist = Common.PageValidate.InputText(request["idlist"], 1000000);
                    string[] arr = idlist.Split(',');

                    string EventType = "彻底删除岗位";

                    DataSet ds = post.GetList("post_id in (" + idlist.Trim() + ")");

                    for (int i = 0; i < arr.Length; i++)
                    {
                        post.Delete(int.Parse(arr[i]));
                    }

                    if (true)
                    {
                        //日志
                        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                        {
                            int UserID = emp_id;
                            string UserName = empname;
                            string IPStreet = request.UserHostAddress;
                            int EventID = idlist[i];
                            string EventTitle = ds.Tables[0].Rows[0]["post_name"].ToString();
                            string Original_txt = null;
                            string Current_txt = null;

                            C_Sys_log log = new C_Sys_log();

                            log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, null, Original_txt, Current_txt);
                        }
                        context.Response.Write("true");
                    }
                }
                else
                {
                    context.Response.Write("auth");
                }
            }

            //get post by empid
            if (request["Action"] == "getpostbyempid")
            {
                BLL.hr_post hp = new BLL.hr_post();
                int empid = int.Parse(request["empid"]);
                DataSet ds = hp.GetList(" isDelete=0 and emp_id=" + empid);
                if (ds.Tables[0].Rows.Count > 0)
                {
                    string dt = Common.GetGridJSON.DataTableToJSON(ds.Tables[0]);
                    context.Response.Write(dt);
                }
            }
            //serch
            if (request["Action"] == "serch")
            {
                BLL.hr_post hp = new BLL.hr_post();
                string serchtxt = Common.PageValidate.InputText(request["Serchtext"], 255);
                DataSet ds = hp.GetList(" isDelete=0 and post_name like N'%" + serchtxt + "%'");
                if (ds.Tables[0].Rows.Count > 0)
                {
                    string dt = Common.GetGridJSON.DataTableToJSON(ds.Tables[0]);
                    context.Response.Write(dt);
                }
                else
                {
                    context.Response.Write("post_name like N'%" + serchtxt + "%'");
                }
            }
            //post_emp
            if (request["Action"] == "postemp")
            {
                string json = request["PostData"].ToLower();
                JavaScriptSerializer js = new JavaScriptSerializer();

                PostData[] postdata;
                postdata = js.Deserialize<PostData[]>(json);

                BLL.hr_post hp = new BLL.hr_post();

                string empid = request["empid"];
                int Eid = -1;
                if (!string.IsNullOrEmpty(empid))
                {
                    Eid = Common.PageValidate.IsNumber(empid) ? int.Parse(empid) : -1;
                }

                model.emp_id = Eid;
                modelemp.ID = Eid;
                model.emp_name = Common.PageValidate.InputText(request["emp_name"], 255);

                for (int i = 0; i < postdata.Length; i++)
                {
                    model.post_id = postdata[i].Post_id;
                    model.default_post = postdata[i].Default_post;

                    if (postdata[i].Default_post == 1)
                    {
                        modelemp.d_id = postdata[i].Dep_id;
                        modelemp.dname = postdata[i].Depname;
                        modelemp.zhiwuid = postdata[i].Position_id;
                        modelemp.zhiwu = postdata[i].Position_name;
                        modelemp.postid = postdata[i].Post_id;
                        modelemp.post = postdata[i].Post_name;
                        //context.Response.Write(postdata[i].Depname + "@");
                        emp.UpdatePost(modelemp);
                    }

                    hp.UpdatePostEmp(model);
                }
            }
            //combo
            if (request["Action"] == "combo")
            {
                int postid = int.Parse(request["postid"]);

                DataSet ds = post.GetList(" isDelete=0 and dep_id=" + postid);

                StringBuilder str = new StringBuilder();

                str.Append("[");
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    str.Append("{id:" + ds.Tables[0].Rows[i]["post_id"].ToString() + ",text:'" + ds.Tables[0].Rows[i]["post_name"] + "'},");
                }
                str.Replace(",", "", str.Length - 1, 1);
                str.Append("]");

                context.Response.Write(str);

            }
        }
コード例 #7
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            HttpRequest request = context.Request;

            BLL.hr_post   post  = new BLL.hr_post();
            Model.hr_post model = new Model.hr_post();

            var    cookie     = context.Request.Cookies[FormsAuthentication.FormsCookieName];
            var    ticket     = FormsAuthentication.Decrypt(cookie.Value);
            string CoockiesID = ticket.UserData;

            BLL.hr_employee emp     = new BLL.hr_employee();
            int             emp_id  = int.Parse(CoockiesID);
            DataSet         dsemp   = emp.GetList("id=" + emp_id);
            string          empname = dsemp.Tables[0].Rows[0]["name"].ToString();
            string          uid     = dsemp.Tables[0].Rows[0]["uid"].ToString();

            if (request["Action"] == "grid")
            {
                string depid     = request["depid"];
                string emps      = request["empstatus"];
                int    empstuats = 0;
                if (!string.IsNullOrEmpty(emps))
                {
                    empstuats = Common.PageValidate.IsNumber(request["empstatus"]) ? int.Parse(request["empstatus"]) : 0;
                }

                string serchtxt = "";

                switch (empstuats)
                {
                case 0: serchtxt += "1=1 ";
                    break;

                case 1: serchtxt += "emp_id=-1 ";
                    break;

                case 2: serchtxt += "emp_id!=-1 ";
                    break;
                }

                if (!string.IsNullOrEmpty(depid) && depid != "null")
                {
                    serchtxt += " and dep_id=" + int.Parse(depid);
                }

                DataSet ds = post.GetList(0, serchtxt, " position_order");
                string  dt = Common.GetGridJSON.DataTableToJSON(ds.Tables[0]);
                context.Response.Write(dt);
            }


            if (request["Action"] == "save")
            {
                //dep
                model.dep_id  = int.Parse(request["T_depname_val"]);
                model.depname = PageValidate.InputText(request["T_depname"], 250);
                //name
                model.post_name = PageValidate.InputText(request["T_postname"], 250);
                //position
                model.position_id    = int.Parse(request["T_position_val"]);
                model.position_name  = PageValidate.InputText(request["T_position"], 250);
                model.position_order = int.Parse(request["T_position_leavel"]);
                //emp
                int empid = Common.PageValidate.IsNumber(request["T_emp_val"]) ? int.Parse(request["T_emp_val"]) : -1;
                model.emp_id   = empid;
                model.emp_name = PageValidate.InputText(request["T_emp"], 250);
                //note
                model.note = PageValidate.InputText(request["T_descript"], 4000);

                Model.hr_employee modelemp = new Model.hr_employee();
                //更新员工岗位
                modelemp.d_id  = model.dep_id;
                modelemp.dname = model.depname;

                modelemp.post    = model.post_name;
                modelemp.zhiwuid = model.position_id;
                modelemp.zhiwu   = model.position_name;
                modelemp.ID      = empid;

                string postid = PageValidate.InputText(request["postid"], 50);
                if (!string.IsNullOrEmpty(postid) && postid != "null")
                {
                    model.post_id = int.Parse(postid);
                    DataSet ds = post.GetList(" post_id=" + int.Parse(postid));
                    DataRow dr = null;
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        dr = ds.Tables[0].Rows[0];

                        //判断默认岗位
                        if (model.emp_id == -1)
                        {
                            model.default_post = 0;
                        }
                        else
                        {
                            DataSet ds1 = post.GetList(string.Format("default_post=1 and emp_id={0} and post_id!={1}", model.emp_id, int.Parse(postid)));
                            if (ds1.Tables[0].Rows.Count > 0)
                            {
                                model.default_post = 0; //此员工有默认岗位
                            }
                            else
                            {
                                model.default_post = 1; //设置此岗位为此员工默认岗位

                                //更新员工岗位
                                modelemp.postid = model.post_id;
                                emp.UpdatePost(modelemp);
                            }
                        }
                    }
                    post.Update(model);

                    //日志
                    C_Sys_log log = new C_Sys_log();

                    int    UserID     = emp_id;
                    string UserName   = empname;
                    string IPStreet   = request.UserHostAddress;
                    string EventTitle = model.position_name;
                    string EventType  = "岗位修改";
                    int    EventID    = model.post_id;

                    if (dr["post_name"].ToString() != request["T_postname"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "岗位名称", dr["post_name"].ToString(), request["T_postname"]);
                    }
                    if (dr["position_name"].ToString() != request["T_position"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "岗位级别", dr["position_name"].ToString(), request["T_position"]);
                    }
                    if (dr["emp_name"].ToString() != request["T_emp"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "岗位员工", dr["emp_name"].ToString(), request["T_emp"]);
                    }
                    if (dr["note"].ToString() != request["T_descript"])
                    {
                        log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "描述", dr["note"].ToString(), request["T_descript"]);
                    }
                }
                else
                {
                    model.isDelete = 0;
                    postid         = post.Add(model).ToString();

                    //判断默认岗位
                    if (model.emp_id == -1)
                    {
                        model.default_post = 0;
                    }
                    else
                    {
                        DataSet ds1 = post.GetList(string.Format("default_post=1 and emp_id={0} and post_id!={1}", model.emp_id, int.Parse(postid)));
                        if (ds1.Tables[0].Rows.Count > 0)
                        {
                            model.default_post = 0; //此员工有默认岗位
                        }
                        else
                        {
                            model.default_post = 1; //设置此岗位为此员工默认岗位

                            //更新员工岗位
                            modelemp.postid = int.Parse(postid);
                            emp.UpdatePost(modelemp);
                        }
                    }
                    post.UpdatePostEmp(model);
                }
            }
            //Form JSON
            if (request["Action"] == "form")
            {
                int         postid = int.Parse(request["postid"]);
                BLL.hr_post hp     = new BLL.hr_post();
                DataSet     ds     = hp.GetList("post_id=" + postid);

                string dt = Common.DataToJson.DataToJSON(ds);

                context.Response.Write(dt);
            }
            //del
            if (request["Action"] == "del")
            {
                string postid = request["id"];

                string  EventType = "岗位删除";
                DataSet ds        = post.GetList(" post_id=" + int.Parse(postid));

                if (ds.Tables[0].Rows[0]["emp_id"].ToString() != "-1")
                {
                    //含有员工信息不能删除
                    context.Response.Write("false:emp");
                }
                else
                {
                    bool isdel = post.Delete(int.Parse(postid));
                    if (isdel)
                    {
                        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                        {
                            int       UserID       = emp_id;
                            string    UserName     = empname;
                            string    IPStreet     = request.UserHostAddress;
                            int       EventID      = int.Parse(postid);
                            string    EventTitle   = ds.Tables[0].Rows[i]["post_name"].ToString();
                            string    Original_txt = null;
                            string    Current_txt  = null;
                            C_Sys_log log          = new C_Sys_log();
                            log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, null, Original_txt, Current_txt);
                        }
                        context.Response.Write("true");
                    }
                    else
                    {
                        context.Response.Write("false");
                    }
                }
            }

            //get post by empid
            if (request["Action"] == "getpostbyempid")
            {
                BLL.hr_post hp    = new BLL.hr_post();
                int         empid = int.Parse(request["empid"]);
                DataSet     ds    = hp.GetList(" emp_id=" + empid);
                if (ds.Tables[0].Rows.Count > 0)
                {
                    string dt = Common.GetGridJSON.DataTableToJSON(ds.Tables[0]);
                    context.Response.Write(dt);
                }
            }
            //serch
            if (request["Action"] == "serch")
            {
                BLL.hr_post hp       = new BLL.hr_post();
                string      serchtxt = PageValidate.InputText(request["Serchtext"], 255);
                DataSet     ds       = hp.GetList(" isDelete=0 and post_name like N'%" + serchtxt + "%'");
                if (ds.Tables[0].Rows.Count > 0)
                {
                    string dt = Common.GetGridJSON.DataTableToJSON(ds.Tables[0]);
                    context.Response.Write(dt);
                }
                else
                {
                    context.Response.Write("post_name like N'%" + serchtxt + "%'");
                }
            }
            //post_emp
            if (request["Action"] == "postemp")
            {
                string json             = request["PostData"].ToLower();
                JavaScriptSerializer js = new JavaScriptSerializer();

                PostData[] postdata;
                postdata = js.Deserialize <PostData[]>(json);

                BLL.hr_post hp = new BLL.hr_post();


                string empid = request["empid"];
                int    Eid   = -1;
                if (!string.IsNullOrEmpty(empid))
                {
                    Eid = Common.PageValidate.IsNumber(empid) ? int.Parse(empid) : -1;
                }
                Model.hr_employee modelemp = new Model.hr_employee();
                model.emp_id   = Eid;
                modelemp.ID    = Eid;
                model.emp_name = PageValidate.InputText(request["emp_name"], 255);

                for (int i = 0; i < postdata.Length; i++)
                {
                    model.post_id      = postdata[i].Post_id;
                    model.default_post = postdata[i].Default_post;

                    if (postdata[i].Default_post == 1)
                    {
                        modelemp.d_id    = postdata[i].Dep_id;
                        modelemp.dname   = postdata[i].Depname;
                        modelemp.zhiwuid = postdata[i].Position_id;
                        modelemp.zhiwu   = postdata[i].Position_name;
                        modelemp.postid  = postdata[i].Post_id;
                        modelemp.post    = postdata[i].Post_name;
                        //context.Response.Write(postdata[i].Depname + "@");
                        emp.UpdatePost(modelemp);
                    }

                    hp.UpdatePostEmp(model);
                }
            }
            //combo
            if (request["Action"] == "combo")
            {
                int postid = int.Parse(request["postid"]);

                DataSet ds = post.GetList(" dep_id=" + postid);

                StringBuilder str = new StringBuilder();

                str.Append("[");
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    str.Append("{id:" + ds.Tables[0].Rows[i]["post_id"].ToString() + ",text:'" + ds.Tables[0].Rows[i]["post_name"] + "'},");
                }
                str.Replace(",", "", str.Length - 1, 1);
                str.Append("]");

                context.Response.Write(str);
            }
        }
コード例 #8
0
 /// <summary>
 /// 个人信息修改
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool PersonalUpdate(Model.hr_employee model)
 {
     return(dal.PersonalUpdate(model));
 }