コード例 #1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                if (WorkerName.Text != null /*&& ucHistory.txtCompany.Text != null*/ && cboSex.Text != null)
                {
                    string NewID  = Md5LockedUtil.MD5Encrypt32(WorkerID.Text.ToString());
                    string NewTel = Md5LockedUtil.MD5Encrypt32(WorkerTel.Text.ToString());

                    #region 员工信息添加代码块
                    Worker worker = new Worker
                    {
                        WorkerId        = WorkerNo.Text.Trim(),
                        WorkerName      = WorkerName.Text.Trim(),
                        WorkerBirthday  = dtpBirthday.Value,
                        WorkerSex       = cboSex.SelectedIndex,
                        WorkerTel       = NewTel,
                        WorkerClub      = cboClub.Text,
                        WorkerAddress   = txtAddress.Text,
                        WorkerPosition  = cboWorkerPosition.Text,
                        CardId          = NewID,
                        WorkerPwd       = Pwd.Text,
                        WorkerTime      = dtpTime.Value,
                        WorkerFace      = cboWorkerFace.Text,
                        WorkerEducation = cboEducation.Text
                    };
                    int n = WorkerManager.AddWorker(worker);
                    #endregion
                    #region 履历添加代码块
                    if (ucHistory.txtCompany != null && ucHistory.txtPosition != null && ucHistory.dtpStartDate.Value != null && ucHistory.dtpEndDate.Value != null)
                    {
                        WorkerHistory workerHistory = new WorkerHistory
                        {
                            StartDate = ucHistory.dtpStartDate.Value,
                            EndDate   = ucHistory.dtpEndDate.Value,
                            Postion   = ucHistory.txtPosition.Text,
                            Company   = ucHistory.txtCompany.Text
                        };
                        int j = WorkerHistoryManager.AddHistoryByWorkerId(workerHistory, WorkerNo.Text);
                        #endregion

                        #region 判断履历和信息代码块
                        if (n > 0 && j > 0)
                        {
                            MessageBox.Show("员工信息/履历添加成功!该员工登录密码为:" + Pwd.Text + ",请提醒员工妥善保管!");
                            FrmWorkerManager.Reload();
                            #region 获取添加操作日志所需的信息
                            OperationLog o = new OperationLog();
                            o.OperationTime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd,HH:mm:ss"));
                                << << << < HEAD : SYS.FormUI / FrmAddWorker.cs
                                << << << < HEAD : SYS.FormUI / FrmAddWorker.cs
                                o.Operationlog = AdminInfo.admingroup + AdminInfo.adminType + "于" + DateTime.Now + "进行了添加员工操作,员工编号为:" + WorkerNo.Text + "!";
                            o.OperationAccount = AdminInfo.admingroup + AdminInfo.adminType;
                            OperationManager.InsertOperationLog(o);
コード例 #2
0
        public static List <WorkerHistory> SelectHistoryByWorkerId(string wid)
        {
            List <WorkerHistory> why = new List <WorkerHistory>();
            string        sql        = "SELECT * FROM WORKERINFO wi,WORKERHISTORY wh where wi.WorkerId = wh.WorkerId and wi.WorkerId = '" + wid + "'";
            SqlDataReader dr         = DBHelper.ExecuteReader(sql);

            while (dr.Read())
            {
                WorkerHistory workerHistory = new WorkerHistory();
                workerHistory.WorkerId  = dr["WorkerId"].ToString();
                workerHistory.StartDate = DateTime.Parse(dr["StartDate"].ToString());
                workerHistory.EndDate   = DateTime.Parse(dr["EndDate"].ToString());
                workerHistory.Postion   = dr["Position"].ToString();
                workerHistory.Company   = dr["Company"].ToString();
                why.Add(workerHistory);
            }
            dr.Close();
            DBHelper.Closecon();
            return(why);
        }
コード例 #3
0
        public bool Transfer(int worker, int segmentStart, int segmentEnd, int targetWorker, int targetStart)
        {
            var newTicks = state.History.Workers[worker].Ticks.Take(segmentStart).ToList();

            while (newTicks.Count > startIndexes[worker] - 1 && !newTicks.Last().Wrapped)
            {
                newTicks.RemoveAt(newTicks.Count - 1);
            }

            var segment = state.History.Workers[worker].Ticks.Skip(segmentStart).Take(segmentEnd - segmentStart + 1).ToList();

            segmentEnd++;
            while (segmentEnd < state.History.Workers[worker].Ticks.Count && !state.History.Workers[worker].Ticks[segmentEnd].Wrapped)
            {
                segmentEnd++;
            }

            var wasTicks = newTicks.Count;

            newTicks.AddRange(state.History.Workers[worker].Ticks.Skip(segmentEnd));
            var beforeFix = newTicks.Count;

            FixStep(newTicks, wasTicks - 1);
            var afterFix = newTicks.Count;

            var newTargetTicks = newTicks;

            if (targetWorker == worker)
            {
                if (targetStart > wasTicks)
                {
                    targetStart += (afterFix - beforeFix - segmentEnd + wasTicks);
                }
            }
            else
            {
                newTargetTicks = state.History.Workers[targetWorker].Ticks.ToList();
            }

            newTargetTicks.InsertRange(targetStart, segment);
            FixStep(newTargetTicks, targetStart + segment.Count - 1);
            FixStep(newTargetTicks, targetStart - 1);

            if (targetWorker == worker)
            {
                if (state.History.Workers[worker].Ticks.Count <= newTicks.Count)
                {
                    return(false);
                }
            }
            else
            {
                if (state.History.Workers[worker].Ticks.Count <= newTicks.Count && state.History.Workers[targetWorker].Ticks.Count <= newTargetTicks.Count)
                {
                    return(false);
                }

                if (state.History.Workers[worker].Ticks.Count > newTicks.Count && state.History.Workers[targetWorker].Ticks.Count > newTargetTicks.Count)
                {
                }
                else if (state.History.Workers[worker].Ticks.Count > newTicks.Count || state.History.Workers[targetWorker].Ticks.Count > newTargetTicks.Count)
                {
                    if (state.History.Workers[worker].Ticks.Count == newTicks.Count || state.History.Workers[targetWorker].Ticks.Count == newTargetTicks.Count)
                    {
                    }
                    else
                    {
                        var www = state.History.Workers.ToList();
                        www[worker] = new WorkerHistory {
                            StartTick = www[worker].StartTick, Ticks = newTicks
                        };
                        www[targetWorker] = new WorkerHistory {
                            StartTick = www[targetWorker].StartTick, Ticks = newTargetTicks
                        };

                        var newHistory = new History
                        {
                            Workers = www
                        };

                        if (state.History.CalculateTime() <= newHistory.CalculateTime())
                        {
                            return(false);
                        }
                    }
                }
            }

            // Console.Out.WriteLine($"{worker}: [{segmentStart}-{segmentEnd}] ==> {targetWorker}: {targetStart}");
            // for (int i = 0; i < state.History.Workers.Count; i++)
            // {
            //     if (i == worker)
            //         Console.Out.WriteLine(
            //             $"  F {state.History.Workers[i].StartTick} + {state.History.Workers[i].Ticks.Count} = {state.History.Workers[i].StartTick + state.History.Workers[i].Ticks.Count}" +
            //             $" => {state.History.Workers[i].StartTick} + {newTicks.Count} = {state.History.Workers[i].StartTick + newTicks.Count}");
            //     else if (i == targetWorker)
            //         Console.Out.WriteLine(
            //             $"  F {state.History.Workers[i].StartTick} + {state.History.Workers[i].Ticks.Count} = {state.History.Workers[i].StartTick + state.History.Workers[i].Ticks.Count}" +
            //             $" => {state.History.Workers[i].StartTick} + {newTargetTicks.Count} = {state.History.Workers[i].StartTick + newTargetTicks.Count}");
            //     else
            //         Console.Out.WriteLine($"  - {state.History.Workers[i].StartTick} + {state.History.Workers[i].Ticks.Count} = {state.History.Workers[i].StartTick + state.History.Workers[i].Ticks.Count}");
            // }
            //
            // Console.Out.WriteLine();

            state.History.Workers[worker].Ticks       = newTicks;
            state.History.Workers[targetWorker].Ticks = newTargetTicks;
            return(true);
        }
コード例 #4
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                if (WorkerName.Text != null && cboSex.Text != null)
                {
                    string NewID  = Md5LockedUtil.MD5Encrypt32(WorkerID.Text.ToString());
                    string NewTel = Md5LockedUtil.MD5Encrypt32(WorkerTel.Text.ToString());

                    #region 员工信息添加代码块
                    Worker worker = new Worker
                    {
                        WorkerId        = WorkerNo.Text.Trim(),
                        WorkerName      = WorkerName.Text.Trim(),
                        WorkerBirthday  = dtpBirthday.Value,
                        WorkerSex       = (int)cboSex.SelectedValue,
                        WorkerNation    = cbWorkerNation.SelectedValue.ToString(),
                        WorkerTel       = NewTel,
                        WorkerClub      = cboClub.SelectedValue.ToString(),
                        WorkerAddress   = txtAddress.Text,
                        WorkerPosition  = cboWorkerPosition.SelectedValue.ToString(),
                        CardId          = NewID,
                        WorkerTime      = dtpTime.Value,
                        WorkerFace      = cboWorkerFace.Text,
                        WorkerEducation = cboEducation.SelectedValue.ToString(),
                        datains_usr     = AdminInfo.Account,
                        datains_date    = DateTime.Now
                    };
                    bool n = new WorkerService().AddWorker(worker);
                    #endregion

                    if (ucHistory.txtCompany != null && ucHistory.txtPosition != null && ucHistory.dtpStartDate.Value != null && ucHistory.dtpEndDate.Value != null)
                    {
                        #region 履历添加代码块
                        WorkerHistory workerHistory = new WorkerHistory
                        {
                            StartDate = ucHistory.dtpStartDate.Value,
                            EndDate   = ucHistory.dtpEndDate.Value,
                            Position  = ucHistory.txtPosition.Text,
                            Company   = ucHistory.txtCompany.Text,
                            WorkerId  = WorkerNo.Text.Trim()
                        };
                        bool j = new WorkerHistoryService().AddHistoryByWorkerId(workerHistory);
                        #endregion

                        #region 判断履历和信息代码块
                        if (n == true && j == true)
                        {
                            UIMessageBox.Show("员工信息/履历添加成功!该员工登录密码为:123456,请提醒员工妥善保管并首次登录系统时修改密码!");
                            FrmWorkerManager.Reload();
                            #region 获取添加操作日志所需的信息
                            OperationLog o = new OperationLog();
                            o.OperationTime    = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd,HH:mm:ss"));
                            o.Operationlog     = AdminInfo.Account + AdminInfo.Name + "于" + DateTime.Now + "进行了添加员工操作,员工编号为:" + WorkerNo.Text + "!";
                            o.OperationAccount = AdminInfo.Account + AdminInfo.Name;
                            o.datains_usr      = AdminInfo.Account;
                            o.datachg_date     = DateTime.Now;
                            new OperationlogService().InsertOperationLog(o);
                            #endregion
                        }
                        else
                        {
                            UIMessageBox.Show("员工信息/履历添加失败,请检查数据格式或稍后再试!");
                        }
                        #endregion
                    }
                }
                else
                {
                    UIMessageBox.Show("信息不能为空!");
                }
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.ToString());
                UIMessageBox.Show("服务器繁忙或数据格式为空!");
            }
            finally
            {
                this.Close();
            }
        }
コード例 #5
0
        public static int AddHistoryByWorkerId(WorkerHistory workerHistory, string wid)
        {
            string sql = "insert into WorkerHistory values('" + wid + "','" + workerHistory.StartDate + "','" + workerHistory.EndDate + "','" + workerHistory.Postion + "','" + workerHistory.Company + "')";

            return(DBHelper.ExecuteNonQuery(sql));
        }
コード例 #6
0
 public static int AddHistoryByWorkerId(WorkerHistory workerHistory, string wid)
 {
     return(WorkerHistoryService.AddHistoryByWorkerId(workerHistory, wid));
 }
コード例 #7
0
 public bool AddHistoryByWorkerId([FromBody] WorkerHistory workerHistory)
 {
     return(new WorkerHistoryService().AddHistoryByWorkerId(workerHistory));
 }