public ActionResult Remove(int workerId)
        {
            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    WorkerEntity worker = WorkerRepository.Instance.GetById(workerId);
                    worker.Status = GenericStatus.INACTIVE;
                    WorkerRepository.Instance.UpdateWorker(worker);
                    //WorkerRepository.Instance.RemoveWorker(worker.Id);

                    //AccountRepository.Instance.RemoveAccount(worker.UserId);

                    //PlayerEngineService.Instance.DeleteById(worker.ExternalId);
                    PlayerEngineDTO player = PlayerEngineService.Instance.GetById(worker.ExternalId);
                    player.Active = false;
                    PlayerEngineService.Instance.CreateOrUpdate(player);

                    scope.Complete();
                }
            }
            catch (Exception e)
            {
                Error("Ocorreu um erro ao remover.");
            }

            ViewBag.NumberOfWorkers = WorkerRepository.Instance.GetCountFromFirm(CurrentFirm.Id);

            return(View("Index"));
        }
        public bool UpdateInfo(WorkerEntity obj, string jobnumber)
        {
            con = Connectionsql.Connection();
            bool term = SelectMysql.result("update tb_zhigong set Password='******'," +
                                           "Name='" + obj.Name + "',Shenfenzhenghao='" + obj.Idnumber + "',Sex='" + obj.Sex + "',Address=" +
                                           "'" + obj.Address + "',Phone='" + obj.Phone + "'" +
                                           ",Birth='" + obj.Birth + "',Ruyongriqi='" + obj.Hiredate + "'where Gonghao='" + jobnumber + "'");

            try
            {
                if (term == true)
                {
                    return(term);
                }
            }
            catch (MySqlException e)
            {
                MessageBox.Show(e.Message, "提示", MessageBoxButtons.OK);
            }
            finally
            {
                con.Close();
            }

            return(term);
        }
Beispiel #3
0
        /// <summary>
        /// Maps source entity to target worker
        /// </summary>
        /// <param name="entity">Source entity</param>
        /// <returns>Target worker</returns>
        private Worker MapToWorker(WorkerEntity entity)
        {
            var worker = new Worker(this);

            MapToWorker(worker, entity);
            return(worker);
        }
Beispiel #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            string jobnumber = textBox1_GH.Text;
            string name      = textBox2_Name.Text;
            string sex       = comboBox1_Sex.Text;
            string workunit  = comboBox2_GZDW.Text;
            string birth     = dateTimePicker1.Text;
            string password  = textBox6_Pass.Text;
            string phone     = textBox7_Phone.Text;
            string address   = textBox8_Addr.Text;
            string idnumber  = textBox9_SFZH.Text;
            string hiredate  = dateTimePicker2.Text;

            WorkerEntity            worker           = new WorkerEntity(jobnumber, password, name, idnumber, sex, address, workunit, phone, birth, hiredate);
            IWorkerManageController manageController = new WorkerManageControllerImpl();
            bool term = manageController.InsertWorkerInfo(worker);

            if (term == true)
            {
                WorkerManage form = new WorkerManage();
                MessageBox.Show("添加职工信息成功!");
                this.DialogResult = DialogResult.OK;
                this.Hide();
            }
            else
            {
                MessageBox.Show("添加职工信息失败!");
            }
        }
