Exemple #1
0
        public EmployeeResult Find(long id)
        {
            Data.Entity.Employee entity = EmployeeDao.Find(id);
            EmployeeResult       result = EmployeeResultConverter.Convert(entity);

            return(result);
        }
Exemple #2
0
        /// <summary>
        /// 人员面试后记录面试结果和增加面试轮数
        /// </summary>
        /// <param name="eventParams"></param>
        /// <returns></returns>
        public bool EmployeePlanFinish(WorkFlowCustomEventParams eventParams)
        {
            var repository    = Abp.AbpBootstrapper.Create <Abp.Modules.AbpModule>().IocManager.IocContainer.Resolve <IRepository <EmployeePlan, Guid> >();
            var logrepository = Abp.AbpBootstrapper.Create <Abp.Modules.AbpModule>().IocManager.IocContainer.Resolve <IRepository <EmployeeResult, Guid> >();
            var plan          = repository.Get(Guid.Parse(eventParams.InstanceID));

            var log = new EmployeeResult()
            {
                AdminUserId        = plan.AdminUserId,
                AdminVerifyDiscuss = plan.AdminVerifyDiscuss,
                ApplyCount         = plan.ApplyCount,
                ApplyJob           = plan.ApplyJob,
                ApplyNo            = plan.ApplyNo,
                ApplyOrgId         = plan.ApplyOrgId,
                ApplyPostId        = plan.ApplyPostId,
                ApplyTime          = plan.ApplyTime,
                ApplyUser          = plan.ApplyUser,
                Comment            = plan.Comment,
                Discuss            = plan.Discuss,
                EmployeePlanId     = plan.Id,
                MergeUserId        = plan.MergeUserId,
                NeedAdmin          = plan.NeedAdmin,
                RecordUserId       = plan.RecordUserId,
                Result             = plan.Result,
                Phone           = plan.Phone,
                VerifyDiscuss   = plan.VerifyDiscuss,
                VerifyUserId    = plan.VerifyUserId,
                EmployeeUserIds = plan.EmployeeUserIds,
            };

            logrepository.Insert(log);
            if (plan.NeedAdmin.HasValue && plan.NeedAdmin.Value)
            {
                //需要领导审核时
            }
            else
            {
                //不需要领导审核时
                plan.ApplyCount         = (ApplyCount)((int)plan.ApplyCount) + 1;
                plan.EmployeeUserIds    = "";
                plan.AdminVerifyDiscuss = "";
                plan.Comment            = "";
                plan.Discuss            = "";
                plan.JoinDes            = "";
                plan.VerifyDiscuss      = "";
                plan.AdminUserId        = "";
                plan.MergeUserId        = "";
                plan.NeedAdmin          = null;
                plan.RecordUserId       = "";
                plan.Result             = null;
                plan.VerifyUserId       = "";
                repository.Update(plan);
            }


            return(true);
        }
Exemple #3
0
        public EmployeeResult Details(int id)
        {
            var detailsResult = new EmployeeResult();

            detailsResult.employee = objManage.GetEmployeeData(id);
            var managerOf = objManage.GetManagerOf(id);

            detailsResult.managerOf  = managerOf;
            detailsResult.managedBy  = objManage.GetMyManager(id);
            detailsResult.taskList   = objManage.GetMyTasks(id);
            detailsResult.reportList = objManage.GetMyReports(managerOf);
            return(detailsResult);
        }
        //Get the details of a particular employee
        public Employee GetEmployeeData(int id)
        {
            try
            {
                EmployeeResult result = new EmployeeResult();

                Employee employee = db.Employee.Find(id);
                return(employee);
            }
            catch
            {
                throw;
            }
        }
Exemple #5
0
        public static EmployeeResult Create(string param)
        {
            EmployeeResult model       = new EmployeeResult();
            AccessToken    accessToken = TokenHelp.GetAccessToken();
            string         url         = DingTalkUrlHelp.CreateEmployee(accessToken.Value);

            model = DingTalkHttpHelp <EmployeeResult> .Post(url, param);

            if (model.errmsg == "40014")
            {
                accessToken = TokenHelp.GetAccessToken();
                url         = DingTalkUrlHelp.CreateEmployee(accessToken.Value);
                model       = DingTalkHttpHelp <EmployeeResult> .Post(url, param);
            }
            return(model);
        }
