using RMYY_CallCenter_Api.Controllers;
using RMYY_CallCenter_Api.DB;
using RMYY_CallCenter_Api.Models;
using RMYY_CallCenter_Api.Models.Enum;
using RMYY_CallCenter_Api.Models.Input;
using RMYY_CallCenter_Api.Utility;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Web;
using System.Web.Mvc;

namespace RMYY_CallCenter_Api.Controllers
{
 
 
    public class GroupClassController : BaseController
    {

        

        public ActionResult GetUserlistByDeptId()
        {
            DataTable dt = new DataTable();
            string sql = " select * from T_Sys_UserAccount where   F_DeleteFlag=0  and F_DeptId='"+User.F_DeptId+"'";

            dt=   DbHelperSQL.Query(sql).Tables[0];
            return Success("获取当前部门的所有人",dt);

           
        }

        public ActionResult GetUserlistByDeptIdNew (int deptid=0)
        {
            int dept = User.F_DeptId;
            DataTable dt = new DataTable();
            string sql = " select * from T_Sys_UserAccount where   F_DeleteFlag=0  and F_DeptId='" + deptid + "'";
            //string sql = " select * from T_Sys_UserAccount where F_DeptId in (  select F_DeptId from T_Sys_Department  where  F_DeptId = '"+dept+"'  )";

            dt = DbHelperSQL.Query(sql).Tables[0];
            return Success("获取当前部门的所有人", dt);


        }

        public ActionResult AddGroupClass(string usercode,string date, string id,string classcode,int isAutomatic=1,int deptid=0)
        {
            if (deptid == 0)
            {
                deptid = User.F_DeptId;
            }

            List<string> userlist = new List<string>();
            if (usercode.Contains(","))
            {
                userlist = usercode.Split(',').ToList();
            }
            else
            { userlist.Add(usercode); }

            long pkid = 0;
            if (!string.IsNullOrEmpty(id))
            {
                pkid = long.Parse(id);
            }

            Model.T_Sys_GroupClass dModel = new Model.T_Sys_GroupClass();
            //添加值班信息
            if (pkid == 0)
            {

                foreach (string strusercode   in userlist)
                {
                    var list = new Bll.T_Sys_GroupClass().GetModelList(" F_ClassCode='" + classcode + "' and F_Date='" + date + "' and F_DeptId='" + deptid + "' and F_IsDelete=0  and F_UserCode='" + strusercode + "'");
                    if (list.Count > 0)
                    {
                        continue;
                    }
                    else
                    {
                        //添加值班信息
                        dModel.F_UserCode = strusercode;
                        dModel.F_Date = Convert.ToDateTime(date);
                        dModel.F_DeptId = deptid;
                        dModel.F_State = 0;
                        dModel.F_IsDelete = 0;
                        dModel.F_ClassCode = classcode;
                        dModel.F_CreateUser = User.F_UserCode;
                        dModel.F_CreateTime = DateTime.Now;
                        dModel.F_IsAutomatic = isAutomatic;
                        long n = new Bll.T_Sys_GroupClass().Add(dModel);
                        
                    }
                   
                }
                return Success("添加成功");

            }
            else
            {
                dModel = new Bll.T_Sys_GroupClass().GetModel(pkid);
                if (dModel != null)
                {
                    var list = new Bll.T_Sys_GroupClass().GetModelList(" F_ClassCode='" + classcode + "' and F_Date='" + date + "' and F_DeptId='" + deptid + "' and F_IsDelete=0   and F_UserCode='" + usercode + "'");
                    if (list.Count > 0)
                    {
                        return Error("已经存在此值班信息");
                    }
                    else
                    {
                        dModel.F_UserCode = usercode;
                       
                        if (new Bll.T_Sys_GroupClass().Update(dModel))
                            return Success("修改成功");
                        else
                            return Error("修改失败");
                    }
                }
                else
                {
                    return Error("修改失败");
                }
            }
        }