Beispiel #5
0
        public void Create(WorkerEntity worker)
        {
            connection.Open();
            MySqlCommand command = new MySqlCommand(addString);

            MySqlParameter numberParam = new MySqlParameter("@passport_n", worker.PassportNumber);
            MySqlParameter dataParam   = new MySqlParameter("@passport_d", worker.PersonalData);

            command.Parameters.Add(numberParam);
            command.Parameters.Add(dataParam);
            command.Connection = connection;

            object obj = null;

            try
            {
                obj = command.ExecuteScalar();
            }
            finally
            {
                connection.Close();
            }
            int id = Convert.ToInt32(obj);

            worker.PassportNumber = id;
        }
        public List <WorkerEntity> GetDataFromDB(ProjectAllocationFramework.Statues.ProgressChangedEventHandler OnProgress, WorkerSearchCondtion searchCondition = null)
        {
            List <WorkerEntity> entityList = new List <WorkerEntity>();

            string    sql = "select WorkerCode, WorkerName FROM [Worker] WHERE 1=1 and WorkerCode like @WorkerCode and WorkerName like @WorkerName ORDER BY WorkerCode";
            DbCommand cmd = DatabaseUtil.GetCommand(db.GetSqlStringCommand(sql));

            string workerCode = string.Empty;
            string workerName = string.Empty;

            if (searchCondition != null)
            {
                workerCode = searchCondition.WorkerCode.Trim();
                workerName = searchCondition.WorkerName.Trim();
            }

            db.AddInParameter(cmd, "WorkerCode", DbType.String, '%' + workerCode + '%');
            db.AddInParameter(cmd, "WorkerName", DbType.String, '%' + workerName + '%');

            using (IDataReader reader = db.ExecuteReader(cmd))
            {
                while (reader.Read())
                {
                    WorkerEntity item = new WorkerEntity();
                    item.WorkerCode = ConvertUtil.ToString(reader["WorkerCode"]);
                    item.WorkerName = ConvertUtil.ToString(reader["WorkerName"]);
                    item.Action     = Constant.ACTION_UPDATE;
                    item.ReadOnly   = true;
                    //throw new Exception();
                    entityList.Add(item);
                }
            }
            return(entityList);
        }
Beispiel #7
0
        private void btnProjectLeader2_Click(object sender, EventArgs e)
        {
            string assemblyName = Path.Combine(Application.StartupPath, "Worker.dll");
            IEntry instance     = ApplicationDispatcher.GetInstance(assemblyName, new String[] { "" });
            Form   objForm      = instance.GetSearchDialog(null);

            if (objForm.ShowDialog() == DialogResult.OK)
            {
                var objForm1 = objForm as frmBase;
                if (objForm1 != null)
                {
                    foreach (DataGridViewRow item in objForm1.SelectedRows())
                    {
                        WorkerEntity entity = new WorkerEntity();
                        entity.WorkerCode = ConvertUtil.ToString(item.Cells["workerCodeColumn"].Value);
                        entity.WorkerName = ConvertUtil.ToString(item.Cells["workerNameColumn"].Value);

                        if (!string.IsNullOrEmpty(entity.WorkerCode))
                        {
                            this.txtProjectLeader2.Text = entity.WorkerName;
                            this.txtProjectLeader2.Tag  = entity.WorkerCode;
                            break;
                        }
                    }
                }
            }
        }
Beispiel #8
0
        public List <WorkerEntity> Read(int minPassportNumber = DefValInt, int maxPassportNumber = DefValInt, string PersonalData = null)
        {
            string stringWithWhere = CreateWherePartForReadQuery(minPassportNumber, maxPassportNumber, PersonalData);

            MySqlCommand command = new MySqlCommand(readString + stringWithWhere);

            command.Connection = connection;

            connection.Open();

            List <WorkerEntity> result = new List <WorkerEntity>();

            try
            {
                MySqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    object       passportNumber     = reader["PassportNumber"];
                    object       personalDataFromDb = reader["PersonalData"];
                    WorkerEntity worker             = new WorkerEntity
                    {
                        PassportNumber = System.Convert.ToInt32(passportNumber),
                        PersonalData   = System.Convert.ToString(personalDataFromDb),
                    };
                    result.Add(worker);
                }
            }
            finally
            {
                connection.Close();
            }
            return(result);
        }
        public bool InsertInfo(WorkerEntity obj)
        {
            con = Connectionsql.Connection();
            bool term = SelectMysql.result("insert into  tb_zhigong(Gonghao,Password,Name,Shenfenzhenghao,Sex,Address" +
                                           ",Gongzuodanwei,Phone,Birth,Ruyongriqi) values(" + "'" + obj.Jobnumber + "'" + "," + "'" + obj.Password + "'" + ","
                                           + "'" + obj.Name + "'" + "," + "'" + obj.Idnumber + "'" + "," + "'" + obj.Sex + "'" + "," + "'" + obj.Address +
                                           "'" + "," + "'" + obj.Workunit + "'" + "," + "'" + obj.Phone + "'" + "," + "'" + obj.Birth + "'" + "," + "'" + obj.Hiredate + "'" + ")");

            try
            {
                if (term == true)
                {
                    return(term);
                }
            }
            catch (MySqlException e)
            {
                MessageBox.Show(e.Message, "提示", MessageBoxButtons.OK);
            }
            finally
            {
                con.Close();
            }

            return(term);
        }
