示例#1
0
        private void button9_Click(object sender, EventArgs e)
        {
            try
            {
                int iRetorno;
                iRetorno = MP2032.FormataTX(Cabecalho(1) + textArea.Text + finalConta(), 1, 0, 0, 1, 0);

                iRetorno = MP2032.AcionaGuilhotina(1);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#2
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            func();
            if (dataGridView3.Rows.Count == 0)
            {
                MessageBox.Show("Insira itens na conta clicando duas vezes sobre eles no menu à esquerda.");
                return;
            }


            DateTime saveNow = DateTime.Now;
            string   cupom   = "";

            try
            {
                SQLiteConnection conn = new SQLiteConnection(conexao);
                if (conn.State == ConnectionState.Closed)
                {
                    conn.Open();
                }

                for (int k = 0; k < dataGridView3.Rows.Count; k++)
                {
                    SQLiteCommand cmd2 = new SQLiteCommand("INSERT INTO CONTAS(CODIGO_CONTA, CODIGO, NOME, PRECO, DATA) VALUES (@CODIGO_CONTA, @CODIGO, @NOME, @PRECO, @DATA)", conn);
                    cmd2.Parameters.AddWithValue("@CODIGO_CONTA", Convert.ToInt32(id));
                    cmd2.Parameters.AddWithValue("@CODIGO", Convert.ToInt32(dataGridView3.Rows[k].Cells[0].Value));
                    cmd2.Parameters.AddWithValue("@NOME", dataGridView3.Rows[k].Cells[1].Value.ToString());
                    cmd2.Parameters.AddWithValue("@PRECO", Convert.ToDouble(dataGridView3.Rows[k].Cells[2].Value));
                    cmd2.Parameters.AddWithValue("@DATA", saveNow.ToString());
                    //cupom = cupom + "\r\n" + Convert.ToInt32(dataGridView3.Rows[k].Cells[0].Value).ToString();
                    cupom = cupom + "" + dataGridView3.Rows[k].Cells[1].Value.ToString();

                    int row = dataGridView3.Rows[k].Cells[1].Value.ToString().Length + 1;

                    string yourValue = (((double)Convert.ToDouble(dataGridView3.Rows[k].Cells[2].Value) / 100) * 100).ToString("C");
                    row = row + yourValue.Length;
                    row = 33 - row;
                    string spaces = "";
                    for (int n = 0; n < row; n++)
                    {
                        spaces = spaces + " ";
                    }
                    cupom = cupom + spaces + yourValue + "\r\n";

                    using (cmd2)
                    {
                        cmd2.ExecuteNonQuery();
                    }
                }
                atualizaTotal();
                cupom = cupom + "---------------------------------\r\nTOTAL: " + total;
                listar();
                dataGridView3.DataSource = null;
                dataGridView3.Rows.Clear();
                atualizaTotal();
                try
                {
                    int iRetorno;
                    iRetorno = MP2032.FormataTX(Cabecalho(0) + cupom + finalConta(), 1, 0, 0, 1, 0);

                    iRetorno = MP2032.AcionaGuilhotina(1);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    MessageBox.Show("Conta impressa");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro ao fechar conta:\n" + ex.Message);
                return;
            }

            string path = "C:\\Users\\Quinta de Viana\\OneDrive\\Documentos\\";

            File.Delete(path + "Banco.db");
            File.Copy("Banco.db", path + "Banco.db");
        }