private void FrmAddWorker_Load(object sender, EventArgs e)
        {
            //加载部门信息
            cboClub.DataSource    = new BaseService().SelectDeptAll();
            cboClub.DisplayMember = "dept_name";
            cboClub.ValueMember   = "dept_no";
            //加载民族信息
            cbWorkerNation.DataSource    = new BaseService().SelectNationAll();
            cbWorkerNation.DisplayMember = "nation_name";
            cbWorkerNation.ValueMember   = "nation_no";
            //加载职位信息
            cboWorkerPosition.DataSource    = new BaseService().SelectPositionAll();
            cboWorkerPosition.DisplayMember = "position_name";
            cboWorkerPosition.ValueMember   = "position_no";
            //加载性别信息
            cboSex.DataSource    = new BaseService().SelectSexTypeAll();
            cboSex.DisplayMember = "sexName";
            cboSex.ValueMember   = "sexId";
            //加载学历信息
            cboEducation.DataSource    = new BaseService().SelectEducationAll();
            cboEducation.DisplayMember = "education_name";
            cboEducation.ValueMember   = "education_no";

            pictureBox1.LoadAsync("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1587209835893&di=02964b1de4a1ef4f938f7d3ae12b5b17&imgtype=0&src=http%3A%2F%2Fbpic.588ku.com%2Felement_origin_min_pic%2F17%2F11%2F25%2F0ef5a188956c2717db96d72d58524dec.jpg");
            if (this.Text == "员工信息查看页")
            {
                foreach (Control control in this.Controls)
                {
                    switch (control.GetType().ToString())
                    {
                    case "Sunny.UI.UITextBox":
                        (control as Sunny.UI.UITextBox).ReadOnly = true;
                        break;

                    case "Sunny.UI.UIComboBox":
                        (control as Sunny.UI.UIComboBox).ReadOnly = true;
                        break;

                    case "Sunny.UI.UIDatePicker":
                        (control as Sunny.UI.UIDatePicker).ReadOnly = true;
                        break;
                    }
                }
                btnAdd.Visible           = false;
                WorkerNo.Text            = FrmChangeWorker.wk_WorkerNo;
                WorkerName.Text          = FrmChangeWorker.wk_WorkerName;
                cboSex.Text              = FrmChangeWorker.wk_WorkerSex;
                cboWorkerPosition.Text   = FrmChangeWorker.wk_WorkerPosition;
                cboWorkerFace.Text       = FrmChangeWorker.wk_WorkerFace;
                cbWorkerNation.Text      = FrmChangeWorker.wk_WorkerNation;
                dtpBirthday.Value        = Convert.ToDateTime(FrmChangeWorker.wk_WorkerBirthday);
                dtpTime.Value            = Convert.ToDateTime(FrmChangeWorker.wk_WorkerTime);
                WorkerID.Text            = FrmChangeWorker.wk_WorkerID;
                txtAddress.Text          = FrmChangeWorker.wk_WorkerAddress;
                WorkerTel.Text           = FrmChangeWorker.wk_WorkerTel;
                cboEducation.Text        = FrmChangeWorker.wk_WorkerEducation;
                cboClub.Text             = FrmChangeWorker.wk_WorkerClub;
                this.WorkerID.Validated -= new EventHandler(WorkerID_Validated);
                List <WorkerHistory> workerHistories = new WorkerHistoryService().SelectHistoryByWorkerId(WorkerNo.Text);
                for (int i = 0; i < workerHistories.Count; i++)
                {
                    ucHistory = new ucHistory();
                    ucHistory.dtpStartDate.Value    = workerHistories[i].StartDate;
                    ucHistory.dtpEndDate.Value      = workerHistories[i].EndDate;
                    ucHistory.txtPosition.Text      = workerHistories[i].Position;
                    ucHistory.txtCompany.Text       = workerHistories[i].Company;
                    ucHistory.dtpStartDate.ReadOnly = true;
                    ucHistory.dtpEndDate.ReadOnly   = true;
                    ucHistory.txtPosition.ReadOnly  = true;
                    ucHistory.txtCompany.ReadOnly   = true;
                    flpHistory.Controls.Add(ucHistory);
                }
            }
            else if (this.Text == "添加员工")
            {
                WorkerNo.Text = new CounterHelper().GetNewId("WorkerId");
                ucHistory     = new ucHistory();
                //ucHistory.txtCompany.ReadOnly = false;
                //ucHistory.txtPosition.ReadOnly = false;
                ucHistory.dtpStartDate.Enabled = true;
                ucHistory.dtpEndDate.Enabled   = true;
                ucHistory.txtCompany.Enabled   = true;
                ucHistory.txtPosition.Enabled  = true;
                flpHistory.Controls.Add(ucHistory);
                cboClub.SelectedIndex           = 0;
                cboEducation.SelectedIndex      = 0;
                cboSex.SelectedIndex            = 0;
                cboWorkerFace.SelectedIndex     = 0;
                cboWorkerPosition.SelectedIndex = 0;
            }
            else
            {
                bool dr = UIMessageBox.Show("修改操作仅能修改姓名、性别、电话号码、联系地址、面貌以及最高学历,以上是否知晓?点击确定继续进行修改!", "修改提醒", UIStyle.Orange, UIMessageBoxButtons.OKCancel);
                if (dr == true)
                {
                    foreach (Control item in this.Controls)
                    {
                        switch (item.Name)
                        {
                        case "Sunny.UI.UITextBox":
                            (item as Sunny.UI.UITextBox).ReadOnly = true;
                            break;

                        case "Sunny.UI.UIComboBox":
                            (item as Sunny.UI.UIComboBox).ReadOnly = true;
                            break;

                        case "Sunny.UI.UIDatePicker":
                            (item as Sunny.UI.UIDatePicker).ReadOnly = true;
                            break;
                        }
                    }
                    WorkerNo.Text            = FrmChangeWorker.wk_WorkerNo;
                    WorkerName.Text          = FrmChangeWorker.wk_WorkerName;
                    cboSex.Text              = FrmChangeWorker.wk_WorkerSex;
                    cboWorkerPosition.Text   = FrmChangeWorker.wk_WorkerPosition;
                    cboWorkerFace.Text       = FrmChangeWorker.wk_WorkerFace;
                    cbWorkerNation.Text      = FrmChangeWorker.wk_WorkerNation;
                    dtpBirthday.Value        = Convert.ToDateTime(FrmChangeWorker.wk_WorkerBirthday);
                    dtpTime.Value            = Convert.ToDateTime(FrmChangeWorker.wk_WorkerTime);
                    WorkerID.Text            = FrmChangeWorker.wk_WorkerID;
                    txtAddress.Text          = FrmChangeWorker.wk_WorkerAddress;
                    WorkerTel.Text           = FrmChangeWorker.wk_WorkerTel;
                    cboEducation.Text        = FrmChangeWorker.wk_WorkerEducation;
                    cboClub.Text             = FrmChangeWorker.wk_WorkerClub;
                    this.WorkerID.Validated -= new EventHandler(WorkerID_Validated);
                    btnAdd.Text              = "修改";
                    this.btnAdd.Click       -= new EventHandler(btnAdd_Click);
                    this.btnAdd.Click       += new EventHandler(btnUpd_Click);
                    WorkerTel.ReadOnly       = false;
                    txtAddress.ReadOnly      = false;
                    List <WorkerHistory> workerHistories = new WorkerHistoryService().SelectHistoryByWorkerId(WorkerNo.Text);
                    for (int i = 0; i < workerHistories.Count; i++)
                    {
                        ucHistory = new ucHistory();
                        ucHistory.dtpStartDate.Value = workerHistories[i].StartDate;
                        ucHistory.dtpEndDate.Value   = workerHistories[i].EndDate;
                        ucHistory.txtPosition.Text   = workerHistories[i].Position;
                        ucHistory.txtCompany.Text    = workerHistories[i].Company;
                        flpHistory.Controls.Add(ucHistory);
                    }
                }
            }
        }
        private void FrmAddWorker_Load(object sender, EventArgs e)
        {
            Random ran = new Random();

            for (int i = 0; i < 10; i++)
            {
                RandKey = ran.Next(100000000, 999999999);
            }
            pictureBox1.LoadAsync("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1587209835893&di=02964b1de4a1ef4f938f7d3ae12b5b17&imgtype=0&src=http%3A%2F%2Fbpic.588ku.com%2Felement_origin_min_pic%2F17%2F11%2F25%2F0ef5a188956c2717db96d72d58524dec.jpg");
            if (this.Text == "员工信息查看页")
            {
                foreach (Control control in pnlInfo.Controls)
                {
                    if (control is TextBox)
                    {
                        (control as TextBox).ReadOnly = true;
                    }
                }
                btnAdd.Visible         = false;
                WorkerNo.Text          = FrmChangeWorker.wk_WorkerNo;
                WorkerName.Text        = FrmChangeWorker.wk_WorkerName;
                cboSex.Text            = FrmChangeWorker.wk_WorkerSex;
                cboWorkerPosition.Text = FrmChangeWorker.wk_WorkerPosition;
                cboWorkerFace.Text     = FrmChangeWorker.wk_WorkerFace;
                Pwd.Text                 = "***************";
                dtpBirthday.Value        = Convert.ToDateTime(FrmChangeWorker.wk_WorkerBirthday);
                dtpTime.Value            = Convert.ToDateTime(FrmChangeWorker.wk_WorkerTime);
                WorkerID.Text            = FrmChangeWorker.wk_WorkerID;
                txtAddress.Text          = FrmChangeWorker.wk_WorkerAddress;
                WorkerTel.Text           = FrmChangeWorker.wk_WorkerTel;
                cboEducation.Text        = FrmChangeWorker.wk_WorkerEducation;
                cboClub.Text             = FrmChangeWorker.wk_WorkerClub;
                this.WorkerID.Validated -= new EventHandler(WorkerID_Validated);
                List <WorkerHistory> workerHistories = WorkerHistoryManager.SelectHistoryByWorkerId(WorkerNo.Text);
                for (int i = 0; i < workerHistories.Count; i++)
                {
                    ucHistory = new ucHistory();
                    ucHistory.dtpStartDate.Value = workerHistories[i].StartDate;
                    ucHistory.dtpEndDate.Value   = workerHistories[i].EndDate;
                    ucHistory.txtPosition.Text   = workerHistories[i].Postion;
                    ucHistory.txtCompany.Text    = workerHistories[i].Company;
                    flpHistory.Controls.Add(ucHistory);
                }
            }
            else if (this.Text == "员工信息添加页")
            {
                Random random = new Random();
                Pwd.Text      = RandKey.ToString();
                WorkerNo.Text = "WK" + random.Next(0, 9).ToString() + random.Next(0, 9).ToString() + random.Next(0, 9).ToString();
                ucHistory     = new ucHistory();
                //ucHistory.txtCompany.ReadOnly = false;
                //ucHistory.txtPosition.ReadOnly = false;
                ucHistory.dtpStartDate.Enabled = true;
                ucHistory.dtpEndDate.Enabled   = true;
                ucHistory.txtCompany.Enabled   = true;
                ucHistory.txtPosition.Enabled  = true;
                flpHistory.Controls.Add(ucHistory);
                cboClub.SelectedIndex           = 0;
                cboEducation.SelectedIndex      = 0;
                cboSex.SelectedIndex            = 0;
                cboWorkerFace.SelectedIndex     = 0;
                cboWorkerPosition.SelectedIndex = 0;
            }
            else
            {
                DialogResult dr = MessageBox.Show("修改操作仅能修改性别、电话号码、联系地址、登录密码、面貌以及最高学历,以上是否知晓?点击确定继续进行修改!", "修改提醒", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                if (dr == DialogResult.OK && Pwd.Text != null)
                {
                    WorkerNo.Text          = FrmChangeWorker.wk_WorkerNo;
                    WorkerName.Text        = FrmChangeWorker.wk_WorkerName;
                    cboSex.Text            = FrmChangeWorker.wk_WorkerSex;
                    cboWorkerPosition.Text = FrmChangeWorker.wk_WorkerPosition;
                    cboWorkerFace.Text     = FrmChangeWorker.wk_WorkerFace;
                    //Pwd.Text = "***************";
                    dtpBirthday.Value        = Convert.ToDateTime(FrmChangeWorker.wk_WorkerBirthday);
                    dtpTime.Value            = Convert.ToDateTime(FrmChangeWorker.wk_WorkerTime);
                    WorkerID.Text            = FrmChangeWorker.wk_WorkerID;
                    txtAddress.Text          = FrmChangeWorker.wk_WorkerAddress;
                    WorkerTel.Text           = FrmChangeWorker.wk_WorkerTel;
                    cboEducation.Text        = FrmChangeWorker.wk_WorkerEducation;
                    cboClub.Text             = FrmChangeWorker.wk_WorkerClub;
                    this.WorkerID.Validated -= new EventHandler(WorkerID_Validated);
                    btnAdd.Text              = "修改";
                    this.btnAdd.Click       -= new EventHandler(btnAdd_Click);
                    this.btnAdd.Click       += new EventHandler(btnUpd_Click);
                    WorkerTel.ReadOnly       = false;
                    txtAddress.ReadOnly      = false;
                    Pwd.ReadOnly             = false;
                    List <WorkerHistory> workerHistories = WorkerHistoryManager.SelectHistoryByWorkerId(WorkerNo.Text);
                    for (int i = 0; i < workerHistories.Count; i++)
                    {
                        ucHistory = new ucHistory();
                        ucHistory.dtpStartDate.Value = workerHistories[i].StartDate;
                        ucHistory.dtpEndDate.Value   = workerHistories[i].EndDate;
                        ucHistory.txtPosition.Text   = workerHistories[i].Postion;
                        ucHistory.txtCompany.Text    = workerHistories[i].Company;
                        flpHistory.Controls.Add(ucHistory);
                    }
                }
            }
        }