Beispiel #10
0
        private void button1_Click(object sender, EventArgs e)
        {
            login = new LoginControllerImpl();
            string jobnumber = textBox1.Text;
            string password  = textBox2.Text;
            string workunit  = comboBox1.Text;

            WorkerEntity obj   = new WorkerEntity(jobnumber, password, workunit);
            SalerManage  saler = new SalerManage(obj);

            login.JudgeNull(obj);

            bool term = login.VisitDatabase(obj);

            if (term == true)
            {
                login.JumpShow(obj);
                this.Hide();
                MessageBox.Show("登录成功");
            }
            else
            {
                MessageBox.Show("没有此用户!请重新输入!");
            }
        }
        //登录
        public bool VisitDatabase(WorkerEntity obj)
        {
            IWorkerDataService connect = new WorkerDataServiceImpl();
            bool term = connect.SelectInfo(obj);

            return(term);
        }
Beispiel #12
0
        static public void SetAllPlayersTrue()
        {
            //string gameId = CurrentFirm.ExternalId;

            GetAllDTO games = GameEngineService.Instance.GetAll(0, 10000, "*****@*****.**");

            foreach (GameEngineDTO game in games.List.game)
            {
                List <WorkerDTO> workers = WorkerRepository.Instance.GetWorkerDTOByExternalGameId(game.Id);
                string           errors  = "";

                foreach (WorkerDTO workerDTO in workers)
                {
                    try
                    {
                        PlayerEngineDTO player = PlayerEngineService.Instance.GetById(workerDTO.ExternalId, "*****@*****.**");
                        player.Active = true;
                        player.Role   = workerDTO.Role;
                        PlayerEngineService.Instance.CreateOrUpdate(player, "*****@*****.**");

                        WorkerEntity worker = WorkerRepository.Instance.GetById(workerDTO.IdWorker);
                        worker.Status = GenericStatus.ACTIVE;
                        WorkerRepository.Instance.UpdateWorker(worker);
                    }
                    catch (Exception e)
                    {
                        errors += workerDTO.Email + " -> " + e.Message + "<br/>";
                    }
                }
            }
        }
        //判断是否重复
        public bool Register(WorkerEntity obj)
        {
            IWorkerDataService connect = new WorkerDataServiceImpl();
            bool term = connect.SelectUniqueInfo(obj);

            return(term);
        }
 public void JumpShow(WorkerEntity obj)
 {
     if (obj.Workunit == "人事管理")
     {
         WorkerManage worker = new WorkerManage();
         worker.Show();
     }
     else if (obj.Workunit == "销售管理")
     {
         SaleManage saleManage = new SaleManage();
         saleManage.Show();
     }
     else if (obj.Workunit == "进货管理")
     {
         PurchaseManage purchase = new PurchaseManage();
         purchase.Show();
     }
     else if (obj.Workunit == "库存管理")
     {
         StockManage stockManage = new StockManage();
         stockManage.Show();
     }
     else if (obj.Workunit == "销售员")
     {
         SalerManage salerManage = new SalerManage(obj);
         salerManage.Show();
     }
 }
