private void txtCep_Leave(object sender, EventArgs e)
        {
            string lZipCode = txtCep.Text.Replace("-", string.Empty);

            if (lZipCode != string.Empty && lZipCode.Length == 8)
            {
                try
                {
                    using (var ws = new WSCorreios.AtendeClienteClient())
                    {
                        var result = ws.consultaCEP(lZipCode);
                        txtState.Text    = result.uf;
                        txtCity.Text     = result.cidade;
                        txtDistrict.Text = result.bairro;
                        txtStreet.Text   = result.end;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    errorQuery lerrorQuery = new errorQuery();
                    lerrorQuery.AddError(Principal.lUser, Errors.lZipCodeInvalid, ex.Message.Replace("'", ""), DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"), "Cadastro Cliente");
                }
            }
            else
            {
                MessageBox.Show(Errors.lZipCodeInvalid);
            }
        }
        private void ExportExcel()
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter   = "Excel Documents (*.xls)|*.xls";
            sfd.FileName = "Clientes_" + DateTime.Now.ToString("dd-MM-yyyy");
            if (sfd.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    // Copy DataGridView results to clipboard
                    copyAlltoClipboard();

                    object misValue = System.Reflection.Missing.Value;
                    Microsoft.Office.Interop.Excel.Application xlexcel = new Microsoft.Office.Interop.Excel.Application();

                    xlexcel.DisplayAlerts = false; // Without this you will get two confirm overwrite prompts
                    Workbook  xlWorkBook  = xlexcel.Workbooks.Add(misValue);
                    Worksheet xlWorkSheet = (Worksheet)xlWorkBook.Worksheets.get_Item(1);

                    // Paste clipboard results to worksheet range
                    Range CR = (Range)xlWorkSheet.Cells[1, 1];
                    CR.Select();

                    xlWorkSheet.PasteSpecial(CR, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, true);
                    xlWorkSheet.Rows.AutoFit();
                    xlWorkSheet.Columns.AutoFit();

                    // Delete blank column A and select cell A1
                    Range delRng = xlWorkSheet.get_Range("A:A").Cells;
                    delRng.Delete(Type.Missing);
                    xlWorkSheet.get_Range("A1").Select();

                    // Save the excel file under the captured location from the SaveFileDialog
                    xlWorkBook.SaveAs(sfd.FileName, XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);
                    xlexcel.DisplayAlerts = true;
                    xlWorkBook.Close(true, misValue, misValue);
                    xlexcel.Quit();

                    releaseObject(xlWorkSheet);
                    releaseObject(xlWorkBook);
                    releaseObject(xlexcel);

                    // Clear Clipboard and DataGridView selection
                    Clipboard.Clear();
                    dataGridView1.ClearSelection();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, MessageBoxResult.lExportError);
                    errorQuery lerrorQuery = new errorQuery();
                    lerrorQuery.AddError(Principal.lUser, MessageBoxResult.lExportError, ex.Message.Replace("'", ""), DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"), "Cadastro Funcionario");
                }
            }
        }
