private void btnDeletar_Click(object sender, EventArgs e) { if (dgvBaixa.SelectedRows.Count == 0) { MessageBox.Show("Nenhum envelope selecionado."); return; } //deseja realmente excluir? DialogResult resultado = MessageBox.Show("Tem certeza?", "Pergunta", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (resultado == DialogResult.No) { return; } //Pegar produto selecionado EnvelopeDTO envelopeSelecionado = (dgvBaixa.SelectedRows[0].DataBoundItem as EnvelopeDTO); EnvelopeControl envelopeControl = new EnvelopeControl(); string retorno = " "; retorno = envelopeControl.Excluir(envelopeSelecionado.IdEnvelope); try { int idCliente = Convert.ToInt32(retorno); MessageBox.Show("Envelope excluído com sucesso.", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information); AtualizarGrid(); } catch { MessageBox.Show("Não foi possível excluir." + retorno, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public string Alterar(EnvelopeDTO envelope) { try { DateTime dataInicio = Convert.ToDateTime(envelope.DataEntrada); envelope.DataEntrada = dataInicio.ToString("yyyy-MM-dd HH:mm:ss"); DateTime dataFim = Convert.ToDateTime(envelope.DataEntrega); envelope.DataEntrega = dataFim.ToString("yyyy-MM-dd HH:mm:ss"); AcessoDadosMySql acesso = new AcessoDadosMySql(); acesso.LimparParametros(); acesso.AdicionarParametros("spIdCliente", envelope.IdCliente); acesso.AdicionarParametros("spOS", envelope.IdEnvelope); acesso.AdicionarParametros("spBaixa", envelope.Baixa); acesso.AdicionarParametros("spObservacao", envelope.Observacao); acesso.AdicionarParametros("spPreco", envelope.Preco); acesso.AdicionarParametros("spSinal", envelope.Sinal); acesso.AdicionarParametros("spTotal", envelope.Total); acesso.AdicionarParametros("spNome", envelope.Nome); acesso.AdicionarParametros("spTelefone", envelope.Telefone); acesso.AdicionarParametros("spDataEntrega", envelope.DataEntrega); acesso.AdicionarParametros("spDataEntrada", envelope.DataEntrada); acesso.AdicionarParametros("spAtend", envelope.Atend); acesso.AdicionarParametros("spFormaPagamento", envelope.FormaPagamento); string id = acesso.ExecutarManipulacao(CommandType.StoredProcedure, "spEnvelopeAlterar").ToString(); return(id); } catch (Exception ex) { return(ex.Message); } }
public frmEnvelope(CRUD crud, EnvelopeDTO envelopeSelecionado, int codigo, int idPermissao = 0) { this.crud = crud; this.envelopeSelecionado = envelopeSelecionado; InitializeComponent(); dgvProdutos.AutoGenerateColumns = false; dgvClientesVip.AutoGenerateColumns = false; this.codigo = codigo; this.idPermissao = idPermissao; }
public EnvelopeColecao ConsultarTodos(string nome) { try { AcessoDadosMySql acessoMySql = new AcessoDadosMySql(); acessoMySql.LimparParametros(); acessoMySql.AdicionarParametros("spNome", nome); DataTable table = acessoMySql.ExecutarConsulta(CommandType.StoredProcedure, "spEnvelopeSelecionaPorNomeCliente"); EnvelopeColecao envelopes = new EnvelopeColecao(); foreach (DataRow linha in table.Rows) { EnvelopeDTO envelope = new EnvelopeDTO(); envelope.Atend = linha["atend"].ToString(); envelope.Baixa = Convert.ToBoolean(linha["baixa"]); envelope.IdEnvelope = Convert.ToInt32(linha["OS"]); if (linha["idCliente"].ToString() == null || linha["idCliente"].ToString() == "" || linha["idCliente"].ToString() == " ") { envelope.IdCliente = 0; } else { envelope.IdCliente = Convert.ToInt32(linha["idCliente"]); } envelope.Observacao = (linha["observacao"]).ToString(); envelope.Preco = Convert.ToDecimal(linha["preco"]); if (linha["sinal"].ToString() == null || linha["sinal"].ToString() == "" || linha["sinal"].ToString() == " ") { envelope.Sinal = 00.00M; } else { envelope.Sinal = Convert.ToDecimal(linha["sinal"]); } envelope.Total = Convert.ToDecimal(linha["total"]); envelope.Nome = (linha["nome"]).ToString(); envelope.Telefone = linha["telefone"].ToString(); envelope.DataEntrega = linha["dataEntrega"].ToString(); envelope.DataEntrada = linha["dataEntrada"].ToString(); envelope.FormaPagamento = linha["formaPagamento"].ToString(); envelopes.Add(envelope); } return(envelopes); } catch (Exception) { return(null); } }
private void btnAlterar_Click(object sender, EventArgs e) { if (dgvBaixa.SelectedRows.Count == 0) { MessageBox.Show("Nenhum envelope selecionado."); return; } EnvelopeDTO envelopeSelecionado = (dgvBaixa.SelectedRows[0].DataBoundItem as EnvelopeDTO); envelopeSelecionado.Baixa = true; frmEnvelope frmEnvelope = new frmEnvelope(CRUD.alterar, envelopeSelecionado, 0); if (frmEnvelope.ShowDialog() == DialogResult.Yes) { AtualizarGrid(); } //env.Alterar(envelopeSelecionado); }
private void btnDarBaixa_Click(object sender, EventArgs e) { if (dgvBaixa.SelectedRows.Count == 0) { MessageBox.Show("Nenhum envelope selecionado."); return; } EnvelopeDTO envelopeSelecionado = (dgvBaixa.SelectedRows[0].DataBoundItem as EnvelopeDTO); envelopeSelecionado.Baixa = true; string idBaixa = env.Alterar(envelopeSelecionado); try { int a = Convert.ToInt32(idBaixa); AtualizarGrid(); return; } catch (Exception) { MessageBox.Show("Não foi possivel dar baixa", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnImprimir_Click(object sender, EventArgs e) { if (!string.IsNullOrWhiteSpace(txbTotalTudo.Text) && !string.IsNullOrWhiteSpace(txbCliente.Text) && !string.IsNullOrWhiteSpace(txbTelefone.Text) && !string.IsNullOrWhiteSpace(txbValor.Text) && !string.IsNullOrWhiteSpace(txbOs.Text) && dgvProdutos.DataSource != null) { if (crud == CRUD.cadastrar) { //EnvelopeControl envelop = new EnvelopeControl(); EnvelopeDTO envelope = new EnvelopeDTO(); envelope.IdEnvelope = Convert.ToInt32(txbOs.Text); envelope.Baixa = false; if (!string.IsNullOrWhiteSpace(idCliente)) { envelope.IdCliente = Convert.ToInt32(idCliente); } else { envelope.IdCliente = 0; } envelope.Observacao = txbObservacao.Text; envelope.Preco = Convert.ToDecimal(txbValor.Text); if (!string.IsNullOrWhiteSpace(txbSinal.Text)) { envelope.Sinal = Convert.ToDecimal(txbSinal.Text); } else { envelope.Sinal = 00.00M; } envelope.Total = Convert.ToDecimal(txbTotalTudo.Text); envelope.Nome = txbCliente.Text; envelope.Telefone = txbTelefone.Text; envelope.DataEntrada = DateTime.Now.ToString(); envelope.DataEntrega = txbDataEntrega.Text; envelope.Atend = cbxAtend.Text; envelope.FormaPagamento = cbxFormaPagamento.Text; frmImprimir imprimir = new frmImprimir(envelope, lista); if (imprimir.ShowDialog() == DialogResult.Yes) { MessageBox.Show("Produto cadastrado com sucesso", "Sucesso", MessageBoxButtons.OK, MessageBoxIcon.Information); if (idPermissao == 3) { CriarPasta(); } ClearForm(); DialogResult = DialogResult.Yes; } else { MessageBox.Show("Erro ao Cadastrar ", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); DialogResult = DialogResult.No; } } if (crud == CRUD.alterar) { EnvelopeControl env = new EnvelopeControl(); GestaoProdutoControl produtoControl = new GestaoProdutoControl(); EnvelopeDTO envelope = new EnvelopeDTO(); envelope.IdEnvelope = Convert.ToInt32(txbOs.Text); envelope.Baixa = envelopeSelecionado.Baixa; if (!string.IsNullOrWhiteSpace(idCliente)) { envelope.IdCliente = Convert.ToInt32(idCliente); } else { envelope.IdCliente = 0; } envelope.Observacao = txbObservacao.Text; envelope.Preco = Convert.ToDecimal(txbValor.Text); if (!string.IsNullOrWhiteSpace(txbSinal.Text)) { envelope.Sinal = Convert.ToDecimal(txbSinal.Text); } else { envelope.Sinal = 00.00M; } envelope.Total = Convert.ToDecimal(txbTotalTudo.Text); envelope.Nome = txbCliente.Text; envelope.Telefone = txbTelefone.Text; envelope.DataEntrada = lblDataAtual.Text; envelope.DataEntrega = txbDataEntrega.Text; envelope.Atend = cbxAtend.Text; envelope.FormaPagamento = cbxFormaPagamento.Text; string[] metodos = new string[3]; metodos[0] = env.LimparProdutos(envelope.IdEnvelope); metodos[1] = produtoControl.InserirProdutoEmEnvelope(envelope.IdEnvelope.ToString(), lista); metodos[2] = env.Alterar(envelope); if (metodos[1] == "") { metodos[1] = "0"; } try { //Verifica se algum processo deu erro for (int i = 0; i < metodos.Count(); i++) { int idAlterar = Convert.ToInt32(metodos[i]); } MessageBox.Show("Alteração efetuada com sucesso", "Sucesso", MessageBoxButtons.OK, MessageBoxIcon.Information); DialogResult = DialogResult.Yes; } catch (Exception) { MessageBox.Show("Não foi possível alterar envelope selecionado", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); DialogResult = DialogResult.No; } } } else { MessageBox.Show("Preencha todos os campos obrigatórios primeiro", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// A method that accepts as input the language of the request, a semester /// and a page number, and returns the course instances that appear /// on said page in the given language (given that the page number was valid). /// </summary> /// <param name="requestLanguage">The language of the request (i.e. "is" or "en")</param> /// <param name="semester">The query semester</param> /// <param name="page">1-based index of the requested page.</param> /// <returns>An envelope containing both our data (the courses) /// and the paging information</returns> public EnvelopeDTO<CourseInstanceDTO> GetCourseInstancesBySemester(string requestLanguage, string semester = null, int page = 1) { const string ICELANDIC = "is"; const string DEFAULT_SEMESTER = "20153"; const int PAGECOUNT = 10; if (string.IsNullOrEmpty(semester)) { semester = DEFAULT_SEMESTER; } var pageCoursesList = new List<CourseInstanceDTO>(); var allCoursesList = new List<CourseInstanceDTO>(); var allCourses = (from c in _courseInstances.All() join ct in _courseTemplates.All() on c.CourseID equals ct.CourseID where c.SemesterID == semester select new CourseInstanceDTO { Name = (requestLanguage == ICELANDIC ? ct.Name : ct.NameEN), TemplateID = ct.CourseID, CourseInstanceID = c.ID, MainTeacher = "" }); allCoursesList = allCourses.ToList(); // If the page requested is a number less than 1, // we want pageCourseList to be empty and // simply return an empty page. if (page > 0) { pageCoursesList = allCourses.OrderBy(c => c.CourseInstanceID).Skip((page - 1) * PAGECOUNT).Take(PAGECOUNT).ToList(); } EnvelopeDTO<CourseInstanceDTO> envelope = new EnvelopeDTO<CourseInstanceDTO>(pageCoursesList, page, PAGECOUNT, allCoursesList.Count); return envelope; }
public frmImprimir(EnvelopeDTO envelope) { InitializeComponent(); this.envelope = envelope; }
public frmImprimir(EnvelopeDTO envelope, List <Produto> produtos) { InitializeComponent(); this.envelope = envelope; this.produtos = produtos; }