Beispiel #15
0
        private void button1_Click(object sender, EventArgs e)
        {
            register = new LoginControllerImpl();
            string       jobnumber = textBox1.Text;
            string       password  = textBox2.Text;
            string       workunit  = textBox3.Text;
            WorkerEntity obj       = new WorkerEntity(jobnumber, password, workunit);

            register.JudgeNull(obj);
            bool term  = false; //判断是否添加成功
            bool judge = false; //判断是否重复添加

            if (jobnumber != "" && password != "" && workunit != "")
            {
                term  = register.InsertDatabase(obj); //判断是否添加成功
                judge = register.Register(obj);       //判断是否重复添加
            }

            if (judge == true)
            {
                MessageBox.Show("用户已注册!");
            }
            else
            {
                if (term == true)
                {
                    MessageBox.Show("注册成功!");
                    Login login = new Login();
                    this.Hide();
                    login.Show();
                }
            }
        }
        //登录
        public bool SelectInfo(WorkerEntity obj)
        {
            bool term = false;

            con = Connectionsql.Connection();
            MySqlDataReader reader = SelectMysql.reader("select Gonghao,Password,Gongzuodanwei from tb_zhigong");

            try
            {
                while (reader.Read())
                {
                    if ((obj.Jobnumber == reader.GetString("Gonghao")) && (obj.Password == reader.GetString("Password")) && (obj.Workunit == reader.GetString("Gongzuodanwei")))
                    {
                        term = true;
                    }
                }
            }
            catch (MySqlException e)
            {
                MessageBox.Show(e.Message, "提示", MessageBoxButtons.OK);
            }
            finally
            {
                con.Close();
            }
            return(term);
        }
Beispiel #17
0
 public WorkerViewModel()
 {
     addWorker     = new AddWorker(this);
     UpdateWorker  = new UpdateWorker(this);
     DeleteWorker  = new DeleteWorker(this);
     CurrentWorker = new WorkerEntity();
     SelectWorker  = new WorkerEntity();
 }
        private AuthStatus LoginGeral(LoginViewModel model)
        {
            AuthResult result = new AuthResult();

            if (!ModelState.IsValid)
            {
                return(AuthStatus.ERROR);
            }

            result = AccountHandler.Login(new LoginRequest()
            {
                UserName    = model.Email,
                Password    = model.Password,
                TokenMobile = model.tokenMobile,
                Device      = model.tipoDispositivo
            });

            WorkerEntity worker = WorkerRepository.Instance.GetByUserId(result.UserId);

            if (result.AuthStatus == AuthStatus.OK)
            {
                var claims = new List <Claim>();
                claims.Add(new Claim(ClaimTypes.Sid, result.UserId.ToString()));
                claims.Add(new Claim(ClaimTypes.Name, result.UserId.ToString()));
                claims.Add(new Claim(ClaimTypes.Email, model.Email));
                claims.Add(new Claim(ClaimTypes.NameIdentifier, result.UserId.ToString()));
                claims.Add(new Claim("http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider", "http://vlast.com.br"));

                bool isSystemAdmin = false;
                foreach (var role in result.UserRoles)
                {
                    if (role == Roles.ADMINISTRATOR)
                    {
                        isSystemAdmin = true;
                    }

                    claims.Add(new Claim(ClaimTypes.Role, role.ToString()));
                }


                if (!isSystemAdmin)
                {
                    //WorkerEntity worker = WorkerRepository.Instance.GetByUserId(result.UserId);
                    WorkerTypeEntity profile = WorkerTypeRepository.Instance.GetById(worker.WorkerTypeId);
                    claims.Add(new Claim(ClaimTypes.Role, profile.ProfileName.ToString()));
                }

                var identity = new ClaimsIdentity(claims, DefaultAuthenticationTypes.ApplicationCookie);

                var ctx = Request.GetOwinContext();
                var authenticationManager = ctx.Authentication;
                authenticationManager.SignIn(identity);

                return(AuthStatus.OK);
            }

            return(AuthStatus.ERROR);
        }