Beispiel #3
0
        //Cliente cliente = new Cliente();

        private void button1_Click(object sender, EventArgs e)
        {
            MySqlConnection con = new MySqlConnection(Connection.lConnection);

            con.Open();

            string       consulta = "SELECT empUsername,empPassword,empName FROM employee WHERE empDocument = @cpf";
            MySqlCommand cmd      = new MySqlCommand(consulta, con);

            //Passo o parametro
            cmd.Parameters.AddWithValue("@cpf", txtCpf.Text);
            MySqlDataReader leitor = cmd.ExecuteReader();
            string          lSenha = string.Empty;
            string          lLogin = string.Empty;
            string          lNome  = string.Empty;


            while (leitor.Read())
            {
                //passo os valores para o objeto cliente
                //que será retornado

                lSenha = leitor["empPassword"].ToString();
                lLogin = leitor["empUsername"].ToString();
                lNome  = leitor["empName"].ToString();
            }
            try
            {
                Email = new MailMessage();
                Email.To.Add(new MailAddress(txtEmail.Text));
                Email.From       = (new MailAddress(Credentials.lAdress));
                Email.Subject    = "Suas Informações de Login como solicitado.";
                Email.IsBodyHtml = true;
                Email.Body       = "Ceo:Giovanni Nascimento Santos <br/> FarmaLife Enterprise 2018 ® </br> <b>Aqui estão seus dados senhor(a) </br>" + lNome + "</b> </br> <i> Não responder esse e-mail</i></br> Login: "******" </br> Senha : " + lSenha;
                SmtpClient cliente = new SmtpClient(Credentials.lSmtpLive, Credentials.lSmtpLivePort);
                using (cliente)
                {
                    cliente.Credentials = new System.Net.NetworkCredential(Credentials.lAdress, Credentials.lPassword);
                    cliente.EnableSsl   = true;
                    cliente.Send(Email);
                }
                MessageBox.Show("E-mail enviado com sucesso, apenas aguarde alguns segundos", "E-mail enviado");
                this.Close();
                Login login = new Login();
                login.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show(MessageBoxResult.lEmailError);
                errorQuery lerrorQuery = new errorQuery();
                MessageBox.Show(MessageBoxResult.lEmailError, Config.lAlert);
                lerrorQuery.AddError(Principal.lUser, MessageBoxResult.lEmailError, ex.Message.Replace("'", ""), DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"), "Esqueceu Email");
            }
        }
Beispiel #4
0
        public void Add(Client lClient)
        {
            try
            {
                MySqlConnection connection = new MySqlConnection(Connection.lConnection);

                connection.Open();

                string insert = "INSERT INTO cadastro_cliente(for_nome,for_cpf,for_cep,for_endereco,for_bairro,for_cidade,for_uf,for_fone,for_email)" + "values ('"
                                + lClient.Name + "','" + lClient.Document + "','" + lClient.ZipCode + "','" + lClient.Street + "','" + lClient.District + "','" + lClient.City + "','" + lClient.State + "','"
                                + lClient.Telephone + "','" + lClient.Email + "')";
                MySqlCommand    command = new MySqlCommand(insert, connection);
                MySqlDataReader myreader;
                myreader = command.ExecuteReader();
            }
            catch (Exception ex)
            {
                errorQuery lerrorQuery = new errorQuery();
                lerrorQuery.AddError(Principal.lUser, MessageBoxResult.lError, ex.Message.Replace("'", ""), DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"), "Cadastro Funcionario");
            }
        }
Beispiel #5
0
        public void Update(Client lClient)
        {
            try
            {
                MySqlConnection connection = new MySqlConnection(Connection.lConnection);
                connection.Open();

                string update = "UPDATE cadastro_cliente set for_nome= '" + lClient.Name + "',for_endereco= '" + lClient.Street + "',for_bairro= '" + lClient.District + "',for_cidade= '" + lClient.City +
                                "',for_uf ='" + lClient.State + "',for_cpf= '" + lClient.Document + "',for_cep='" + lClient.ZipCode + "',for_fone='" + lClient.Telephone +
                                "',for_email='" + lClient.Email + "' WHERE for_cod='" + lClient.Id + "';";

                MySqlCommand    command = new MySqlCommand(update, connection);
                MySqlDataReader myreader;
                myreader = command.ExecuteReader();
            }
            catch (Exception ex)
            {
                errorQuery lerrorQuery = new errorQuery();
                lerrorQuery.AddError(Principal.lUser, MessageBoxResult.lErrorUpdate, ex.Message.Replace("'", ""), DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"), "Cadastro Cliente");
            }
        }
        // botão cadastrar
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (txtId.Text != string.Empty)
            {
                Client      lClient = new Client();
                clientQuery da      = new clientQuery();

                lClient.Id = Convert.ToInt16(txtId.Text);
                if (txtName.Text != string.Empty)
                {
                    lClient.Name = txtName.Text;
                }
                else
                {
                    MessageBox.Show(Config.lFied + "NOME" + Config.lRequired, Config.lAlert);
                }

                if (txtCpf.Text != string.Empty)
                {
                    lClient.Document = txtCpf.Text;
                }
                else
                {
                    MessageBox.Show(Config.lFied + "CPF" + Config.lRequired, Config.lAlert);
                }

                if (txtCep.Text != string.Empty)
                {
                    lClient.ZipCode = txtCep.Text;
                }
                else
                {
                    MessageBox.Show(Config.lFied + "CEP" + Config.lRequired, Config.lAlert);
                }

                lClient.Street    = txtStreet.Text;
                lClient.District  = txtDistrict.Text;
                lClient.City      = txtCity.Text;
                lClient.State     = txtState.Text;
                lClient.Telephone = txtCellphone.Text;

                if (txtEmail.Text != string.Empty)
                {
                    lClient.Email = txtEmail.Text;
                }
                else
                {
                    MessageBox.Show(Config.lFied + "E-MAIL" + Config.lRequired, Config.lAlert);
                }

                if (txtStatus.Text == "Ativo" && txtStatus.Text != string.Empty)
                {
                    lClient.Status = "A";
                }
                else if (txtStatus.Text != string.Empty)
                {
                    lClient.Status = "I";
                }
                else
                {
                    MessageBox.Show(Config.lFied + "STATUS" + Config.lRequired, Config.lAlert);
                }


                if (txtName.Text != string.Empty && txtCep.Text != string.Empty && txtEmail.Text != string.Empty &&
                    txtCpf.Text != string.Empty && txtStatus.Text != string.Empty)
                {
                    da.Update(lClient);
                    MessageBox.Show(MessageBoxResult.lUpdate);
                    Clean();
                }
                else
                {
                    MessageBox.Show(Config.lErrorRegister, MessageBoxResult.lErrorUpdate);
                }
            }
            else if (MessageBox.Show("Deseja receber um e-mail para confirmar o cadastro?", Config.lAlert, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            {
                MySqlConnection con = new MySqlConnection(Connection.lConnection);
                con.Open();
                string       consulta = "SELECT for_cpf FROM cadastro_cliente WHERE for_cpf = @cpf";
                MySqlCommand cmd      = new MySqlCommand(consulta, con);

                //Passo o parametro
                cmd.Parameters.AddWithValue("@cpf", txtCpf.Text);
                MySqlDataReader read = cmd.ExecuteReader();

                //se o cliente já estiver cadastrado
                if (read.Read())
                {
                    if (MessageBox.Show("Cliente já está cadastrado, gostaria de pesquisar o mesmo?", Config.lAlert, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        tabControl1.SelectedTab = tabPage2;
                    }
                }
                //se não estiver
                else
                {
                    Client      lClient = new Client();
                    clientQuery da      = new clientQuery();
                    if (txtName.Text != string.Empty)
                    {
                        lClient.Name = txtName.Text;
                    }
                    else
                    {
                        MessageBox.Show(Config.lFied + "NOME" + Config.lRequired, Config.lAlert);
                    }

                    if (txtCpf.Text != string.Empty)
                    {
                        lClient.Document = txtCpf.Text;
                    }
                    else
                    {
                        MessageBox.Show(Config.lFied + "CPF" + Config.lRequired, Config.lAlert);
                    }

                    if (txtCep.Text != string.Empty)
                    {
                        lClient.ZipCode = txtCep.Text;
                    }
                    else
                    {
                        MessageBox.Show(Config.lFied + "CEP" + Config.lRequired, Config.lAlert);
                    }

                    lClient.Street    = txtStreet.Text;
                    lClient.District  = txtDistrict.Text;
                    lClient.City      = txtCity.Text;
                    lClient.State     = txtState.Text;
                    lClient.Telephone = txtCellphone.Text;

                    if (txtEmail.Text != string.Empty)
                    {
                        lClient.Email = txtEmail.Text;
                    }
                    else
                    {
                        MessageBox.Show(Config.lFied + "E-MAIL" + Config.lRequired, Config.lAlert);
                    }

                    if (txtStatus.Text == "Ativo" && txtStatus.Text != string.Empty)
                    {
                        lClient.Status = "A";
                    }
                    else if (txtStatus.Text != string.Empty)
                    {
                        lClient.Status = "I";
                    }
                    else
                    {
                        MessageBox.Show(Config.lFied + "STATUS" + Config.lRequired, Config.lAlert);
                    }


                    if (txtName.Text != string.Empty && txtCep.Text != string.Empty && txtEmail.Text != string.Empty &&
                        txtCpf.Text != string.Empty && txtStatus.Text != string.Empty)
                    {
                        da.Add(lClient);
                        MessageBox.Show(MessageBoxResult.lSucess);
                        Clean();
                    }
                    else
                    {
                        MessageBox.Show(Config.lErrorRegister, MessageBoxResult.lError);
                    }
                }
            }
            else
            {
                MySqlConnection con = new MySqlConnection(Connection.lConnection);
                con.Open();
                string       consulta = "SELECT for_cpf FROM cadastro_cliente WHERE for_cpf = @cpf";
                MySqlCommand cmd      = new MySqlCommand(consulta, con);

                //Passo o parametro
                cmd.Parameters.AddWithValue("@cpf", txtCpf.Text);
                MySqlDataReader read = cmd.ExecuteReader();

                //se o cliente já estiver cadastrado
                if (read.Read())
                {
                    if (MessageBox.Show("Cliente já está cadastrado, gostaria de pesquisar o mesmo?", Config.lAlert, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        tabControl1.SelectedTab = tabPage2;
                    }
                }
                //se não estiver
                else
                {
                    Client      lClient = new Client();
                    clientQuery da      = new clientQuery();
                    if (txtName.Text != string.Empty)
                    {
                        lClient.Name = txtName.Text;
                    }
                    else
                    {
                        MessageBox.Show(Config.lFied + "NOME" + Config.lRequired, Config.lAlert);
                    }

                    if (txtCpf.Text != string.Empty)
                    {
                        lClient.Document = txtCpf.Text;
                    }
                    else
                    {
                        MessageBox.Show(Config.lFied + "CPF" + Config.lRequired, Config.lAlert);
                    }

                    if (txtCep.Text != string.Empty)
                    {
                        lClient.ZipCode = txtCep.Text;
                    }
                    else
                    {
                        MessageBox.Show(Config.lFied + "CEP" + Config.lRequired, Config.lAlert);
                    }

                    lClient.Street    = txtStreet.Text;
                    lClient.District  = txtDistrict.Text;
                    lClient.City      = txtCity.Text;
                    lClient.State     = txtState.Text;
                    lClient.Telephone = txtCellphone.Text;

                    if (txtEmail.Text != string.Empty)
                    {
                        lClient.Email = txtEmail.Text;
                    }
                    else
                    {
                        MessageBox.Show(Config.lFied + "E-MAIL" + Config.lRequired, Config.lAlert);
                    }

                    if (txtStatus.Text == "Ativo" && txtStatus.Text != string.Empty)
                    {
                        lClient.Status = "A";
                    }
                    else if (txtStatus.Text != string.Empty)
                    {
                        lClient.Status = "I";
                    }
                    else
                    {
                        MessageBox.Show(Config.lFied + "STATUS" + Config.lRequired, Config.lAlert);
                    }


                    if (txtName.Text != string.Empty && txtCep.Text != string.Empty && txtEmail.Text != string.Empty &&
                        txtCpf.Text != string.Empty && txtStatus.Text != string.Empty)
                    {
                        da.Add(lClient);
                        MessageBox.Show(MessageBoxResult.lSucess);
                    }
                    else
                    {
                        MessageBox.Show(Config.lErrorRegister, MessageBoxResult.lError);
                    }

                    try
                    {
                        MySqlConnection conn = new MySqlConnection(Connection.lConnection);
                        conn.Open();
                        string       consulta1 = "SELECT for_nome,for_email FROM cadastro_cliente WHERE for_email = @for_email";
                        MySqlCommand cmd1      = new MySqlCommand(consulta1, conn);
                        //Passo o parametro
                        cmd1.Parameters.AddWithValue("@for_email", txtEmail.Text);
                        MySqlDataReader leitor = cmd1.ExecuteReader();
                        string          lEmail = string.Empty;
                        string          lName  = string.Empty;

                        while (leitor.Read())
                        {
                            lName  = leitor["for_nome"].ToString();
                            lEmail = leitor["for_email"].ToString();
                        }
                        Email = new MailMessage();
                        Email.To.Add(new MailAddress(lEmail));
                        Email.From       = (new MailAddress(Credentials.lAdress));
                        Email.Subject    = "Bem Vindo a Farmalife";
                        Email.IsBodyHtml = true;
                        Email.Body       = "Ceo:Giovanni Nascimento Santos <br/> FarmaLife Enterprise 2018 ® </br> <b>Parabéns! Seu cadastrado foi concluído com exito e o(a) senhor(a)" + lName + " já pode desfrutar de todos os nossos produtos. Fique atento no e-mail que estaremos sempre encaminhando descontos para agradar os nossos clientes. </b></br>Com atenção, FarmaLife</br> <i>Não responder esse e-mail</i></br>";
                        SmtpClient cliente = new SmtpClient(Credentials.lSmtpLive, Credentials.lSmtpLivePort);
                        using (cliente)
                        {
                            cliente.Credentials = new System.Net.NetworkCredential(Credentials.lAdress, Credentials.lPassword);
                            cliente.EnableSsl   = true;
                            cliente.Send(Email);
                        }
                        conn.Close();
                        con.Close();
                        Clean();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Erro ao enviar email de confirmação para cliente:" + ex.Message);
                        errorQuery lerrorQuery = new errorQuery();
                        lerrorQuery.AddError(Principal.lUser, MessageBoxResult.lEmailError, ex.Message.Replace("'", ""), DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"), "Cadastro Funcionario");
                    }
                }
            }
        }
Beispiel #7
0
        // quantidade manda pra datagrid
        private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            Product lProduct = new Product();

            MySqlConnection cn5  = new MySqlConnection(Connection.lConnection);
            MySqlCommand    cmd5 = new MySqlCommand("SELECT pro_quantidade_no_estoque FROM cadastro_remedios WHERE pro_codigo='" + txtProduct.Text + "'", cn5);

            cn5.Open();
            MySqlDataReader reader = cmd5.ExecuteReader();

            if (reader.Read())
            {
                int sotockQuantity = reader.GetInt32(0);
                if (e.KeyChar == Config.lEnterValue)
                {
                    btnClose.Enabled       = true;
                    btnGet.Enabled         = false;
                    pictureBox7.Visible    = false;
                    pictureBox1.Visible    = true;
                    dataGridView2.Visible  = false;
                    comboBox2.Visible      = false;
                    panel1.Visible         = false;
                    textBox1.Visible       = false;
                    btnPequisar.Visible    = false;
                    btnCloseSearch.Visible = false;
                    button1.Enabled        = false;

                    dataGridView2.Enabled = false;
                    dataGridView2.Columns.Clear();
                    dataGridView2.Refresh();
                    comboBox2.Enabled      = false;
                    panel1.Enabled         = false;
                    textBox1.Enabled       = false;
                    btnPequisar.Enabled    = false;
                    btnCloseSearch.Enabled = false;

                    dataGridView1.Visible = true;
                    txtSearch.Visible     = false;
                    comboBox1.Visible     = false;
                    dataGridViewSearch.Columns.Clear();
                    dataGridViewSearch.Refresh();
                    dataGridViewSearch.Visible = false;
                    btnSearch.Visible          = false;

                    if (txtProdQnt.Text == "0" || this.txtProdQnt.Text == string.Empty)
                    {
                        txtProdQnt.Text = "1";
                        MessageBox.Show("A quantidade '0' foi substituída por '1'");
                    }
                    double qqty = 0, value, total, discount, finaldiscount;
                    qqty = Convert.ToDouble(txtProdQnt.Text);

                    if (sotockQuantity >= qqty)
                    {
                        counter++;
                        value         = Convert.ToDouble(txtProdValor.Text);
                        discount      = Convert.ToDouble(txtProdDesc.Text);
                        finaldiscount = discount * qqty;
                        total         = (qqty * value) - finaldiscount;
                        dataGridView1.Rows.Add(txtProduct.Text, txtProdName.Text, txtProdQnt.Text, txtProdValor.Text, finaldiscount, total);
                    }
                    else
                    {
                        MessageBox.Show(MessageBoxResult.lStockError, Config.lAlert);
                        errorQuery lerrorQuery = new errorQuery();

                        if (sotockQuantity == 0)
                        {
                            try
                            {
                                Email = new MailMessage();
                                Email.To.Add(new MailAddress(Credentials.lGerenciaAdress));
                                Email.From       = (new MailAddress(Credentials.lAdress));
                                Email.Subject    = Config.lAlert;
                                Email.IsBodyHtml = true;
                                Email.Body       = "FarmaLife Enterprises 2018 ®</br>Foi verificado que ao tentar realizar uma compra do produto com o código: " + txtProduct.Text + " e o nome: " + txtProdName.Text + " no dia " + DateTime.Now + "</b>, o mesmo não se encontrava em estoque, favor tomar medidas cabíveis. </br> <i> Não responder esse e-mail</i></br>";

                                SmtpClient sell = new SmtpClient(Credentials.lSmtpLive, Credentials.lSmtpLivePort);

                                using (sell)
                                {
                                    sell.Credentials = new System.Net.NetworkCredential(Credentials.lAdress, Credentials.lPassword);
                                    sell.EnableSsl   = true;
                                    sell.Send(Email);
                                }
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(MessageBoxResult.lEmailError, Config.lAlert);
                                lerrorQuery.AddError(Principal.lUser, MessageBoxResult.lEmailError, ex.Message.Replace("'", ""), DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"), "Venda");
                            }
                            lerrorQuery.AddError(Principal.lUser, MessageBoxResult.lStockError, "Estoque zerado.", DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"), "Venda");
                        }
                        else
                        {
                            MessageBox.Show(MessageBoxResult.lStockError, Config.lAlert);
                        }
                    }
                }
            }
        }
Beispiel #8
0
        private void FinishMethod()
        {
            if (this.txtProduct.Text == string.Empty | this.txtEmployee.Text == string.Empty | this.txtClient.Text == string.Empty | this.txtGrossAmount.Text == string.Empty | this.txtDiscount.Text == string.Empty | this.txtNetAmount.Text == string.Empty)
            {
                MessageBox.Show("Algumas informações importantes para a venda ficaram de fora, ou foram preenchidos errados, revise.", Config.lAlert);
                txtEmployee.Focus();
            }

            else if (MessageBox.Show("Deseja finalizar venda?", Config.lAlert, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                Product   lProduct   = new Product();
                Employee  lEmployee  = new Employee();
                Client    lClient    = new Client();
                Sell      lSell      = new Sell();
                ItemSell  lItemSell  = new ItemSell();
                sellQuery lsellQuery = new sellQuery();
                {
                    lEmployee.Id          = Convert.ToInt16(txtEmployee.Text);
                    lClient.Id            = Convert.ToInt16(txtClient.Text);
                    lProduct.Codigo       = Convert.ToInt16(txtProduct.Text);
                    lSell.sellGrossAmount = txtGrossAmount.Text;
                    lSell.sellDiscount    = txtDiscount.Text;
                    lSell.sellNetAmount   = txtNetAmount.Text;
                    lSell.sellStatus      = txtStatus.Text;
                    lSell.sellDate        = txtDate.Text;
                    lSell.sellHour        = txtHour.Text;
                    lsellQuery.SellMethod(lProduct, lEmployee, lClient, lSell);
                }

                //exibir código da venda
                string          result;
                MySqlConnection cn2 = new MySqlConnection(Connection.lConnection);
                MySqlCommand    cmd = new MySqlCommand("SELECT  max(ven_cod) FROM venda", cn2);
                cn2.Open();
                MySqlDataReader reader = cmd.ExecuteReader();

                if (reader.Read())
                {
                    result         = reader.GetString(0);
                    txtId.Visible  = true;
                    label8.Visible = true;
                    txtId.Text     = result;
                }
                cn2.Close();
                //configurar datagrid
                string[,] item = new string[counter, 5];
                for (int l = 0; l < counter; l++)
                {
                    for (int c = 0; c < 5; c++)
                    {
                        DataGridViewCell cell = null;
                        foreach (DataGridViewCell selectedCell in dataGridView1.SelectedCells)
                        {
                            cell = selectedCell;
                            break;
                        }
                        if (cell != null)
                        {
                            if (c == 0)
                            {
                                item[l, c]      = dataGridView1.Rows[l].Cells[c].Value.ToString();
                                lProduct.Codigo = Convert.ToInt32(item[l, c]);
                            }
                            else if (c == 1)
                            {
                                item[l, c]             = dataGridView1.Rows[l].Cells[2].Value.ToString();
                                lItemSell.itemQuantity = Convert.ToInt32(item[l, c]);
                            }
                            else if (c == 2)
                            {
                                item[l, c]          = dataGridView1.Rows[l].Cells[3].Value.ToString();
                                lProduct.PrecoVenda = (item[l, c]);
                            }
                            else if (c == 3)
                            {
                                item[l, c]          = dataGridView1.Rows[l].Cells[5].Value.ToString();
                                lItemSell.itemTotal = (item[l, c]);
                            }
                            else if (c == 4)
                            {
                                lSell.sellId = Convert.ToInt32(txtId.Text);
                            }
                        }
                    }
                    lsellQuery.ItemSellMethod(lProduct, lSell, lItemSell);
                    //Atualiza estoque
                    MySqlConnection cn3  = new MySqlConnection(Connection.lConnection);
                    MySqlCommand    cmd3 = new MySqlCommand("SELECT pro_quantidade_no_estoque FROM cadastro_remedios WHERE pro_codigo = '" + lProduct.Codigo + "'", cn3);
                    cn3.Open();
                    MySqlDataReader reader3 = cmd3.ExecuteReader();

                    if (reader3.Read())
                    {
                        int sotockQuantity = reader3.GetInt32(0);
                        actualStock = sotockQuantity - lItemSell.itemQuantity;
                    }

                    try
                    {
                        MySqlConnection connection = new MySqlConnection(Connection.lConnection);
                        connection.Open();

                        string update = "UPDATE cadastro_remedios SET pro_quantidade_no_estoque =  '" + actualStock + "' WHERE pro_codigo = '" + lProduct.Codigo + "';";

                        MySqlCommand    command = new MySqlCommand(update, connection);
                        MySqlDataReader myreader;
                        myreader = command.ExecuteReader();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(MessageBoxResult.lErrorCommand + ex.Message);
                        errorQuery lerrorQuery = new errorQuery();
                        lerrorQuery.AddError(Principal.lUser, MessageBoxResult.lErrorCommand, ex.Message.Replace("'", ""), DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"), "Venda");
                    }
                }
                MessageBox.Show("Venda Finalizada com Sucesso", "Sucesso!");
                //limpar a tela após finalizar venda

                if (Convert.ToDouble(txtNetAmount.Text) > 850.00)
                {
                    try
                    {
                        Email = new MailMessage();
                        Email.To.Add(new MailAddress(Credentials.lGerenciaAdress));
                        Email.From       = (new MailAddress(Credentials.lAdress));
                        Email.Subject    = Config.lAlert;
                        Email.IsBodyHtml = true;
                        Email.Body       = "FarmaLife Enterprises 2018 ®</br>A compra com o código: " + txtId.Text + " teve o valor de  " + txtNetAmount.Text.Replace(",", ".") + ", que foi realizada por " + txtNameEmployee.Text + " para o cliente " + txtNameCliente.Text + ", no dia " + DateTime.Now + " o valor em questão foi acima do padrão, favor verificar. </br> <i> Não responder esse e-mail</i></br>";

                        SmtpClient sell2 = new SmtpClient(Credentials.lSmtpLive, Credentials.lSmtpLivePort);

                        using (sell2)
                        {
                            sell2.Credentials = new System.Net.NetworkCredential(Credentials.lAdress, Credentials.lPassword);
                            sell2.EnableSsl   = true;
                            sell2.Send(Email);
                        }
                        this.Close();
                        Venda sell = new Venda();
                        sell.Show();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                        errorQuery lerrorQuery = new errorQuery();
                        MessageBox.Show(MessageBoxResult.lEmailError, Config.lAlert);
                        lerrorQuery.AddError(Principal.lUser, MessageBoxResult.lEmailError, ex.Message.Replace("'", ""), DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"), "Venda");
                    }
                }
                else
                {
                    this.Close();
                    Venda sell = new Venda();
                    sell.Show();
                }
            }
        }
Beispiel #9
0
        private void btnEnviar_Click(object sender, EventArgs e)
        {
            string op = (string)comboBox1.SelectedItem;

            switch (op)
            {
            case "Outlook":
                try
                {
                    Email = new MailMessage();
                    Email.To.Add(new MailAddress(txtPara.Text));
                    Email.From       = (new MailAddress(txtDe.Text));
                    Email.Subject    = txtAssunto.Text;
                    Email.IsBodyHtml = true;
                    Email.Body       = txtMensagem.Text;
                    SmtpClient cliente = new SmtpClient(Credentials.lSmtpLive, Credentials.lSmtpLivePort);
                    using (cliente)
                    {
                        cliente.Credentials = new System.Net.NetworkCredential(txtDe.Text, txtPassword.Text);
                        cliente.EnableSsl   = true;
                        cliente.Send(Email);
                    }
                    MessageBox.Show("E-mail enviado com sucesso, apenas aguarde alguns segundos", "E-mail enviado");
                    this.Close();
                    email email = new email();
                    email.Show();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(MessageBoxResult.lEmailError, ex.Message);
                    errorQuery lerrorQuery = new errorQuery();
                    MessageBox.Show(MessageBoxResult.lEmailError, Config.lAlert);
                    lerrorQuery.AddError(Principal.lUser, MessageBoxResult.lEmailError, ex.Message.Replace("'", ""), DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"), "Venda");
                }
                break;

            case "Gmail":
                try
                {
                    Email = new MailMessage();
                    Email.To.Add(new MailAddress(txtPara.Text));
                    Email.From       = (new MailAddress(txtDe.Text));
                    Email.Subject    = txtAssunto.Text;
                    Email.IsBodyHtml = true;
                    Email.Body       = txtMensagem.Text;
                    SmtpClient cliente1 = new SmtpClient(Credentials.lSmtpGmail, Credentials.lSmtpLivePort);
                    using (cliente1)
                    {
                        cliente1.Credentials = new System.Net.NetworkCredential(txtDe.Text, txtPassword.Text);
                        cliente1.EnableSsl   = true;
                        cliente1.Send(Email);
                    }
                    MessageBox.Show("E-mail enviado com sucesso, apenas aguarde alguns segundos", "E-mail enviado");
                    this.Close();
                    email email1 = new email();
                    email1.Show();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(MessageBoxResult.lEmailError, ex.Message);
                    errorQuery lerrorQuery = new errorQuery();
                    MessageBox.Show(MessageBoxResult.lEmailError, Config.lAlert);
                    lerrorQuery.AddError(Principal.lUser, MessageBoxResult.lEmailError, ex.Message.Replace("'", ""), DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"), "Venda");
                }
                break;
            }
        }
Beispiel #10
0
        public void RegisterEmploye()
        {
            Employee      lEmployee = new Employee();
            employeeQuery da        = new employeeQuery();

            //Verificar se é um funcionario novo ou ja existente
            if (txtId.Text != string.Empty)
            {
                lEmployee.Id = Convert.ToInt32(txtId.Text);
                if (txtName.Text != string.Empty)
                {
                    lEmployee.Name = txtName.Text;
                }
                else
                {
                    MessageBox.Show(Config.lFied + "NOME" + Config.lRequired, Config.lAlert);
                }

                if (txtCep.Text != string.Empty)
                {
                    lEmployee.ZipCode = txtCep.Text;
                }
                else
                {
                    MessageBox.Show(Config.lFied + "CEP" + Config.lRequired, Config.lAlert);
                }

                lEmployee.CivilState = txtCivilState.Text;
                lEmployee.BirthDate  = txtBirthDate.Text;
                lEmployee.Telephone  = txtFone.Text;
                lEmployee.Number     = txtNumber.Text;
                lEmployee.State      = txtState.Text;
                lEmployee.City       = txtCity.Text;
                lEmployee.Street     = txtStreet.Text;
                lEmployee.District   = txtDistrict.Text;

                if (txtCellphone.Text != string.Empty)
                {
                    lEmployee.CellPhone = txtCellphone.Text;
                }
                else
                {
                    MessageBox.Show(Config.lFied + "CELULAR" + Config.lRequired, Config.lAlert);
                }

                if (txtEmail.Text != string.Empty)
                {
                    lEmployee.Email = txtEmail.Text;
                }
                else
                {
                    MessageBox.Show(Config.lFied + "E-MAIL" + Config.lRequired, Config.lAlert);
                }

                if (txtUsername.Text != string.Empty)
                {
                    lEmployee.Username = txtUsername.Text;
                }
                else
                {
                    MessageBox.Show(Config.lFied + "LOGIN" + Config.lRequired, Config.lAlert);
                }

                if (txtPassword.Text != string.Empty)
                {
                    if (txtPassword.Text.Length >= 8)
                    {
                        lEmployee.Password = txtPassword.Text;
                    }
                    else
                    {
                        MessageBox.Show("A senha deve conter pelo menos 8 caracteres", Config.lAlert);
                    }
                }
                else
                {
                    MessageBox.Show(Config.lFied + "SENHA" + Config.lRequired, Config.lAlert);
                }

                if (txtRole.Text != string.Empty)
                {
                    lEmployee.Role = txtRole.Text;
                }
                else
                {
                    MessageBox.Show(Config.lFied + "CARGO" + Config.lRequired, Config.lAlert);
                }

                if (txtCPF.Text != string.Empty)
                {
                    lEmployee.Document = txtCPF.Text;
                }
                else
                {
                    MessageBox.Show(Config.lFied + "CPF" + Config.lRequired, Config.lAlert);
                }

                if (txtStatus.Text == "Ativo" && txtStatus.Text != string.Empty)
                {
                    lEmployee.Status = "A";
                }
                else if (txtStatus.Text != string.Empty)
                {
                    lEmployee.Status = "I";
                }
                else
                {
                    MessageBox.Show(Config.lFied + "STATUS" + Config.lRequired, Config.lAlert);
                }


                if (txtName.Text != string.Empty && txtStreet.Text != string.Empty && txtCity.Text != string.Empty && txtState.Text != string.Empty &&
                    txtCellphone.Text != string.Empty && txtEmail.Text != string.Empty && txtUsername.Text != string.Empty && txtPassword.Text != string.Empty &&
                    txtRole.Text != string.Empty && txtCPF.Text != string.Empty && txtStatus.Text != string.Empty && txtPassword.Text.Length >= 8)
                {
                    da.Update(lEmployee);
                    MessageBox.Show(MessageBoxResult.lUpdate);
                    CleanMethod();
                }
                else
                {
                    MessageBox.Show(Config.lErrorRegister, MessageBoxResult.lErrorUpdate);
                }
            }
            else if (MessageBox.Show("Deseja receber um e-mail para confirmar o cadastro?", Config.lAlert, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            {
                MySqlConnection con = new MySqlConnection(Connection.lConnection);
                con.Open();
                string       consulta = "SELECT empUsername,empDocument, empEmail FROM employee WHERE empDocument = @CPF OR empUsername = @LOGIN OR empEmail = @EMAIL";
                MySqlCommand cmd      = new MySqlCommand(consulta, con);

                //Passo o parametro
                cmd.Parameters.Add("@CPF", MySqlDbType.VarChar).Value   = txtCPF.Text;
                cmd.Parameters.Add("@LOGIN", MySqlDbType.VarChar).Value = txtUsername.Text;
                cmd.Parameters.Add("@EMAIL", MySqlDbType.VarChar).Value = txtEmail.Text;

                MySqlDataReader le = null;
                le = cmd.ExecuteReader();

                //se o usuario já estiver cadastrado
                if (le.Read())
                {
                    if (MessageBox.Show("Este usuario já está cadastrado, gostaria de pesquisar o mesmo?", Config.lAlert, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        tabControl1.SelectedTab = tabPage2;
                    }
                }
                //se não estiver
                else
                {
                    if (txtName.Text != string.Empty)
                    {
                        lEmployee.Name = txtName.Text;
                    }
                    else
                    {
                        MessageBox.Show(Config.lFied + "NOME" + Config.lRequired, Config.lAlert);
                    }

                    if (txtCep.Text != string.Empty)
                    {
                        lEmployee.ZipCode = txtCep.Text;
                    }
                    else
                    {
                        MessageBox.Show(Config.lFied + "CEP" + Config.lRequired, Config.lAlert);
                    }

                    lEmployee.State    = txtState.Text;
                    lEmployee.City     = txtCity.Text;
                    lEmployee.Street   = txtStreet.Text;
                    lEmployee.District = txtDistrict.Text;

                    lEmployee.CivilState = txtCivilState.Text;
                    lEmployee.BirthDate  = txtBirthDate.Text;
                    lEmployee.Telephone  = txtFone.Text;
                    lEmployee.Number     = txtNumber.Text;

                    if (txtCellphone.Text != string.Empty)
                    {
                        lEmployee.CellPhone = txtCellphone.Text;
                    }
                    else
                    {
                        MessageBox.Show(Config.lFied + "CELULAR" + Config.lRequired, Config.lAlert);
                    }

                    if (txtEmail.Text != string.Empty)
                    {
                        lEmployee.Email = txtEmail.Text;
                    }
                    else
                    {
                        MessageBox.Show(Config.lFied + "E-MAIL" + Config.lRequired, Config.lAlert);
                    }

                    if (txtUsername.Text != string.Empty)
                    {
                        lEmployee.Username = txtUsername.Text;
                    }
                    else
                    {
                        MessageBox.Show(Config.lFied + "LOGIN" + Config.lRequired, Config.lAlert);
                    }

                    if (txtPassword.Text != string.Empty)
                    {
                        if (txtPassword.Text.Length >= 8)
                        {
                            lEmployee.Password = txtPassword.Text;
                        }
                        else
                        {
                            MessageBox.Show("A senha deve conter pelo menos 8 caracteres", Config.lAlert);
                        }
                    }
                    else
                    {
                        MessageBox.Show(Config.lFied + "SENHA" + Config.lRequired, Config.lAlert);
                    }

                    if (txtRole.Text != string.Empty)
                    {
                        lEmployee.Role = txtRole.Text;
                    }
                    else
                    {
                        MessageBox.Show(Config.lFied + "CARGO" + Config.lRequired, Config.lAlert);
                    }

                    if (txtCPF.Text != string.Empty)
                    {
                        lEmployee.Document = txtCPF.Text;
                    }
                    else
                    {
                        MessageBox.Show(Config.lFied + "CPF" + Config.lRequired, Config.lAlert);
                    }

                    if (txtStatus.Text == "Ativo" && txtStatus.Text != string.Empty)
                    {
                        lEmployee.Status = "A";
                    }
                    else if (txtStatus.Text != string.Empty)
                    {
                        lEmployee.Status = "I";
                    }
                    else
                    {
                        MessageBox.Show(Config.lFied + "STATUS" + Config.lRequired, Config.lAlert);
                    }

                    if (txtName.Text != string.Empty && txtStreet.Text != string.Empty && txtCity.Text != string.Empty && txtState.Text != string.Empty &&
                        txtCellphone.Text != string.Empty && txtEmail.Text != string.Empty && txtUsername.Text != string.Empty && txtPassword.Text != string.Empty &&
                        txtRole.Text != string.Empty && txtCPF.Text != string.Empty && txtStatus.Text != string.Empty && txtPassword.Text.Length >= 8)
                    {
                        da.Add(lEmployee);
                        MessageBox.Show(MessageBoxResult.lSucess);
                        CleanMethod();
                    }
                    else
                    {
                        MessageBox.Show(Config.lErrorRegister, MessageBoxResult.lError);
                    }
                }
            }
            else
            {
                MySqlConnection con = new MySqlConnection(Connection.lConnection);
                con.Open();
                string       consulta = "SELECT empUsername,empDocument, empEmail FROM employee WHERE empDocument = @CPF OR empUsername = @LOGIN OR empEmail = @EMAIL";
                MySqlCommand cmd      = new MySqlCommand(consulta, con);

                //Passo o parametro
                cmd.Parameters.Add("@CPF", MySqlDbType.VarChar).Value   = txtCPF.Text;
                cmd.Parameters.Add("@LOGIN", MySqlDbType.VarChar).Value = txtUsername.Text;
                cmd.Parameters.Add("@EMAIL", MySqlDbType.VarChar).Value = txtEmail.Text;

                MySqlDataReader le = null;
                le = cmd.ExecuteReader();


                //se o usuario já estiver cadastrado
                if (le.Read())
                {
                    if (MessageBox.Show("Este usuario já está cadastrado, gostaria de pesquisar o mesmo?", Config.lAlert, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        tabControl1.SelectedTab = tabPage2;
                    }
                }
                else
                {
                    if (txtName.Text != string.Empty)
                    {
                        lEmployee.Name = txtName.Text;
                    }
                    else
                    {
                        MessageBox.Show(Config.lFied + "NOME" + Config.lRequired, Config.lAlert);
                    }

                    lEmployee.State    = txtState.Text;
                    lEmployee.City     = txtCity.Text;
                    lEmployee.Street   = txtStreet.Text;
                    lEmployee.District = txtDistrict.Text;

                    lEmployee.CivilState = txtCivilState.Text;
                    lEmployee.BirthDate  = txtBirthDate.Text;
                    lEmployee.Telephone  = txtFone.Text;
                    lEmployee.Number     = txtNumber.Text;

                    if (txtCellphone.Text != string.Empty)
                    {
                        lEmployee.CellPhone = txtCellphone.Text;
                    }
                    else
                    {
                        MessageBox.Show(Config.lFied + "CELULAR" + Config.lRequired, Config.lAlert);
                    }

                    if (txtEmail.Text != string.Empty)
                    {
                        lEmployee.Email = txtEmail.Text;
                    }
                    else
                    {
                        MessageBox.Show(Config.lFied + "E-MAIL" + Config.lRequired, Config.lAlert);
                    }

                    if (txtUsername.Text != string.Empty)
                    {
                        lEmployee.Username = txtUsername.Text;
                    }
                    else
                    {
                        MessageBox.Show(Config.lFied + "LOGIN" + Config.lRequired, Config.lAlert);
                    }

                    if (txtPassword.Text != string.Empty)
                    {
                        if (txtPassword.Text.Length >= 8)
                        {
                            lEmployee.Password = txtPassword.Text;
                        }
                        else
                        {
                            MessageBox.Show("A senha deve conter pelo menos 8 caracteres", Config.lAlert);
                        }
                    }
                    else
                    {
                        MessageBox.Show(Config.lFied + "SENHA" + Config.lRequired, Config.lAlert);
                    }

                    if (txtRole.Text != string.Empty)
                    {
                        lEmployee.Role = txtRole.Text;
                    }
                    else
                    {
                        MessageBox.Show(Config.lFied + "CARGO" + Config.lRequired, Config.lAlert);
                    }

                    if (txtCPF.Text != string.Empty)
                    {
                        lEmployee.Document = txtCPF.Text;
                    }
                    else
                    {
                        MessageBox.Show(Config.lFied + "CPF" + Config.lRequired, Config.lAlert);
                    }

                    if (txtStatus.Text == "Ativo" && txtStatus.Text != string.Empty)
                    {
                        lEmployee.Status = "A";
                    }
                    else if (txtStatus.Text != string.Empty)
                    {
                        lEmployee.Status = "I";
                    }
                    else
                    {
                        MessageBox.Show(Config.lFied + "STATUS" + Config.lRequired, Config.lAlert);
                    }

                    if (txtName.Text != string.Empty && txtCep.Text != string.Empty && txtStreet.Text != string.Empty && txtCity.Text != string.Empty && txtState.Text != string.Empty &&
                        txtCellphone.Text != string.Empty && txtEmail.Text != string.Empty && txtUsername.Text != string.Empty && txtPassword.Text != string.Empty &&
                        txtRole.Text != string.Empty && txtCPF.Text != string.Empty && txtStatus.Text != string.Empty && txtPassword.Text.Length >= 8)
                    {
                        da.Add(lEmployee);
                        MessageBox.Show(MessageBoxResult.lSucess);
                    }
                    else
                    {
                        MessageBox.Show(Config.lErrorRegister, MessageBoxResult.lError);
                    }

                    try
                    {
                        MySqlConnection conn = new MySqlConnection(Connection.lConnection);
                        conn.Open();
                        string       consulta1 = "SELECT empName,empEmail FROM employee WHERE empEmail = @empEmail";
                        MySqlCommand cmd1      = new MySqlCommand(consulta1, conn);
                        //Passo o parametro
                        cmd1.Parameters.AddWithValue("@empEmail", txtEmail.Text);
                        MySqlDataReader reader = cmd1.ExecuteReader();
                        string          lEmail = string.Empty;
                        string          lName  = string.Empty;
                        while (reader.Read())
                        {
                            lName  = reader["empName"].ToString();
                            lEmail = reader["empEmail"].ToString();
                        }
                        Email = new MailMessage();
                        Email.To.Add(new MailAddress(lEmail));
                        Email.From       = (new MailAddress(Credentials.lAdress));
                        Email.Subject    = "Bem Vindo a Farmalife";
                        Email.IsBodyHtml = true;
                        Email.Body       = "Ceo:Giovanni Nascimento Santos <br/> FarmaLife Enterprise 2018 ® </br> <b>Bem vindo a nossa equipe senhor(a)," + lName + " seu cadastro foi concluído perfeitamente e o senhor(a) já pode utilizar nosso sistema.</br> </b> </br> <i> Não responder esse e-mail</i></br>";
                        SmtpClient employee = new SmtpClient(Credentials.lSmtpLive, Credentials.lSmtpLivePort);
                        using (employee)
                        {
                            employee.Credentials = new System.Net.NetworkCredential(Credentials.lAdress, Credentials.lPassword);
                            employee.EnableSsl   = true;
                            employee.Send(Email);
                        }
                        conn.Close();
                        CleanMethod();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, MessageBoxResult.lEmailError);
                        errorQuery lerrorQuery = new errorQuery();
                        lerrorQuery.AddError(Principal.lUser, MessageBoxResult.lEmailError, ex.Message.Replace("'", ""), DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"), "Cadastro Funcionario");
                    }
                }
            }
        }
        public void CleanRows()
        {
            bool lVerify;

            lVerify = VerifyPassword();
            if (lVerify == true)
            {
                switch (lTable)
                {
                case "Cliente":
                    try
                    {
                        con.Open();
                        string          deletar = "DELETE FROM cadastro_cliente";
                        MySqlCommand    cmd     = new MySqlCommand(deletar, con);
                        MySqlDataReader myreader;
                        myreader = cmd.ExecuteReader();
                        MessageBox.Show(Config.lDelete, Config.lAlert);
                        con.Close();
                        dataGridView1.Columns.Clear();
                        dataGridView1.Refresh();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(MessageBoxResult.lDeleteError + ex.Message);
                        errorQuery lerrorQuery = new errorQuery();
                        lerrorQuery.AddError(Principal.lUser, MessageBoxResult.lDeleteError, ex.Message.Replace("'", ""), DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"), "ApagarDB");
                        con.Close();
                    }
                    break;

                case "Produto":
                    try
                    {
                        con.Open();
                        string          deletar = "DELETE FROM cadastro_remedios";
                        MySqlCommand    cmd     = new MySqlCommand(deletar, con);
                        MySqlDataReader myreader;
                        myreader = cmd.ExecuteReader();
                        MessageBox.Show(Config.lDelete, Config.lAlert);
                        con.Close();
                        dataGridView1.Columns.Clear();
                        dataGridView1.Refresh();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(MessageBoxResult.lDeleteError + ex.Message);
                        errorQuery lerrorQuery = new errorQuery();
                        lerrorQuery.AddError(Principal.lUser, MessageBoxResult.lDeleteError, ex.Message.Replace("'", ""), DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"), "ApagarDB");
                        con.Close();
                    }
                    break;

                case "Venda":
                    try
                    {
                        con.Open();
                        string          deletar = "DELETE FROM venda";
                        MySqlCommand    cmd     = new MySqlCommand(deletar, con);
                        MySqlDataReader myreader;
                        myreader = cmd.ExecuteReader();
                        MessageBox.Show(Config.lDelete, Config.lAlert);
                        con.Close();
                        dataGridView1.Columns.Clear();
                        dataGridView1.Refresh();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(MessageBoxResult.lDeleteError + ex.Message);
                        errorQuery lerrorQuery = new errorQuery();
                        lerrorQuery.AddError(Principal.lUser, MessageBoxResult.lDeleteError, ex.Message.Replace("'", ""), DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"), "ApagarDB");
                        con.Close();
                    }
                    break;

                case "Item Venda":
                    try
                    {
                        con.Open();
                        string          deletar = "DELETE FROM item_venda";
                        MySqlCommand    cmd     = new MySqlCommand(deletar, con);
                        MySqlDataReader myreader;
                        myreader = cmd.ExecuteReader();
                        MessageBox.Show(Config.lDelete, Config.lAlert);
                        con.Close();
                        dataGridView1.Columns.Clear();
                        dataGridView1.Refresh();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(MessageBoxResult.lDeleteError + ex.Message);
                        errorQuery lerrorQuery = new errorQuery();
                        lerrorQuery.AddError(Principal.lUser, MessageBoxResult.lDeleteError, ex.Message.Replace("'", ""), DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"), "ApagarDB");
                        con.Close();
                    }
                    break;

                case "Funcionario":
                    try
                    {
                        con.Open();
                        string          deletar = "DELETE FROM employee";
                        MySqlCommand    cmd     = new MySqlCommand(deletar, con);
                        MySqlDataReader myreader;
                        myreader = cmd.ExecuteReader();
                        MessageBox.Show(Config.lDelete, Config.lAlert);
                        con.Close();
                        dataGridView1.Columns.Clear();
                        dataGridView1.Refresh();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(MessageBoxResult.lDeleteError + ex.Message);
                        errorQuery lerrorQuery = new errorQuery();
                        lerrorQuery.AddError(Principal.lUser, MessageBoxResult.lDeleteError, ex.Message.Replace("'", ""), DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"), "ApagarDB");
                        con.Close();
                    }
                    break;

                case "Erros":
                    try
                    {
                        con.Open();
                        string          deletar = "DELETE FROM systemerrors";
                        MySqlCommand    cmd     = new MySqlCommand(deletar, con);
                        MySqlDataReader myreader;
                        myreader = cmd.ExecuteReader();
                        MessageBox.Show(Config.lDelete, Config.lAlert);
                        con.Close();
                        dataGridView1.Columns.Clear();
                        dataGridView1.Refresh();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(MessageBoxResult.lDeleteError + ex.Message);
                        errorQuery lerrorQuery = new errorQuery();
                        lerrorQuery.AddError(Principal.lUser, MessageBoxResult.lDeleteError, ex.Message.Replace("'", ""), DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"), "ApagarDB");
                        con.Close();
                    }
                    break;
                }
                panel1.Visible      = false;
                txtPassword.Visible = false;
                btnConfirm.Visible  = false;
                label1.Visible      = false;
                txtPassword.Text    = string.Empty;
            }
            else
            {
                MessageBox.Show("Senha Incorreta", Config.lAlert);
                panel1.Visible      = false;
                txtPassword.Visible = false;
                btnConfirm.Visible  = false;
                label1.Visible      = false;
            }
        }