示例#1
0
 public void AlterarDataEntrega(PedidoNutricao pedNutri)
 {
     if (pedNutri.Pn_dataentrega.Year.ToString() != "1")
     {
         Connection.Execute("update pedidonutricao set pn_dataentrega = @pn_dataentrega where pn_cod = @pn_cod", pedNutri);
     }
     else
     {
         Connection.Execute("update pedidonutricao set pn_dataentrega = null where pn_cod = @pn_cod", pedNutri);
     }
 }
示例#2
0
 private void btn_nEntregue_Click(object sender, EventArgs e)
 {
     if (DialogResult.Yes == MessageBox.Show("Deseja marcar como Não Entregue?", "Confirmação", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2))
     {
         PedidoNutricao p = new PedidoNutricao
         {
             Pn_cod = (int)dataGridView1.CurrentRow.Cells[0].Value,
         };
         dataGridView1.CurrentRow.Cells[2].Value = null;
         PedidoNutricaoRepository.AlterarDataEntrega(p);
         //LimparTudo();
         MessageBox.Show("Alterado Com Sucesso");
     }
 }
示例#3
0
 private void BtnSelecionarCid_Click(object sender, EventArgs e)
 {
     try
     {
         pedNutri = DgvPedNutri.CurrentRow?.DataBoundItem as PedidoNutricao;
         if (DgvPedNutri.CurrentRow != null)
         {
             DialogResult = DialogResult.OK;
             Close();
         }
     }
     catch (Exception erro)
     {
         MessageBox.Show(erro.Message, "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
        private void btn_gravar_Click(object sender, EventArgs e)
        {
            PedidoNutricao pedNutri = new PedidoNutricao();

            if (txt_idCli.Text != "")
            {
                pedNutri.Cliente = ClienteRepository.Get(Convert.ToInt32(txt_idCli.Text));
                if (cbb_Fazenda.Items.Count > 0)
                {
                    pedNutri.Fazenda            = FazendaRepository.GetByNome(cbb_Fazenda.SelectedItem.ToString()).First();
                    pedNutri.Pn_data            = DateTime.Now;
                    pedNutri.Pn_obs             = txt_obs.Text;
                    pedNutri.Pn_valortotal      = Convert.ToDecimal(txt_valorTotal.Text);
                    pedNutri.Pn_previsaoentrega = dataE.Value.Date;
                    if (mask_telefone.Text.Length == 15)
                    {
                        pedNutri.Pn_contato = mask_telefone.Text.Replace("(", "").Replace(")", "").Replace(" ", "").Replace("-", "");
                        if (mask_porcentagem.Text != null)
                        {
                            pedNutri.Pn_porcentagem = Convert.ToInt32(mask_porcentagem.Text);
                            pedNutri.Pn_formapgto   = Convert.ToInt32(cbb_FormaPgto.SelectedItem.ToString());

                            if (txt_codPedido.Text != "")
                            {
                                PedidoNutricaoRepository.DeletaProdutosPedido(Convert.ToInt32(txt_codPedido.Text));
                                pedNutri.Pn_cod = Convert.ToInt32(txt_codPedido.Text);
                            }

                            PedidoNutricaoRepository.GravarPedido(pedNutri);
                            txt_codPedido.Text = pedNutri.Pn_cod.ToString();


                            foreach (var item in prodPedNutriList)
                            {
                                item.PedidoNutricao = pedNutri;
                                PedidoNutricaoRepository.GravarProdutoPedido(item);
                            }
                            MessageBox.Show("Gravado com Sucesso!");
                            GerarExcel(pedNutri);
                            LimparTudo();
                        }
                    }
                }
            }
        }
示例#5
0
        private void btn_gravar_Click(object sender, EventArgs e)//marcar como entregue
        {
            DateTime dataPedido = Convert.ToDateTime(dataGridView1.CurrentRow.Cells[5].Value);
            var      ok         = new view_DataEntrega(dataPedido);

            if (ok.ShowDialog() == DialogResult.OK)
            {
                PedidoNutricao p = new PedidoNutricao
                {
                    Pn_cod         = (int)dataGridView1.CurrentRow.Cells[0].Value,
                    Pn_dataentrega = ok.dataEntrega
                };
                dataGridView1.CurrentRow.Cells[2].Value = p.Pn_dataentrega;
                PedidoNutricaoRepository.AlterarDataEntrega(p);
                //LimparTudo();
                MessageBox.Show("Alterado Com Sucesso");
            }
        }
示例#6
0
 public void GravarPedido(PedidoNutricao pedNutri)
 {
     if (pedNutri.Pn_cod == null)
     {
         Connection.Execute("INSERT INTO pedidonutricao " +
                            "(pn_previsaoentrega, pn_dataentrega, pn_porcentagem, pn_contato, " +
                            "pn_valortotal, pn_data, pn_obs, faz_cod, cli_cod, user_cod, pn_formapgto) " +
                            "VALUES(@pn_previsaoentrega, null, @pn_porcentagem, " +
                            "@pn_contato, @pn_valortotal, @pn_data, @pn_obs, @faz_cod, " +
                            "@cli_cod, @user_cod, @pn_formapgto)", pedNutri);
         pedNutri.Pn_cod = Convert.ToInt32(Connection.ExecuteScalar("select last_insert_id()"));
     }
     else
     {
         Connection.Execute("UPDATE pedidonutricao SET " +
                            "pn_previsaoentrega = @pn_previsaoentrega, pn_dataentrega = @pn_dataentrega, " +
                            "pn_porcentagem = @pn_porcentagem, pn_contato = @pn_contato, pn_valortotal = @pn_valortotal, " +
                            "pn_data = @pn_data, pn_obs = @pn_obs, faz_cod = @faz_cod, cli_cod = @cli_cod, user_cod = @user_cod, pn_formapgto = @pn_formapgto " +
                            "WHERE pn_cod = @pn_cod; ", pedNutri);
     }
 }
        public void GerarExcel(PedidoNutricao pedNutri)
        {
            var package  = new ExcelPackage();
            var workbook = package.Workbook;
            var sheet    = workbook.Worksheets.Add("Pedido");

            {
                sheet.Cells.Style.Font.Name           = "Times New Roman";
                sheet.Cells.Style.Font.Size           = 12;
                sheet.Cells["I3"].Style.WrapText      = true;
                sheet.Cells.Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Left;
            }

            {
                sheet.Cells["A1"].Value                     = "Informações do Pedido";
                sheet.Cells["A1"].Style.Font.Bold           = true;
                sheet.Cells["A1"].Style.Font.Size           = 26;
                sheet.Cells["A1"].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
                sheet.Cells["A1"].Style.VerticalAlignment   = OfficeOpenXml.Style.ExcelVerticalAlignment.Center;
                sheet.Cells["A1:J1"].Merge                  = true;

                sheet.Cells["A2:J2"].Style.Font.Bold = true;

                sheet.Cells[2, 1].Value  = "Código";
                sheet.Cells[2, 2].Value  = "Nome do Cliente";
                sheet.Cells[2, 3].Value  = "Fazenda do Cliente";
                sheet.Cells[2, 4].Value  = "Data do Pedido";
                sheet.Cells[2, 5].Value  = "Previsão de Entrega";
                sheet.Cells[2, 6].Value  = "Contato";
                sheet.Cells[2, 7].Value  = "Valor Total";
                sheet.Cells[2, 8].Value  = "Porcentagem ";
                sheet.Cells[2, 9].Value  = "Observação";
                sheet.Cells[2, 10].Value = "Forma de Pagamento";

                sheet.Cells[3, 1].Value  = pedNutri.Pn_cod;
                sheet.Cells[3, 2].Value  = pedNutri.ClienteNome;
                sheet.Cells[3, 3].Value  = pedNutri.FazendaNome;
                sheet.Cells[3, 4].Value  = pedNutri.Pn_data;
                sheet.Cells[3, 5].Value  = pedNutri.Pn_previsaoentrega.Date.ToShortDateString();
                sheet.Cells[3, 6].Value  = Convert.ToInt64(pedNutri.Pn_contato);
                sheet.Cells[3, 7].Value  = pedNutri.Pn_valortotal;
                sheet.Cells[3, 8].Value  = pedNutri.Pn_porcentagem / 100;
                sheet.Cells[3, 9].Value  = pedNutri.Pn_obs;
                sheet.Cells[3, 10].Value = pedNutri.Pn_formapgto + " Dias";

                using (ExcelRange Rng = sheet.Cells["A2:J3"])
                {
                    ExcelTable table = sheet.Tables.Add(Rng, "infoPedido");
                    table.TableStyle = TableStyles.Dark2;
                    table.ShowHeader = true;
                    table.ShowFilter = false;
                }
            }

            {
                sheet.Cells["A5"].Value                     = "Informações Produto do Pedido";
                sheet.Cells["A5"].Style.Font.Bold           = true;
                sheet.Cells["A5"].Style.Font.Size           = 24;
                sheet.Cells["A5"].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
                sheet.Cells["A5"].Style.VerticalAlignment   = OfficeOpenXml.Style.ExcelVerticalAlignment.Center;
                sheet.Cells["A5:D5"].Merge                  = true;

                sheet.Cells[6, 1].Value = "Produto";
                sheet.Cells[6, 2].Value = "Quantidade";
                sheet.Cells[6, 3].Value = "Peso";
                sheet.Cells[6, 4].Value = "Valor Final do Produto";

                for (int i = 0, l = 7; i < prodPedNutriList.Count; i++, l++)
                {
                    sheet.Cells[l, 1].Value = prodPedNutriList[i].NomeProd;
                    sheet.Cells[l, 2].Value = prodPedNutriList[i].Ppn_quantidade + " Sacos";
                    sheet.Cells[l, 3].Value = prodPedNutriList[i].Ppn_peso + "Kg";
                    sheet.Cells[l, 4].Value = prodPedNutriList[i].Ppn_valorvenda;
                }

                string p = "A6:D" + (prodPedNutriList.Count + 6);
                using (ExcelRange Rng = sheet.Cells[p])
                {
                    ExcelTable table2 = sheet.Tables.Add(Rng, "infoProduto");
                    table2.TableStyle = TableStyles.Dark2;
                    table2.ShowHeader = true;
                    table2.ShowFilter = false;
                }
            }

            {
                //Image img = Image.FromFile(@".\logomarca.png");
                sheet.Cells["F3"].Style.Numberformat.Format    = "0";
                sheet.Cells["H3"].Style.Numberformat.Format    = "0%";
                sheet.Cells["D3"].Style.Numberformat.Format    = "dd/MM/yyyy HH:mm";
                sheet.Cells["D7:D9"].Style.Numberformat.Format = "R$ #,##0.00";
                sheet.Cells["G3"].Style.Numberformat.Format    = "R$ #,##0.00";

                sheet.Cells[sheet.Dimension.Address].AutoFitColumns();
                sheet.Column(9).Width = 32;

                {
                    string c = AppDomain.CurrentDomain.BaseDirectory;
                    c = c.Remove(c.Length - 10) + "Imagens\\";
                    Image        img = Image.FromFile(c + "banner.png");
                    ExcelPicture pic = sheet.Drawings.AddPicture("Picture_Name", img);
                    pic.SetPosition(4, 0, 5, 0);
                    pic.SetSize(36);
                }

                string caminho = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\Pedido_" + pedNutri.ClienteNome + "_" + pedNutri.Pn_cod + ".xlsx";
                package.SaveAs(new FileInfo(caminho));
                MessageBox.Show("Excel Gerado na Pasta de Documentos!");
            }
        }