Beispiel #19
0
 /// <summary>
 /// Maps source entity to target worker
 /// </summary>
 /// <param name="worker">Target worker</param>
 /// <param name="entity">Source entity</param>
 private void MapToWorker(Worker worker, WorkerEntity entity)
 {
     worker.Id          = (int)entity.Id;
     worker.Name        = entity.Name;
     worker.Surname     = entity.Surname;
     worker.Birthday    = entity.Birthday;
     worker.Sex         = (Sex)entity.Sex;
     worker.HasChildren = Convert.ToBoolean(entity.HasChildren);
 }
Beispiel #20
0
 /// <summary>
 /// Maps source worker to target entity
 /// </summary>
 /// <param name="worker">Source worker</param>
 /// <returns>Target entity</returns>
 private void MapToWorkerEntity(Worker worker, WorkerEntity entity)
 {
     entity.Id          = worker.Id;
     entity.Name        = worker.Name;
     entity.Surname     = worker.Surname;
     entity.Birthday    = worker.Birthday;
     entity.Sex         = (long)worker.Sex;
     entity.HasChildren = Convert.ToInt64(worker.HasChildren);
 }
Beispiel #21
0
        public void RegisterWorker(string workerId, string serverId, DbConnection connection, DbTransaction transaction = null)
        {
            var worker = new WorkerEntity()
            {
                Id     = workerId,
                Server = serverId
            };

            connection.Insert <WorkerEntity>(worker, transaction);
        }
Beispiel #22
0
        public SalerManage(WorkerEntity obj)
        {
            InitializeComponent();
            this.obj = obj;//显示时间
            this.toolStripStatusLabel3.Text = "登录时间:" + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
            //查询全部销售信息
            toolStripTextBox1.Text = obj.Name;
            DataTable data = saler.SelectSaleInfo(obj.Idnumber);

            this.dataGridView1.DataSource = data;
        }
Beispiel #23
0
        //修改
        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            DialogResult dialog = MessageBox.Show(this, "确定要修改此职工信息吗?", "提示",
                                                  MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (this.dataGridView1.SelectedRows.Count == 0)
            {
                MessageBox.Show("没有选中职工!");
                return;
            }

            WorkerEntity workerEntity = new WorkerEntity();

            if (dialog == DialogResult.Yes)
            {
                int i = this.dataGridView1.CurrentRow.Index;


                workerEntity.Jobnumber = dataGridView1.CurrentRow.Cells[0].Value.ToString();
                workerEntity.Password  = dataGridView1.Rows[i].Cells[1].Value.ToString();
                workerEntity.Name      = dataGridView1.Rows[i].Cells[2].Value.ToString();
                workerEntity.Idnumber  = dataGridView1.Rows[i].Cells[3].Value.ToString();
                workerEntity.Sex       = dataGridView1.Rows[i].Cells[4].Value.ToString();
                workerEntity.Address   = dataGridView1.Rows[i].Cells[5].Value.ToString();
                workerEntity.Workunit  = dataGridView1.Rows[i].Cells[6].Value.ToString();
                workerEntity.Phone     = dataGridView1.Rows[i].Cells[7].Value.ToString();
                workerEntity.Hiredate  = dataGridView1.Rows[i].Cells[8].Value.ToString();
                workerEntity.Birth     = dataGridView1.Rows[i].Cells[9].Value.ToString();

                UpdateWorker update = new UpdateWorker(workerEntity);
                DialogResult dt     = update.ShowDialog();

                if (dt == DialogResult.OK)
                {
                    workerEntity = update.Worker();
                    dataGridView1.CurrentRow.Cells[0].Value = workerEntity.Jobnumber;
                    dataGridView1.Rows[i].Cells[1].Value    = workerEntity.Password;
                    dataGridView1.Rows[i].Cells[2].Value    = workerEntity.Name;
                    dataGridView1.Rows[i].Cells[3].Value    = workerEntity.Idnumber;
                    dataGridView1.Rows[i].Cells[4].Value    = workerEntity.Sex;
                    dataGridView1.Rows[i].Cells[5].Value    = workerEntity.Address;
                    dataGridView1.Rows[i].Cells[6].Value    = workerEntity.Workunit;
                    dataGridView1.Rows[i].Cells[7].Value    = workerEntity.Phone;
                    dataGridView1.Rows[i].Cells[8].Value    = workerEntity.Hiredate;
                    dataGridView1.Rows[i].Cells[9].Value    = workerEntity.Birth;
                }
            }
            if (workerEntity == null)
            {
                MessageBox.Show("未选中职工!");
                return;
            }
        }
