private void btnSalvar_Click(object sender, EventArgs e) { OdontoADMDll.BLL.Orcamento o = null; OdontoADMDll.DAL.OrcamentoImageDAO oImageDAO = null; if (gridServicos.Rows.Count == 0) { MessageBox.Show("Adicione pelo menos um Serviço!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { // Salva Imagem string filePath = @"C:\Program Files\OdontoAdmin\OrcamentoImages\"; string fileName = IDOrcamento + "dentalMap.jpg"; Bitmap imageDentalMap = new Bitmap(pBoxTooths.Image); FileInfo fInfo = new FileInfo(filePath + fileName); FileStream fs = null; if (!fInfo.Exists) { fs = fInfo.Create(); imageDentalMap.Save(fs, System.Drawing.Imaging.ImageFormat.Jpeg); imageDentalMap.Dispose(); fs.Close(); fs.Dispose(); oImageDAO = new OdontoADMDll.DAL.OrcamentoImageDAO(); oImageDAO.SalvarNovaImagem(IDOrcamento, (filePath + fileName)); o = new OdontoADMDll.BLL.Orcamento(); int idImage = oImageDAO.GetLastImageID(); o.PacienteID = IDPaciente; o.ImagemID = idImage; o.DataOrcamento = DateTime.Now; o.Deletado = false; o.ValorTotal = decimal.Parse(lblValorTotalDt.Text); o.CriarNovoOrcamento(); } else { // Funcione fInfo.Delete(); fs = fInfo.Create(); imageDentalMap.Save(fs, System.Drawing.Imaging.ImageFormat.Jpeg); imageDentalMap.Dispose(); fs.Close(); fs.Dispose(); } // Verificar os Serviços Salvos MessageBox.Show("Orçamento Cadastrado com sucesso!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } }
public void listOrcamentos(int PacienteID) { DataTable dt = new DataTable(); o = new OdontoADMDll.BLL.Orcamento(); dt = o.ListarOrcamentosPorPaciente(IdPaciente); lboxOrcamentos.DisplayMember = "dataOrcamento"; lboxOrcamentos.ValueMember = "id"; lboxOrcamentos.DataSource = dt; }
public Orcamento(int ID, int IDOrc) { InitializeComponent(); FormatarGrid(); this.IDPaciente = ID; if (IDOrc != 0) { this.IDOrcamento = IDOrc; } else { oOrcamento = new OdontoADMDll.BLL.Orcamento(); lblDtOrcamento.Text = IDOrcamento.ToString(); listarServicos(); } }
private void btnCancelar_Click(object sender, EventArgs e) { IDPaciente = 0; // Verify that Orcamento was already saved OdontoADMDll.BLL.Orcamento o = new OdontoADMDll.BLL.Orcamento(); int idO = int.Parse(lblDtOrcamento.Text); o.OrcamentoID = idO; o = o.GetOrcamento(); if (o.ValorTotal == 0) { oServico = new OdontoADMDll.BLL.Servico(); oServico.ExcluirServicosPorOrcamento(idO); this.Close(); } else { this.Close(); } }
private void Orcamento_Load(object sender, EventArgs e) { oPaciente = new Paciente(); oOrcamento = new OdontoADMDll.BLL.Orcamento(); oPaciente = oPaciente.GetPaciente(IDPaciente, false); lblNomePaciente.Text = oPaciente.Nome; lblDtData.Text = DateTime.Now.ToShortDateString(); if (IDOrcamento != 0) { oOrcamento.OrcamentoID = IDOrcamento; oOrcamento = oOrcamento.GetOrcamento(); carregarOrcamento(oOrcamento); } else { this.IDOrcamento = oOrcamento.GetNextOrcamentoID(); lblDtOrcamento.Text = IDOrcamento.ToString(); loadImage(); btnImprimir.Visible = false; } }
private void carregarOrcamento(OdontoADMDll.BLL.Orcamento o) { lblValorTotalDt.Text = o.ValorTotal.ToString(); lblDtData.Text = DateTime.Parse(o.DataOrcamento.ToString()).ToShortDateString(); lblDtOrcamento.Text = o.OrcamentoID.ToString(); DataTable dt = new DataTable(); OdontoADMDll.BLL.Servico s = new OdontoADMDll.BLL.Servico(); dt = s.ListarServicosPorOrcamento(o.OrcamentoID); gridServicos.DataSource = dt; // Carregar Imagem string imageUrl = o.GetImagemPorOrcamento(o.OrcamentoID); FileStream fs = new FileStream(imageUrl, FileMode.Open); MyImagem = (Bitmap)Image.FromStream(fs); fs.Flush(); fs.Close(); loadImage(); }