        public ActionResult GetList()
        {
            DataTable dt = new DataTable();

            string  starttime = HttpUtility.UrlDecode(RequestString.GetQueryString("stime"));
            string  endtime = HttpUtility.UrlDecode(RequestString.GetQueryString("etime"));

            string where = " where F_IsDelete=0 and F_DeptId in(select F_DeptId from[dbo].[GetDeptid] ('" + User.F_DeptId + "'))";

            if (!string.IsNullOrEmpty(starttime) && !string.IsNullOrEmpty(endtime))
            {

                where += " and F_Date >='" + Convert.ToDateTime(starttime) + "' and F_Date<= '" + Convert.ToDateTime(endtime) + "'";
            }


      
            string strsql = " select *,dbo.GetUserName(F_UserCode) as UserName,[dbo].[GetClassNameByClassCode](F_ClassCode) ClassName,CONVERT(varchar(10),F_Date) F_DateStr from T_Sys_GroupClass"+ where;

            dt = DbHelperSQL.Query(strsql).Tables[0]; 

            var obj = new
            {
                state = "success",
                message = "成功",
                rows = dt 
               
            };
            return Content(obj.ToJson());

        }


        public ActionResult DelGroupClass(long id)
        {
            var model = new Bll.T_Sys_GroupClass().GetModel(id);
            model.F_IsDelete = 1;
            model.F_DeleteUser = User.F_UserCode;
            model.F_DeleteTime = DateTime.Now;
            if (new Bll.T_Sys_GroupClass().Update(model))
            {
                return Success("删除成功");
            }
            return Error("删除失败");
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="stime"></param>
        /// <param name="endtime"></param>
        /// <param name="classcode">班别</param>
        /// <param name="type">排班方式 0 是固定 1 是轮值</param>
        /// <param name="usercode">值班人员</param>
        /// <param name="skipholidays">跳过节假日 0 不跳过 1 是跳过</param>
        /// <param name="rotationdays">轮值天数</param>
        /// <returns></returns>
        public ActionResult AutoAddGroupClass(string stime,string endtime,string classcode,string  usercode, int skipholidays=0, int rotationdays=0, int type=0, int isAutomatic=1,int deptid=0)
        {
            //方式选固定，就是每天都是这几个人
            //方式选轮值，轮值1天就是 A，B，C，轮值2天就是A，A，B，B，C，C 
            if (deptid==0) {
                deptid = User.F_DeptId;
            }
          
            DateTime starttime = Convert.ToDateTime(stime);

            DateTime  lasttime = Convert.ToDateTime(endtime);

            var groupclasslist = new Bll.T_Sys_GroupClass().GetModelList("F_ClassCode='" + classcode + "' and F_Date>='" + stime + "' and   F_Date<='" + lasttime + "' and F_DeptId='" + deptid + "' and F_IsDelete=0 ");

            var T_Sys_WorkOFFDayslist = new Bll.T_Sys_WorkOffDays().GetModelList("F_OffDate>='" + starttime.ToString("yyyy-MM-dd") + "' and F_OffDate<='" + lasttime.ToString("yyyy-MM-dd") + "'and F_OffState=0");
            List<string> userlist = new List<string>();
            if (usercode.Contains(","))
            {
                userlist = usercode.Split(',').ToList();
            }
            else
            { userlist.Add(usercode); }
            //固定
            if (type == 0)
            {
                //不跳过节假日
                if (skipholidays == 0)
                {
                    for (DateTime time= starttime; time <=lasttime; time=time.AddDays(1) )
                    {
                        

                        foreach (string strusercode in userlist)
                        {
                            Model.T_Sys_GroupClass dModel = new Model.T_Sys_GroupClass();
                            var list= groupclasslist.Where(x => x.F_UserCode == strusercode && x.F_Date == time).ToList();

                            //var list = new Bll.T_Sys_GroupClass().GetModelList(" F_ClassCode='" + classcode + "' and F_Date='" + time + "' and F_DeptId='" + deptid + "' and F_IsDelete=0  and F_UserCode='" + strusercode + "'");
                            if (list!=null&& list.Count() > 0)
                            {
                                continue;
                            }
                            else
                            {
                                //添加值班信息                               
                                    dModel.F_UserCode = strusercode;
                                    dModel.F_Date = time;
                                    dModel.F_DeptId = deptid;
                                    dModel.F_State = 0;
                                    dModel.F_IsDelete = 0;
                                    dModel.F_ClassCode = classcode;
                                    dModel.F_IsAutomatic = isAutomatic;
                                    dModel.F_CreateUser = User.F_UserCode;
                                    dModel.F_CreateTime = DateTime.Now;
                                    long n = new Bll.T_Sys_GroupClass().Add(dModel);
                            }
                        }

                        
                    }
                    return Success("值班信息添加成功");






                }
                //跳过节假日
                else
                {
                    for (DateTime time = starttime; time <= lasttime; time = time.AddDays(1))
                    {
                        var n = T_Sys_WorkOFFDayslist.Where(x => x.F_OffDate == time).ToList();
                        //string sql = "select count(1) from T_Sys_WorkOFFDays  where F_OffDate='"+time+"' and F_OffState=0";
                        //int n = Convert.ToInt32( DbHelperSQL.GetSingle(sql).ToString());
                        if (n!=null&& n.Count()  > 0)
                        {
                            continue;
                        }

                      //  List<string> userlist = usercode.Split(',').ToList();

                        foreach (string strusercode in userlist)
                        {
                            Model.T_Sys_GroupClass dModel = new Model.T_Sys_GroupClass();
                            //var list = new Bll.T_Sys_GroupClass().GetModelList(" F_ClassCode='" + classcode + "' and F_Date='" + time + "' and F_DeptId='" + deptid + "' and F_IsDelete=0  and F_UserCode='" + usercode + "'");
                            //if (list.Count > 0)
                            var list = groupclasslist.Where(x => x.F_UserCode == strusercode && x.F_Date == time).ToList();

                         
                            if (list != null && list.Count() > 0)
                            {
                                continue;
                            }
                            else
                            {
                                //添加值班信息
                                dModel.F_UserCode = strusercode;
                                dModel.F_Date = time;
                                dModel.F_DeptId = deptid;
                                dModel.F_State = 0;
                                dModel.F_IsDelete = 0;
                                dModel.F_ClassCode = classcode;
                                dModel.F_IsAutomatic = isAutomatic;
                                dModel.F_CreateUser = User.F_UserCode;
                                dModel.F_CreateTime = DateTime.Now;
                                long n1 = new Bll.T_Sys_GroupClass().Add(dModel);

                            }
                        }


                    }
                    return Success("值班信息添加成功");

                }

            }
            //轮值
            else
            {
                //不跳过节假日
                if (skipholidays == 0)
                {
                    int useri = 0;
                    for (DateTime time = starttime; time <= lasttime; time = time.AddDays(rotationdays))
                    {
                      string[] struserlist = usercode.Split(',');
                        if (useri >= struserlist.Count())
                        {
                            useri = useri % struserlist.Count();
                        }
                        for (int i = 0; i < rotationdays; i++)
                        {
                            DateTime newdt = time.AddDays(i);

                            Model.T_Sys_GroupClass dModel = new Model.T_Sys_GroupClass();
                            //var list = new Bll.T_Sys_GroupClass().GetModelList(" F_ClassCode='" + classcode + "' and F_Date='" + newdt + "' and F_DeptId='" + deptid + "' and F_IsDelete=0  and F_UserCode='" + struserlist[useri] + "'");
                            //if (list.Count > 0)
                            var list = groupclasslist.Where(x => x.F_UserCode == struserlist[useri] && x.F_Date == newdt).ToList();


                            if (list != null && list.Count() > 0)
                            {
                                continue;
                            }
                            else
                            {
                                if (newdt <= lasttime) { 
                                //添加值班信息
                                dModel.F_UserCode = struserlist[useri];
                                dModel.F_Date = newdt;
                                dModel.F_DeptId = deptid;
                                dModel.F_State = 0;
                                dModel.F_IsDelete = 0;
                                dModel.F_ClassCode = classcode;
                                dModel.F_IsAutomatic = isAutomatic;
                                dModel.F_CreateUser = User.F_UserCode;
                                dModel.F_CreateTime = DateTime.Now;
                                long n = new Bll.T_Sys_GroupClass().Add(dModel);
                                }

                            }
                        }
                           useri = useri + 1;
                          
                       }


                     
                    return Success("值班信息添加成功");

                }
                //跳过节假日
                else
                {
                    //var T_Sys_WorkOFFDays = new Bll.T_Sys_WorkOffDays().GetModelList("F_OffDate>='" + starttime.ToString("yyyy-MM-dd") + "' and F_OffDate<='" + lasttime.ToString("yyyy-MM-dd") + "'and F_OffState=0");

                  //  var n = T_Sys_WorkOFFDayslist.Where(x => x.F_OffDate == time).ToList();
                    ////string sql = "select count(1) from T_Sys_WorkOFFDays  where F_OffDate='"+time+"' and F_OffState=0";
                    ////int n = Convert.ToInt32( DbHelperSQL.GetSingle(sql).ToString());
                    //if (n != null && n.Count() > 0)
                        int useri = 0;
                    for (DateTime time = starttime; time <= lasttime; time = time.AddDays(rotationdays))
                    {
                       
                        string[] struserlist = usercode.Split(',');
                        if (useri >= struserlist.Count())
                        {
                            useri = useri % struserlist.Count();
                        }
                        int days = rotationdays;
                        int workoffday = 0;
                        for (int i = 0; i < days; i++)
                        {
                            DateTime newdt = time.AddDays(i);
                            if (T_Sys_WorkOFFDayslist != null && T_Sys_WorkOFFDayslist.Count() > 0)
                            {
                                if (T_Sys_WorkOFFDayslist.Where(x => x.F_OffDate.Value.ToString("yyyy-MM-dd") == newdt.ToString("yyyy-MM-dd")).Count() > 0)
                                {
                                    days += 1;
                                   
                                    workoffday += 1;
                                    continue;
                                }
                            }
                            Model.T_Sys_GroupClass dModel = new Model.T_Sys_GroupClass();
                            //var list = new Bll.T_Sys_GroupClass().GetModelList(" F_ClassCode='" + classcode + "' and F_Date='" + newdt + "' and F_DeptId='" + deptid + "' and F_IsDelete=0  and F_UserCode='" + struserlist[useri] + "'");
                            //if (list.Count > 0)
                            var list = groupclasslist.Where(x => x.F_UserCode == struserlist[useri] && x.F_Date == newdt).ToList();

                            if (list != null && list.Count() > 0)
                            {
                                continue;
                            }
                            else
                            {
                                if(newdt<=lasttime)
                                {
                                //添加值班信息
                                dModel.F_UserCode = struserlist[useri];
                                dModel.F_Date = newdt;
                                dModel.F_DeptId = deptid;
                                dModel.F_State = 0;
                                dModel.F_IsDelete = 0;
                                dModel.F_ClassCode = classcode;
                                    dModel.F_IsAutomatic = isAutomatic;
                                    dModel.F_CreateUser = User.F_UserCode;
                                dModel.F_CreateTime = DateTime.Now;
                                long n = new Bll.T_Sys_GroupClass().Add(dModel);
                                }

                            }
                        }
                        useri = useri + 1;
                        time = time.AddDays(workoffday);
                    }
                    return Success("值班信息添加成功");

                }

            }



      
        }

        //根据部门id获取当前时间值班的人员
        public ActionResult GetDutyGroupUserByDeptId(int deptid = 0)
        {

            if (deptid > 0)
            {
                string sql = "    select F_UserCode,dbo.GetUserName(F_UserCode) username,F_Date from  T_Sys_GroupClass where F_IsDelete=0   and F_Date = CONVERT(varchar, GETDATE(), 120)  and F_ClassCode in ( select F_Id from t_sys_class where F_IsDelete = 0 and CONVERT(varchar, GETDATE(),108) between F_InTime and F_OutTime and F_DeptId ='"+deptid+"' )  ";

                 var dt=   DbHelperSQL.Query(sql).Tables[0];
                return Success("根据部门获取值班人员数据成功", dt);
            }

            return Error("deptid需要大于0");
        }




        // GET: GroupClass

        ///// <summary>
        ///// 获取用户班别列表
        ///// </summary>
        ///// <returns></returns>

        //public ActionResult GetList(int isdc = 0)
        //{
        //    DataTable dt = new DataTable();
        //    string sql = " and F_IsDelete=0 ";
        //    string groupcode = HttpUtility.UrlDecode(RequestString.GetQueryString("groupcode"));
        //    string classcode = HttpUtility.UrlDecode(RequestString.GetQueryString("classcode"));
        //    string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
        //    string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));

        //    string strpageindex = RequestString.GetQueryString("page");
        //    int pageindex = 1;
        //    string strpagesize = RequestString.GetQueryString("pagesize");
        //    int pagesize = 10;


        //    if (groupcode.Trim() != "" && groupcode != "undefined")
        //    {
        //        sql += " and F_GroupCode = '" + groupcode.Trim() + "' ";
        //    }
        //    if (classcode.Trim() != "" && classcode != "undefined")
        //    {
        //        sql += " and F_ClassCode = '" + classcode.Trim() + "' ";
        //    }
        //    if (strstarttime.Trim() != "" && strstarttime != "undefined")
        //    {
        //        sql += " and datediff(day,F_Date,'" + strstarttime + "')<=0 ";
        //    }
        //    if (strendtime.Trim() != "" && strendtime != "undefined")
        //    {
        //        sql += " and datediff(day,F_Date,'" + strendtime + "')>=0   ";
        //    }

        //    if (strpageindex.Trim() != "")
        //    {
        //        pageindex = Convert.ToInt32(strpageindex);
        //    }

        //    if (strpagesize.Trim() != "")
        //    {
        //        pagesize = Convert.ToInt32(strpagesize);
        //    }

        //    string cols = "*,dbo.GetUserName(F_GroupCode) as UserName";

        //    if (isdc > 0)
        //    {
        //        var dtdc = DbHelperSQL.Query(" select " + cols + " from T_Sys_GroupClass where 1=1 " + sql).Tables[0];
        //        var msg = new NPOIHelper().ExportToExcel("班组班别列表", dtdc);
        //        if (msg == "")
        //        {
        //            return Success("导出成功");
        //        }
        //        else
        //        {
        //            return Error("导出失败");
        //        }
        //    }

        //    int recordCount = 0;
        //    dt = Bll.PagerBll.GetListPager(
        //        "T_Sys_GroupClass",
        //        "F_Id",
        //        cols,
        //        sql,
        //        "ORDER BY F_Date DESC",
        //        pagesize,
        //        pageindex,
        //        true,
        //        out recordCount);

        //    var obj = new
        //    {
        //        state = "success",
        //        message = "成功",
        //        rows = dt,
        //        total = recordCount
        //    };
        //    return Content(obj.ToJson());

        //}

        ///// <summary>
        ///// 获取用户班别列表
        ///// </summary>
        ///// <returns></returns>

        //public ActionResult GetRLList()
        //{
        //    string sql = " F_IsDelete=0 ";
        //    string groupcode = HttpUtility.UrlDecode(RequestString.GetQueryString("groupcode"));
        //    string classcode = HttpUtility.UrlDecode(RequestString.GetQueryString("classcode"));
        //    string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
        //    string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));

        //    //int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
        //    //Model.T_Sys_UserAccount userModel = new Bll.T_Sys_UserAccount().GetModel(userId);

        //    //if (userModel.F_RoleCode == "ZXHWY" || userModel.F_RoleCode == "ZXBZ")
        //    //{
        //    //    sql += " and F_GroupCode = '" + userModel.F_GroupCode + "' ";
        //    //}

        //    if (groupcode.Trim() != "" && groupcode != "undefined")
        //    {
        //        sql += " and F_GroupCode = '" + groupcode.Trim() + "' ";
        //    }
        //    if (classcode.Trim() != "" && classcode != "undefined")
        //    {
        //        sql += " and F_ClassCode = '" + classcode.Trim() + "' ";
        //    }
        //    if (strstarttime.Trim() != "" && strstarttime != "undefined")
        //    {
        //        sql += " and datediff(day,F_Date,'" + strstarttime + "')<=0 ";
        //    }
        //    if (strendtime.Trim() != "" && strendtime != "undefined")
        //    {
        //        sql += " and datediff(day,F_Date,'" + strendtime + "')>=0   ";
        //    }

        //    var list = new Bll.T_Sys_GroupClass().GetModelList(sql);

        //    var obj = list.Select(p => {
        //        var cls = new Bll.T_Sys_Class().GetModelList(" F_Code='" + p.F_ClassCode + "' ").FirstOrDefault();
        //        var group = new Bll.T_Sys_Group().GetModelList(" F_GroupCode='" + p.F_GroupCode + "' ").FirstOrDefault();
        //        string[] ins = cls.F_InTime.Split(':');
        //        string[] outs = cls.F_OutTime.Split(':');
        //        bool bl = Int32.Parse(ins[0]) > Int32.Parse(outs[0]);
        //        var edate = bl ? p.F_Date.Value.AddDays(1) : p.F_Date.Value;
        //        return new
        //        {
        //            id = p.F_Id,
        //            groupcode= p.F_GroupCode,
        //            classcode= p.F_ClassCode,
        //            title = group.F_GroupName+" "+cls.F_Name + "[" + cls.F_InTime + "-" + cls.F_OutTime + "]",
        //            start = p.F_Date.Value.ToString("yyyy-MM-dd") + " " + cls.F_InTime,
        //            end = edate.ToString("yyyy-MM-dd") + " " + cls.F_OutTime
        //        };
        //    });
        //    return Content(obj.ToJson());

        //}

        ///// <summary>
        ///// 添加用户班别
        ///// </summary>
        ///// <param name="input"></param>
        ///// <returns></returns>
        //[HttpPost]

        //public ActionResult AddGroupClass()
        //{
        //    int userId =   0;

        //    Model.T_Sys_UserAccount userModel = new Bll.T_Sys_UserAccount().GetModel(userId);
        //    string strid = RequestString.GetFormString("id"); ;
        //    string date = RequestString.GetFormString("date");
        //    string groupcode = RequestString.GetFormString("groupcode");
        //    string classcode = RequestString.GetFormString("classcode");
        //    long id = 0;
        //    if (!string.IsNullOrEmpty(strid))
        //    {
        //        id = long.Parse(strid);
        //    }

        //    Model.T_Sys_GroupClass dModel = new Model.T_Sys_GroupClass();
        //    if (id == 0)
        //    {
        //        var list = new Bll.T_Sys_GroupClass().GetModelList(" F_ClassCode='" + classcode + "' and F_Date='" + date + "' and F_GroupCode='" + groupcode + "' and F_IsDelete=0 ");
        //        if (list.Count > 0)
        //        {
        //            return Error("已经存在此班别");
        //        }
        //        else
        //        {
        //            dModel.F_ClassCode = classcode;
        //            dModel.F_Date = Convert.ToDateTime(date);
        //            dModel.F_GroupCode = groupcode;
        //            dModel.F_State = 0;
        //            dModel.F_IsDelete = 0;
        //            dModel.F_CreateUser = userModel.F_UserCode;
        //            dModel.F_CreateTime = DateTime.Now;
        //            long n = new Bll.T_Sys_GroupClass().Add(dModel);
        //            if (n > 0)
        //                return Success("添加成功", n);
        //            else
        //                return Error("添加失败");
        //        }
        //    }
        //    else
        //    {
        //        dModel = new Bll.T_Sys_GroupClass().GetModel(id);
        //        if (dModel != null)
        //        {
        //            var list = new Bll.T_Sys_GroupClass().GetModelList(" F_ClassCode='" + classcode + "' and F_Date='" + date + "' and F_GroupCode='" + groupcode + "' and F_IsDelete=0 and F_Id!='" + id + "' ");
        //            if (list.Count > 0)
        //            {
        //                return Error("已经存在此班别");
        //            }
        //            else
        //            {
        //                dModel.F_ClassCode = classcode;
        //                dModel.F_Date = Convert.ToDateTime(date);
        //                dModel.F_GroupCode = groupcode;
        //                if (new Bll.T_Sys_GroupClass().Update(dModel))
        //                    return Success("修改成功");
        //                else
        //                    return Error("修改失败");
        //            }
        //        }
        //        else
        //        {
        //            return Error("修改失败");
        //        }
        //    }
        //}

        ///// <summary>
        ///// 删除班别
        ///// </summary>
        ///// <param name="ids"></param>
        ///// <returns></returns>

        //public ActionResult DelGroupClass(long id)
        //{
        //    int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
        //    Model.T_Sys_UserAccount userModel = new Bll.T_Sys_UserAccount().GetModel(userId);

        //    var model = new Bll.T_Sys_GroupClass().GetModel(id);
        //    model.F_IsDelete = 1;
        //    model.F_DeleteUser = userModel.F_GroupCode;
        //    model.F_DeleteTime = DateTime.Now;
        //    if (new Bll.T_Sys_GroupClass().Update(model))
        //    {
        //        return Success("删除成功");
        //    }
        //    return Error("删除失败");
        //}

        ///// <summary>
        ///// 获取未分组坐席
        ///// </summary>
        ///// <returns></returns>

        //public ActionResult GetNoGroupSeatList()
        //{
        //    var dt = new Bll.T_Sys_UserAccount().GetList(" f_seatflag=1 and isnull(F_GroupCode,'')='' ").Tables[0];
        //    return Success("成功", dt);
        //}

        ///// <summary>
        ///// 坐席分组
        ///// </summary>
        ///// <returns></returns>

        //public ActionResult GroupSeat()
        //{
        //    string groupcode = RequestString.GetFormString("groupcode");
        //    string usercode = RequestString.GetFormString("usercode");

        //    var ur = new Bll.T_Sys_UserAccount().GetModelList(" F_UserCode='" + usercode + "' ").FirstOrDefault();
        //    if (ur != null)
        //    {
        //        ur.F_GroupCode = groupcode;
        //        if (new Bll.T_Sys_UserAccount().Update(ur))
        //        {
        //            return Success("成功");
        //        }
        //        else
        //        {
        //            return Error("分组失败");
        //        }
        //    }
        //    else
        //    {
        //        return Error("分组失败");
        //    }
        //}
    }
}