Beispiel #24
0
        private void button1_Click(object sender, EventArgs e)
        {
            WorkerEntity            entity           = Worker();
            IWorkerManageController manageController = new WorkerManageControllerImpl();
            bool term = manageController.UpdateWokerInfo(entity, jobnumber);

            if (term == true)
            {
                MessageBox.Show("修改职工信息成功!");
                this.DialogResult = DialogResult.OK;
                this.Hide();
            }
        }
Beispiel #25
0
        public UpdateWorker(WorkerEntity worker)
        {
            InitializeComponent();
            textBox1_GH.Text = worker.Jobnumber;

            textBox6_Pass.Text   = worker.Password;
            textBox2_Name.Text   = worker.Name;
            comboBox1_Sex.Text   = worker.Sex;
            textBox1.Text        = worker.Workunit;
            dateTimePicker1.Text = worker.Birth;
            textBox7_Phone.Text  = worker.Phone;
            textBox8_Addr.Text   = worker.Address;
            textBox9_SFZH.Text   = worker.Idnumber;
            dateTimePicker2.Text = worker.Hiredate;
        }
 public void JudgeNull(WorkerEntity obj)
 {
     if (obj.Jobnumber == "")
     {
         MessageBox.Show("用户名不能为空!");
     }
     else if (obj.Password == "")
     {
         MessageBox.Show("密码不能为空!");
     }
     else if (obj.Workunit == "")
     {
         MessageBox.Show("工作单位不能为空!");
     }
 }
        public void SaveResetsNewIdFlagAndSavesInStore()
        {
            WorkerEntity entity = null;

            _repository.Setup(r => r.Add(It.IsAny <WorkerEntity>())).Callback <WorkerEntity>(e => entity = e);

            var worker = _workerService.CreateNew();

            worker.Save();

            Assert.IsFalse(worker.IsNew);
            CollectionAssert.Contains(_workerService.GetWorkers().Select(w => w.Id), worker.Id);
            Assert.IsNotNull(entity);
            Assert.AreEqual(worker.Id, entity.Id);
        }
Beispiel #28
0
        public WorkerEntity Worker()
        {
            jobnumber = textBox1_GH.Text;
            name      = textBox2_Name.Text;
            sex       = comboBox1_Sex.Text;
            workunit  = textBox1.Text;
            birth     = dateTimePicker1.Text;
            password  = textBox6_Pass.Text;
            phone     = textBox7_Phone.Text;
            address   = textBox8_Addr.Text;
            idnumber  = textBox9_SFZH.Text;
            hiredate  = dateTimePicker2.Text;
            WorkerEntity entity = new WorkerEntity(jobnumber, password, name, idnumber, sex, address, workunit, phone, birth, hiredate);

            return(entity);
        }
Beispiel #29
0
        public void Delete(WorkerEntity worker)
        {
            connection.Open();
            MySqlCommand   command   = new MySqlCommand(deleteString);
            MySqlParameter parameter = new MySqlParameter("@passportNumber", worker.PassportNumber.ToString());

            command.Parameters.Add(parameter);
            command.Connection = connection;
            try
            {
                int delCount = command.ExecuteNonQuery();
            }
            finally
            {
                connection.Close();
            }
        }
Beispiel #30
0
        public void Update(WorkerEntity worker, string PersonalData = null)
        {
            connection.Open();

            string setString = CreateSetPartForUpdateQuery(PersonalData);

            MySqlCommand command = new MySqlCommand(updateString + setString + $" where PassportNumber = {worker.PassportNumber};");

            command.Connection = connection;
            try
            {
                int updateCount = command.ExecuteNonQuery();
            }
            finally
            {
                connection.Close();
            }
        }