public void SaveTerc(string name, string Cnpj, DateTime Inicio, DateTime Final) { if (name == string.Empty || Cnpj == string.Empty) { MessageBox.Show("FALHA,PREENCHA OS CAMPOS!", "TOPMOVIE - ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); Clear = false; } else { TerceirizadoDatabase save = new TerceirizadoDatabase(); // Salvar Parceiro DTOTerceirizado TerceiroDTO = new DTOTerceirizado(); TerceiroDTO.NomeEmpresa = name; TerceiroDTO.Cnpj = Cnpj; TerceiroDTO.Inicio = Inicio; TerceiroDTO.Final = Final; save.SaveTerc(TerceiroDTO); MessageBox.Show("TERCEIRIZADA SALVA COM SUCESSO!", "TOPMOVIE", MessageBoxButtons.OK, MessageBoxIcon.Information); Clear = true; } }
public void Alterar(int id, string nome, string cnpj, DateTime inicio, DateTime fim) { if ((nome == string.Empty || cnpj == string.Empty)) { MessageBox.Show("FALHA,PREENCHA OS CAMPOS!", "TOPMOVIE - ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); Clear = false; } else { CrudDataBase AttDb = new CrudDataBase(); // Salvar o usuário DTOTerceirizado terceirizadosDTO = new DTOTerceirizado(); terceirizadosDTO.IdTerc = id; terceirizadosDTO.NomeEmpresa = nome; terceirizadosDTO.Cnpj = cnpj; terceirizadosDTO.Inicio = inicio; terceirizadosDTO.Final = inicio; AttDb.UpadateTerc(terceirizadosDTO); MessageBox.Show("NOVA ATUALIZAÇÃO REALIZADA!", "TOPMOVIE", MessageBoxButtons.OK, MessageBoxIcon.Information); Clear = true; } }
public void SaveTerc(DTOTerceirizado terceiro) { string query = "insert into tb_terceirizado(id_terc, nm_empresa, ds_cnpj, dt_inicio, dt_final) values(@id_terc, @nm_empresa, @ds_cnpj, @dt_inicio, @dt_final)"; List <MySqlParameter> parameters = new List <MySqlParameter>(); parameters.Add(new MySqlParameter("id_terc", terceiro.IdTerc)); parameters.Add(new MySqlParameter("nm_empresa", terceiro.NomeEmpresa)); parameters.Add(new MySqlParameter("ds_cnpj", terceiro.Cnpj)); parameters.Add(new MySqlParameter("dt_inicio", terceiro.Inicio.ToString("yyyy-MM-dd"))); parameters.Add(new MySqlParameter("dt_final", terceiro.Final.ToString("yyyy-MM-dd"))); ProjetoDataBase terceirizado = new ProjetoDataBase(); terceirizado.ExecuteInsertInt(query, parameters); }
public void UpadateTerc(DTOTerceirizado terceirizadas) { string query = "UPDATE tb_terceirizado SET nm_empresa = @nm_empresa, ds_cnpj = @ds_cnpj, dt_inicio = @dt_inicio, dt_final = @dt_final WHERE id_terc = @id_terc"; List <MySqlParameter> parameters = new List <MySqlParameter>(); parameters.Add(new MySqlParameter("nm_empresa", terceirizadas.NomeEmpresa)); parameters.Add(new MySqlParameter("ds_cnpj", terceirizadas.Cnpj)); parameters.Add(new MySqlParameter("dt_inicio", terceirizadas.Inicio)); parameters.Add(new MySqlParameter("dt_final", terceirizadas.Final)); parameters.Add(new MySqlParameter("id_terc", terceirizadas.IdTerc)); ProjetoDataBase database = new ProjetoDataBase(); database.ExecuteInsertParamters(query, parameters); }
private void lstTerc_SelectedIndexChanged(object sender, EventArgs e) { try { ChamarComplementoTerc c = new ChamarComplementoTerc(); DTOTerceirizado tc = lstTerc.SelectedItem as DTOTerceirizado; c.BuscaUser(tc.IdTerc); txtCnpj.Text = c.Cnpj; txtNomeEmpresa.Text = c.Nome; dtpInicio.Value = c.Comeco; dtpFinal.Value = c.Fim; } catch { MessageBox.Show("OCORREU UM ERRO!", "TOPMOVIE - ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnDeletar_Click(object sender, EventArgs e) { try { DeleteBusiness dbs = new DeleteBusiness(); DTOTerceirizado tercs = lstTerc.SelectedItem as DTOTerceirizado; DialogResult = MessageBox.Show("TEM CERTEZA QUE IRÁ REALIZAR TAL AÇÃO?", "TOPMOVIE", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation); if (DialogResult == DialogResult.OK) { dbs.DeleteTerc(tercs.IdTerc); frmRemoverTerceirizado x = new frmRemoverTerceirizado(); x.Show(); this.Close(); } } catch (Exception) { MessageBox.Show("OCORREU UM ERRO!", "TOPMOVIE - ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public List <DTOTerceirizado> ListarTerceiros() { string query = "Select * from tb_terceirizado"; ProjetoDataBase database = new ProjetoDataBase(); MySqlDataReader reader = database.ExecuteSelect(query); List <DTOTerceirizado> itens = new List <DTOTerceirizado>(); while (reader.Read()) { DTOTerceirizado terc = new DTOTerceirizado(); terc.IdTerc = reader.GetInt32("id_terc"); terc.NomeEmpresa = reader.GetString("nm_empresa"); terc.Cnpj = reader.GetString("ds_cnpj"); terc.Inicio = reader.GetDateTime("dt_inicio"); terc.Final = reader.GetDateTime("dt_final"); itens.Add(terc); } reader.Close(); return(itens); }
private void btnCadastrar_Click(object sender, EventArgs e) { try { AtualizarTerceirizadas nv = new AtualizarTerceirizadas(); DTOTerceirizado terc = lstTerc.SelectedItem as DTOTerceirizado; nv.Alterar(terc.IdTerc, txtNomeEmpresa.Text, txtCnpj.Text, dtpInicio.Value, dtpFinal.Value); if (nv.Clear == true) { frmAlterarTerceirizados cd = new frmAlterarTerceirizados(); cd.Show(); this.Close(); } } catch (Exception) { MessageBox.Show("OCORREU UM PROBLEMA!ESTÁ TUDO CORRETAMENTE PREENCHIDO?", "TOPMOVIE - ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }