Exemplo n.º 1
0
 private void metroLink2_Click(object sender, EventArgs e)
 {
     if (metroGrid1.SelectedRows.Count > 0)
     {
         var          currentEmployee = _appEmployee.GetEmployee(idUser: User.Id);
         DialogResult result;
         if (currentEmployee.Name == RowView["EmployeeName"].ToString())
         {
             result = MetroMessageBox.Show(this, $"Tem certeza que deseja excluir seu próprio cadastro? \n Atenção isso resultará na sua desconexão", "", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, 150);
         }
         else
         {
             result = MetroMessageBox.Show(this, $"Tem certeza que deseja excluir o funcionário {RowView["EmployeeName"].ToString()}?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, 150);
         }
         if (result == DialogResult.Yes)
         {
             var deleteEmployee = (DataRowView)metroGrid1.Rows[metroGrid1.SelectedRows[0].Index].DataBoundItem;
             var employee       = _appEmployee.GetEmployee(employeeName: deleteEmployee["EmployeeName"].ToString());
             _appEmployee.Delete(employee.Name);
             var user = _appUser.GetUser(id: employee.idUser);
             _appUser.Delete(user.Name);
             if (currentEmployee.Name == RowView["EmployeeName"].ToString())
             {
                 MetroMessageBox.Show(this, "Seu usuário foi deletado", "", MessageBoxButtons.OK, MessageBoxIcon.Warning, 100);
                 Cars form = new Cars();
                 form.ShowDialog();
                 this.Close();
             }
             else
             {
                 MetroMessageBox.Show(this, "Funcionário deletado", "", MessageBoxButtons.OK, MessageBoxIcon.Question, 100);
                 Funcionarios_Load(this, new EventArgs());
             }
         }
     }
 }
Exemplo n.º 2
0
        private void metroLink3_Click(object sender, EventArgs e)
        {
            if (RowView != null)
            {
                RentDetails form = new RentDetails(this.StyleManager);
                form.Rent.Id = int.Parse(RowView["Id Aluguel"].ToString());
                Database.DBCar    _appCar    = new Database.DBCar();
                Database.DBClient _appClient = new Database.DBClient();
                var car = _appCar.GetCar(branch: RowView["Marca"].ToString(), model: RowView["Modelo"].ToString(), color: RowView["Cor"].ToString(), year: RowView["Ano"].ToString());
                form.Rent.idCar = car.Id;
                if (RowView["Funcionario"].ToString() != "")
                {
                    Database.DBEmployee _appEmployee = new Database.DBEmployee();
                    form.Rent.idEmployee = _appEmployee.GetEmployee(employeeName: RowView["Funcionario"].ToString()).Id;
                }
                form.Rent.idClient    = (_appClient.GetClientByName(RowView["Cliente"].ToString())).Id;
                form.Rent.PickUpDate  = DateTime.Parse(RowView["Retirada"].ToString());
                form.Rent.DropOffDate = DateTime.Parse(RowView["Devolução"].ToString());
                form.Rent.Value       = double.Parse(RowView["Valor"].ToString().Replace("R$", ""));
                switch (RowView["Tipo Pagamento"].ToString())
                {
                case "1":
                    form.Rent.PaymentType = Domain.Entities.PaymentTypeEnum.Billet;
                    break;

                case "2":
                    form.Rent.PaymentType = Domain.Entities.PaymentTypeEnum.Money;
                    break;

                case "3":
                    form.Rent.PaymentType = Domain.Entities.PaymentTypeEnum.Card;
                    break;
                }
                form.ShowDialog();
            }
            else
            {
                MetroMessageBox.Show(this, "Selecione a linha que deseja editar", "", MessageBoxButtons.OK, MessageBoxIcon.Warning, 100);
            }
        }
Exemplo n.º 3
0
 private Domain.Entities.Employee Load_Employee()
 {
     Database.DBEmployee _appEmployee = new Database.DBEmployee();
     return(_appEmployee.GetEmployee(idEmployee: Rent.idEmployee));
 }