Exemple #6
0
        private static void AddEmployee()
        {
            try
            {
                EmployeeEntity model = new EmployeeEntity();
                model.userid     = "wangzezheng";
                model.name       = "王五";
                model.department = new List <int>(new int[] { 123456 });
                model.position   = "软件工程师";
                model.mobile     = "137*****334";
                model.tel        = "";
                model.workPlace  = "";
                model.remark     = "";
                model.email      = "";
                model.jobnumber  = "";
                model.isHide     = false;
                model.isSenior   = false;

                string param = model.ToJson();

                EmployeeResult Result = EmployeeBll.Create(param);
                if (Result != null)
                {
                    if (Result.errcode == "0")
                    {
                        Console.Write("创建成功,UserId=" + Result.userid);
                    }
                    else
                    {
                        Console.Write(Result.errmsg);
                    }
                }
                else
                {
                    Console.Write("无返回数据");
                }
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);
            }
        }
        public static InvitationResult ConvertToResult(
            Invitation invitation,
            AlienResult alienResult,
            EmployeeResult employeeResult,
            VisitDetailResult visitDetailResult,
            IEnumerable <ForeignParticipantResult> foreignParticipantResultCollection)
        {
            Contract.Argument.IsNotNull(invitation, nameof(invitation));
            Contract.Argument.IsNotNull(alienResult, nameof(alienResult));
            Contract.Argument.IsNotNull(employeeResult, nameof(employeeResult));
            Contract.Argument.IsNotNull(visitDetailResult, nameof(visitDetailResult));
            Contract.Argument.IsNotNull(foreignParticipantResultCollection, nameof(foreignParticipantResultCollection));

            return(new InvitationResult
            {
                Id = invitation.Id,
                Alien = alienResult,
                Employee = employeeResult,
                VisitDetail = visitDetailResult,
                ForeignParticipants = foreignParticipantResultCollection
            });
        }
Exemple #8
0
        private static void EmployeeImputDingTalk()
        {
            LogHelper log = LogFactory.GetLogger("EmployeeImputDingTalk");

            try
            {
                List <DepartmentResult> resultList = new List <DepartmentResult>();
                SqlSugarClient          Edb        = new SqlSugarClient(new ConnectionConfig()
                {
                    ConnectionString      = Config.ESBConnectionString,
                    DbType                = DbType.SqlServer,
                    IsAutoCloseConnection = true
                });

                List <V_EmployeeToDingTalk> ESB_EmployeeList = Edb.Queryable <V_EmployeeToDingTalk>().ToList();

                var _DepartmentId = new[] { "1000000360", "1000000575", "1000000010" };

                ESB_EmployeeList = ESB_EmployeeList.Where(it => _DepartmentId.Contains(it.ESB_DepartmentId) && it.Enabled.Equals(1)).ToList();

                SqlSugarClient Ddb = new SqlSugarClient(new ConnectionConfig()
                {
                    ConnectionString      = Config.DingTalkConnectionString,
                    DbType                = DbType.SqlServer,
                    IsAutoCloseConnection = true
                });
                List <DepartmentResult> DTDepartList = Ddb.Queryable <DepartmentResult>().ToList();


                foreach (var item in ESB_EmployeeList)
                {
                    try
                    {
                        EmployeeEntity model = new EmployeeEntity();
                        model.userid     = item.UserId;
                        model.name       = item.Name;
                        model.department = new List <int>(new int[] { Convert.ToInt32(GetDingTalkDepartmentId(DTDepartList, item.ESB_DepartmentId)) });
                        model.position   = item.PositionName;
                        model.mobile     = item.Mobile;
                        model.tel        = item.Telephone;
                        model.workPlace  = "";
                        model.remark     = "";
                        model.email      = item.Email;
                        model.jobnumber  = item.UserId;
                        model.isHide     = false;
                        model.isSenior   = false;

                        string param = model.ToJson();

                        EmployeeResult Result = EmployeeBll.Create(param);
                        if (Result != null)
                        {
                            if (Result.errcode == "0")
                            {
                                Console.Write("创建成功,UserId=" + Result.userid);
                            }
                            else
                            {
                                Console.Write(Result.errmsg);
                            }
                        }
                        else
                        {
                            Console.Write("无返回数据");
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error(ex);
                        continue;
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
                Console.Write(ex.Message);
            }
        }
        public static void AddEmployee(SqlSugarClient Edb, SqlSugarClient Ddb, V_EmployeeToDingTalk item)
        {
            LogHelper log = LogFactory.GetLogger("AddEmployee");

            try
            {
                EmployeeEntity model           = new EmployeeEntity();
                string         DD_DepartmentId = "1";
                if (!item.ESB_DepartmentId.Equals("1000000001"))
                {
                    try
                    {
                        DepartmentResult DD_DepModel = Ddb.Queryable <DepartmentResult>().With(SqlWith.NoLock).Where(it => it.ESB_DepartmentID.Equals(item.ESB_DepartmentId)).First();
                        if (DD_DepModel == null)
                        {
                            DD_DepartmentId = DepartmentForDingTalkBll.DD_DepartmentIsNullForDingTalk(Edb, Ddb, item.ESB_DepartmentId);
                        }
                        else
                        {
                            DD_DepartmentId = DD_DepModel.id;
                        }
                    }
                    catch
                    {
                        DD_DepartmentId = "1";
                    }
                }

                model.userid     = item.UserId;
                model.name       = item.Name;
                model.department = new List <int>(new int[] { Convert.ToInt32(DD_DepartmentId) });
                model.position   = item.PositionName;
                model.mobile     = item.Mobile;
                model.tel        = item.Telephone;
                model.workPlace  = "";
                model.remark     = "";
                model.email      = item.Email;
                model.jobnumber  = item.UserId;
                model.isSenior   = false;

                string param = model.ToJson();

                EmployeeResult Result = EmployeeBll.Create(param);
                if (Result != null)
                {
                    if (Result.errcode == "0")
                    {
                        //Console.Write("创建成功,UserId=" + Result.userid);
                    }
                    //该外部联系人已存在 ||	手机号码在公司中已存在
                    else if (Result.errcode == "40026" || Result.errcode == "60104")
                    {
                        string res = EmployeeBll.Delete(model.userid).errcode;
                        if (res != "0")
                        {
                            log.Error("\r\n EmployeeForDingTalkBll-AddEmployee() 手机号码在公司中已存在删除时报错,错误编号:" + res);
                        }
                        EmployeeResult Result2 = EmployeeBll.Create(model.ToJson());
                        if (Result2.errcode != "0")
                        {
                            if (Result2.errcode == "40022")
                            {
                                string Deletecode = EmployeeBll.Delete(model.userid).errcode;

                                string Createcode = EmployeeBll.Create(model.ToJson()).errcode;

                                if (Createcode != "0")
                                {
                                    Createcode = EmployeeBll.Create(model.ToJson()).errcode;
                                    if (Createcode != "0" && Createcode != "40021")
                                    {
                                        log.Error("\r\n AddEmployee - 行号507 成功删除员工信息,但是创建员工信息时报错,错误编码如下:" + Createcode);
                                    }
                                }
                                //手机号码在公司中已存在
                                if (Result2.errcode == "60104")
                                {
                                    log.Debug("\r\n EmployeeForDingTalkBll-AddEmployee() 手机号码在公司中已存在 时报错,信息如下" + Result2.errmsg + ",错误编码为:" + Result2.errcode + ", Json参数为:" + param);
                                }
                                else
                                {
                                    log.Error("\r\n EmployeeForDingTalkBll-AddEmployee() 该外部联系人已存在 ||	手机号码在公司中已存在 时报错,信息如下"+ Result2.errmsg + ",错误编码为:" + Result2.errcode + ", Json参数为:" + param);
                                }

                                Task.Factory.StartNew(() =>
                                {
                                    InsertErroUpdateEmployee(Ddb, model.userid, "", item.Mobile, Result.errcode);
                                    if (Deletecode != "0")
                                    {
                                        InsertErroUpdateEmployee(Ddb, model.userid, "", item.Mobile, "新增用户时,删除失败,错误编号:" + Deletecode);
                                    }
                                    if (Createcode != "0")
                                    {
                                        InsertErroUpdateEmployee(Ddb, model.userid, "", item.Mobile, "新增用户时,执行删除后创建失败,错误编号:" + Createcode);
                                    }
                                });
                            }
                        }
                    }
                    else
                    {
                        if (Result.errcode == "60103")
                        {
                            log.Debug("\r\n EmployeeForDingTalkBll-AddEmployee() " + Result.errmsg + ",错误编码为:" + Result.errcode + ",手机号为" + item.Mobile + ",用户id为" + item.UserId + " Json参数为:" + param);
                        }
                        else
                        {
                            log.Error("\r\n EmployeeForDingTalkBll-AddEmployee() " + Result.errmsg + ",错误编码为:" + Result.errcode);
                        }

                        Task.Factory.StartNew(() =>
                        {
                            InsertErroUpdateEmployee(Ddb, model.userid, "", item.Mobile, "新增用户时创建失败,错误编号:" + Result.errcode);
                        });
                    }
                }
                else
                {
                    //Console.Write("无返回数据");
                }
            }
            catch (Exception ex)
            {
                log.Error("\r\n EmployeeForDingTalkBll-AddEmployee() " + ex + "\r\n");
                //Console.Write(ex.Message);
            }
        }
        public static void InsertForDingTalk(SqlSugarClient Edb, SqlSugarClient Ddb, List <V_EmployeeToDingTalk> EmpList, V_EmployeeToDingTalk item)
        {
            LogHelper log             = LogFactory.GetLogger("InsertEmployeeForDingTalk");
            string    DD_DepartmentId = "1";

            if (!item.ESB_DepartmentId.Equals("1000000001"))
            {
                DepartmentResult DD_DepModel = Ddb.Queryable <DepartmentResult>().With(SqlWith.NoLock).Where(it => it.ESB_DepartmentID.Equals(item.ESB_DepartmentId)).First();
                if (DD_DepModel == null)
                {
                    DD_DepartmentId = DepartmentForDingTalkBll.DD_DepartmentIsNullForDingTalk(Edb, Ddb, item.ESB_DepartmentId);
                }
                else
                {
                    DD_DepartmentId = DD_DepModel.id;
                }
                try
                {
                    DD_DepartmentId = Ddb.Queryable <DepartmentResult>().With(SqlWith.NoLock).Where(it => it.ESB_DepartmentID.Equals(item.ESB_DepartmentId)).First().id;
                }
                catch (Exception ex)
                {
                    Console.Write("根据ESB_DepartmentId获取对应的钉钉id时报错,该ID为" + item.ESB_DepartmentId + ",错误信息为:" + ex + "\r\n");
                }
            }
            EmployeeEntity model = new EmployeeEntity();

            model.userid     = item.UserId;
            model.name       = item.Name;
            model.department = new List <int>(new int[] { Convert.ToInt32(DD_DepartmentId) });
            model.position   = item.PositionName;
            model.mobile     = item.Mobile;
            model.tel        = item.Telephone;
            model.workPlace  = "";
            model.remark     = "";
            model.email      = item.Email;
            model.jobnumber  = item.UserId;
            model.isSenior   = false;

            string param = model.ToJson();

            EmployeeResult Result = EmployeeBll.Create(param);

            if (Result != null)
            {
                if (Result.errcode == "0")
                {
                    EmpList.Add(item);
                    //Console.Write("创建成功,UserId=" + Result.userid + "\r\n");
                }
                else
                {
                    //UserID在公司中已存在
                    if (Result.errcode == "60102")
                    {
                        string EmployeeJson = GetEmployee(item.UserId);
                        model = Newtonsoft.Json.JsonConvert.DeserializeObject <EmployeeEntity>(EmployeeJson);

                        model.userid     = item.UserId;
                        model.name       = item.Name;
                        model.department = new List <int>(new int[] { Convert.ToInt32(DD_DepartmentId) });
                        model.position   = item.PositionName;
                        model.mobile     = item.Mobile;
                        model.tel        = item.Telephone;
                        model.email      = item.Email;
                        model.jobnumber  = item.UserId;
                        param            = model.ToJson();

                        Result res = EmployeeBll.Update(param);
                        if (res != null)
                        {
                            if (res.errcode == "0")
                            {
                                EmpList.Add(item);
                                //Console.Write("更新成功," + Result.errmsg);
                            }
                            else
                            {
                                log.Error("\r\n EmployeeForDingTalkBll-InsertForDingTalk() " + Result.errmsg + "; UserId=" + item.UserId);
                                //Console.Write("\r\n" + Result.errmsg + "; UserId=" + item.UserId);
                            }
                        }
                        else
                        {
                            //Console.Write("无返回数据");
                        }
                    }
                    else
                    {
                        if (Result.errcode == "60104")
                        {
                            log.Error("\r\n EmployeeForDingTalkBll-InsertForDingTalk() " + Result.errmsg + "; UserId=" + item.UserId);
                        }
                        else if (Result.errcode == "40026")
                        {
                            //该外部联系人已存在
                            AddEmployee(Edb, Ddb, item);
                            EmpList.Add(item);
                        }
                        else
                        {
                            log.Error("\r\n EmployeeForDingTalkBll-InsertForDingTalk() " + Result.errmsg + "; UserId=" + item.UserId);
                        }
                        //Console.Write("\r\n" + Result.errmsg + "; UserId=" + item.UserId);
                    }
                }
            }
            else
            {
                //Console.Write("无返回数据");
            }
        }
        public static void EmployeeImputDingTalk(SqlSugarClient Edb, SqlSugarClient Ddb)
        {
            LogHelper log = LogFactory.GetLogger("EmployeeImputDingTalk");

            try
            {
                List <DepartmentResult> resultList = new List <DepartmentResult>();

                List <V_EmployeeToDingTalk> ESB_EmployeeList = Edb.Queryable <V_EmployeeToDingTalk>().ToList();

                List <DepartmentResult> DTDepartList = Ddb.Queryable <DepartmentResult>().ToList();

                foreach (var item in ESB_EmployeeList)
                {
                    try
                    {
                        if (item.Enabled == 1)
                        {
                            EmployeeEntity model = new EmployeeEntity();
                            model.userid     = item.UserId;
                            model.name       = item.Name;
                            model.department = new List <int>(new int[] { Convert.ToInt32(DepartmentForDingTalkBll.GetDingTalkDepartmentId(DTDepartList, item.ESB_DepartmentId)) });
                            model.position   = item.PositionName;
                            model.mobile     = item.Mobile;
                            model.tel        = item.Telephone;
                            model.workPlace  = "";
                            model.remark     = "";
                            model.email      = item.Email;
                            model.jobnumber  = item.UserId;
                            model.isHide     = false;
                            model.isSenior   = false;

                            string param = model.ToJson();

                            EmployeeResult Result = EmployeeBll.Create(param);
                            if (Result != null)
                            {
                                if (Result.errcode == "0")
                                {
                                    Console.Write("创建成功,UserId=" + Result.userid + "\r\n");
                                }
                                else
                                {
                                    Console.Write(Result.errmsg + "\r\n");
                                }
                            }
                            else
                            {
                                Console.Write("无返回数据");
                            }
                        }
                        else
                        {
                            Result Result = EmployeeBll.Delete(item.UserId);
                            if (Result != null)
                            {
                                if (Result.errcode == "0")
                                {
                                    Console.Write("删除成功," + Result.errmsg + "\r\n");
                                }
                                else
                                {
                                    Console.Write(Result.errmsg + "\r\n");
                                }
                            }
                            else
                            {
                                Console.Write("无返回数据");
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("\r\n InitializeDingTalk-EmployeeImputDingTalk() " + ex);
                        continue;
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error("\r\n InitializeDingTalk-EmployeeImputDingTalk() " + ex);
                Console.Write(ex.Message);
            }
        }
        /// <summary>
        /// This is the method that inits the employee tab functions.
        /// Be prepared to replicate this logic for the other tab init functions.
        /// If we do this right we can reuse a good bit of this logic for all the other classes
        /// This is a segmentation based approach to formulating query logic
        /// The goal is to do minimum hardcoding, unfortunately this means relying on direct input
        /// I've included sanitizing handlers on all text entry for ensuring we don't get malicious input
        /// We can split this up across muliple partial classes if needed, you can only access controls directly
        /// from the main class thats linked to the window.
        /// There may be other ways to split it up among completely different classes, let me [Marcus] know.
        /// One class per initializer, if things get too hectic.
        /// </summary>
        private void InitializeEmployees()
        {
            //Set generic table name
            string mainTable = "Employees";
            //Declare column names to a generic name
            string id              = "EID";
            string primaryColumn   = "FirstName";
            string secondaryColumn = "LastName";


            //One way of doing dynamic joins?
            //The keys in this dictionary represent a selection value, such as Zipcode
            //The values are the table that would be needed to retireve this value, For zip thats EmployeeContacts
            //We could check contains<Selection value> and them automatically append the correct table to the join statement?
            Dictionary <string, string> joinList = new Dictionary <string, string>();

            //Add conditions, remeber these are just column names that you need to account for.
            //Good example, even though i show ZipCode to the user, We sanitize that to a proper column name "Zip"
            //THEN we query the joinList for the correct table to join to.
            //ALL this is taken care of, or should be, by the rest of the logic so just ensure you have the proper columns here
            //Then Go down to the "Sanitization Section" and  ensure you're sanitizing any "Facade Names" to a proper column name where you need to
            //OTHERWISE it wont match on the join list, and you WONT get a join!
            //Of course if we have time we can refine the system to make it more intelligent, but I'd rather implement that once we get all
            //50 Questions handled

            joinList.Add("Zip", "EmployeeContacts");

            //Declare Controls to a generic name;
            //That way we can resuse most of this logic by just assigning the proper control here.
            var SearchBar = EmployeesSearchBar;
            //We do the same for every other control
            var SearchBy = EmployeesSearchByComboBox;

            SearchBy.SelectionChanged += (obj, sender) =>
            {
                //Set on change to enable search button, if filterby is untouched
                if (!EmployeesFilterOptionBar.IsEnabled)
                {
                    EmployeesRunButton.IsEnabled = true;
                }
                else
                {
                    EmployeesRunButton.IsEnabled = false;
                }
            };

            var OrderBy = EmployeesSortByComboBox;



            var FilterBy = EmployeesFilterByComboBox;

            //Acts as a filter
            FilterBy.SelectionChanged += (obj, sender) =>
            {
                //Set on change to enable filter box if not enabled
                if (!EmployeesFilterOptionBar.IsEnabled)
                {
                    EmployeesFilterOptionBar.IsEnabled = true;
                }

                if (EmployeesRunButton.IsEnabled)
                {
                    EmployeesRunButton.IsEnabled = false;
                }
            };

            var RunButton = EmployeesRunButton;

            //Remember to set default button for each home tab, so that enter will trigger.
            RunButton.IsDefault = true;
            //The most important part, contains submission logic.
            RunButton.Click += (obj, sender) =>
            {
                //The run button for each tab is responsible for sanitizing input, building the query and launching the result tab
                //First case is when there is no filter by
                if (true)
                {
                    //SANITIZATION SECTION
                    var sanitizedText = EmployeesSearchBar.Text;

                    int spaces = 0; //TrackSpaces

                    //Must sanitize to prevent SQL Injection.
                    foreach (char c in sanitizedText)
                    {
                        if (!char.IsLetterOrDigit(c))
                        {
                            MessageBox.Show("Invalid Input!");
                            return;
                        }
                        if (c == ' ')
                        {
                            spaces++;
                        }
                        if (spaces > 1)
                        {
                            MessageBox.Show("Too Many Spaces!");
                            return;
                        }
                    }

                    string searchByChoice = SearchBy.Text;
                    string filterByChoice = FilterBy.Text;
                    string orderByChoice  = OrderBy.Text;



                    //Remove spaces
                    searchByChoice = searchByChoice.Replace(" ", "");
                    filterByChoice = filterByChoice.Replace(" ", "");
                    orderByChoice  = orderByChoice.Replace(" ", "");

                    //If you have any 'facade names' that is , inputs that don't share the same screen name as the column name, handle that here
                    if (filterByChoice == "ZipCode")
                    {
                        filterByChoice = "Zip"; //Change to the shortened form
                    }
                    //Build Query
                    //Hopefully the only part we'll have to hardcode

                    //STATEMENT SECTION

                    string joinStatement = "";
                    //now join statement needs to be empty by default
                    //how do we sovle the question of knowing WHENwe need a join, being  least hardcody as possible?

                    //All joins will be done by some sort of ID

                    //conditionals for all entries that will require touching another table and making sure that table is accounted for
                    if (joinList.ContainsKey(filterByChoice))
                    {
                        //On <jtable>.<idvalue> = <maintable>.<idvalue>
                        var onStatement = " On " + joinList[filterByChoice] + "." + id + " = " + mainTable + "." + id;
                        // <maintabl> , <jtable> + [OnStatement]
                        joinStatement += " join " + joinList[filterByChoice] + " " + onStatement + " ";
                    }

                    string fromStatement = " From " + mainTable + " " + joinStatement;
                    //Explanation for +Maintable + "." + id, To prevent ambiguous column name in case of join
                    string selectionStatement = "Select " + mainTable + "." + id + "," + primaryColumn + ", " + secondaryColumn + " " + fromStatement;
                    //The "And" Part of the where OR the WHOLE where if there is no search by chosen.
                    string filterStatement = ""; //triggered if filter by is on

                    if (EmployeesFilterOptionBar.IsEnabled && EmployeesFilterOptionBar.Text.Length > 0)
                    {
                        filterStatement = " And " + filterByChoice + " = '" + EmployeesFilterOptionBar.Text + "'";
                    }


                    string whereStatement = ""; //We'll use conditional logic to formulate this value, then pass it through to our query.

                    if (sanitizedText.Length > 0)
                    {
                        //If the user has followed the default search logic
                        //(Type info in search bar, choose search by =>{Whatever else}
                        whereStatement = "Where " + searchByChoice + " = '" + sanitizedText + "' " + filterStatement;
                    }
                    else if (sanitizedText.Length == 0 && filterStatement != "")
                    {
                        //If the user wants all users that match a given filter, then type the filter in the option bar
                        whereStatement =
                            "Where " + filterStatement.Replace(" And ",
                                                               ""); //Its just the filter statement minus the And part;
                    }
                    else
                    {
                        throw new IllegalStateException("Error in Employee query generation conditional logic.");
                    }

                    //This is the final part of our query, the order statement
                    string orderStatement = "";


                    if (OrderBy.SelectedIndex == 1)
                    {
                        //This would be the full name;
                        if (EmployeesCheckBoxIsDesc.IsChecked != null && (bool)EmployeesCheckBoxIsDesc.IsChecked)
                        {
                            //If they want it desc
                            orderStatement = " Order By FirstName Desc, LastName Desc";
                        }
                        else
                        {
                            orderStatement = " Order By FirstName, LastName";
                        }
                    }
                    else if (OrderBy.SelectedIndex != -1)
                    {
                        //anything other than full name
                        if (EmployeesCheckBoxIsDesc.IsChecked != null && (bool)EmployeesCheckBoxIsDesc.IsChecked)
                        {
                            //If they want it desc
                            orderStatement = " Order By " + orderByChoice + " Desc";
                        }
                        else
                        {
                            orderStatement = " Order By " + orderByChoice; // Ascending order is default.
                        }
                    }

                    //NOW WEBUILD THE QUERY

                    //QUERY
                    SqlCommand GetEmployees = new SqlCommand(
                        //Do not forget to space after each statement
                        //Although I've already added proper spacing in the statements themselves
                        //Data we will be returning
                        selectionStatement +
                        //Yes for inserted strings, that you want to be evaluated in sql as string
                        //You still have to concat the ' before AND after!
                        whereStatement +
                        //Now we just concat our formulated order statement
                        orderStatement
                        //That's it.
                        );
                    //Debug ops, and for easy referencing later.
                    Logger.LogG("SqlCommand",
                                "Created query:" + Environment.NewLine + GetEmployees.CommandText + Environment.NewLine);

                    //You must link the connection, maybe we can create a connection wrapper that does this for us.
                    //You could also pass as second param in constructor but the idea would be to have it link automatically
                    //It could grab the db connection from the Connection Manager.
                    GetEmployees.Connection = db;

                    try
                    {
                        //Launch Command, Returns a Reader on the result table
                        var results = GetEmployees.ExecuteReader();

                        //Spawn a new results tab, besure to call Prepare() before adding to the master tab control for that Section!
                        var resultsTab = new ResultsTab();



                        while (results.Read())
                        {
                            var result = new EmployeeResult(results[0], results[1], results[2]); //Create new result with an EMPLOYEE Context.
                            resultsTab.Add(result);
                        }

                        //CLOSE the sql command's reader, or subsequent calls to the sql command will fail!
                        results.Close();

                        //Handle naming...

                        //How many other result tabs are open?
                        int count = 1; //init the counter
                        foreach (object tab in EmployeesTabControl.Items)
                        {
                            if (tab is ResultsTab)
                            {
                                count++;
                            }
                        }

                        //PREPARE the tab BEFORE adding to the MasterTab's TabControl.
                        resultsTab.Prepare("Results " + count);
                        //Add to tabcontrol.
                        EmployeesTabControl.Items.Add(resultsTab);

                        //Switch to new tab, for pazzaz really, but it makes sense.
                        //ie when a user searches, you expect to be brought to the results
                        //imagine if google opened it's results in a new tab and made you switch to it
                        //or when you rightclick and issue an  open in new tab command , you have to manually click the tab
                        //it wouldn't make any sense, so don't forget to always do this.
                        EmployeesTabControl.SelectedIndex = EmployeesTabControl.Items.Count - 1;
                    }
                    catch (SqlException sqe)
                    {
                        //Use EasyBox to handle errors.
                        EasyBox.ShowError(sqe);
                        Application.Current.Shutdown(1);
                    }
                }
            };
            //Filter drop down
            var FilterOptions = EmployeesFilterOptionBar;

            //Enables/Disables submit button
            EmployeesFilterOptionBar.TextChanged += (obj, sender) =>
            {
                if (FilterOptions.Text.Length > 1)
                {
                    //enable button
                    RunButton.IsEnabled = true;
                }
                else
                {
                    RunButton.IsEnabled = false;
                }
            };



            //Handler that disables search button if box is empty.
            SearchBar.TextChanged += (sender, args) =>
            {
                if (SearchBar.Text.Length == 0)
                {
                    EmployeesRunButton.IsEnabled = false;
                }
                //If there is text AND search by is filled AND there's no filter
                else if (SearchBy.SelectedItem != null && !EmployeesFilterOptionBar.IsEnabled)
                {
                    RunButton.IsEnabled = true;
                }
                //If there is text AND search by is filled AND the filter contains text
                else if (SearchBy.SelectedItem != null && EmployeesFilterOptionBar.IsEnabled && EmployeesFilterOptionBar?.Text.Length > 0)
                {
                    RunButton.IsEnabled = true;
                }
            };
        }