private void mainButton_Click(object sender, EventArgs e)
        {
            date = DateTime.Now;
            int      count    = Database.getTotalSales(date.Date);
            Cashboxs cashboxs = new Cashboxs();

            cashboxs = Database.findCashBox(date.Date);
            int client      = Database.getTotalClient(date.Date);
            int product     = Database.getTotalProduct(date.Date);
            int work_orders = Database.getTotalWorkOrder(date.Date);

            if (!containerPanel.Controls.Contains(main.Instance))
            {
                containerPanel.Controls.Add(main.Instance);
                main.Instance.Dock             = DockStyle.Fill;
                main.Instance.salenumber       = count;
                main.Instance.total_account    = cashboxs.income;
                main.Instance.total_client     = client;
                main.Instance.total_product    = product;
                main.Instance.total_work_order = work_orders;
                main.Instance.BringToFront();
            }
            else
            {
                main.Instance.salenumber       = count;
                main.Instance.total_account    = cashboxs.income;
                main.Instance.total_client     = client;
                main.Instance.total_product    = product;
                main.Instance.total_work_order = work_orders;
                main.Instance.BringToFront();
            }
        }
Exemple #2
0
        private void button_addOutcome_Click(object sender, EventArgs e)
        {
            if (textBox_value.Text.Trim().Length == 0 || textBox_description.Text.Trim().Length == 0)
            {
                MessageBox.Show("Ingrese todos los datos", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                date = DateTime.Now;
                Cashboxs cashboxs1 = new Cashboxs();
                cashboxs1 = Database.findCashBox(date.Date);
                Console.WriteLine(cashboxs1.date);
                Console.WriteLine(cashboxs1.income);
                Console.WriteLine(cashboxs1.outcome);

                if (cashboxs1.date != date.Date)
                {
                    MessageBox.Show("Inicie la caja del día", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    DateTime date    = DateTime.Now;
                    Outcome  outcome = new Outcome();
                    outcome.date        = date.Date;
                    outcome.value       = Convert.ToInt32(textBox_value.Text.Trim());
                    outcome.description = textBox_description.Text.Trim();
                    outcome.username    = id;
                    int resultado = Database.addOutcome(outcome);
                    if (resultado > 0)
                    {
                        Cashboxs cashbox = new Cashboxs();
                        cashbox.outcome = Convert.ToInt32(textBox_value.Text.Trim());
                        cashbox.date    = date.Date;
                        int result = Database.updateCashBox(cashbox, "outcome");
                        if (result > 0)
                        {
                            MessageBox.Show("Egreso ingresado con éxito", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            textBox_value.Text       = "";
                            textBox_description.Text = "";
                            date = DateTime.Now;
                            Cashboxs cashboxs = new Cashboxs();
                            cashboxs               = Database.findCashBox(date.Date);
                            totalcountLabel.Text   = cashbox.income.ToString("C");
                            totalOutcomeLabel.Text = cashbox.outcome.ToString("C");
                        }
                    }
                }
            }
        }
Exemple #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            DateTime date = DateTime.Now;

            Console.WriteLine(date.ToString("dd-MM-yyyy"));

            Cashboxs cashbox = new Cashboxs();

            cashbox.date = date.Date;

            int result = Database.addCashBox(cashbox);

            if (result > 0)
            {
                MessageBox.Show("Caja iniciada, Dia " + date.ToString("dd-MM-yyyy"), "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemple #4
0
        private void button_deleteSale_Click(object sender, EventArgs e)
        {
            string            message = "Realmente desea anular la venta?";
            string            caption = "Confirmar anulación de venta";
            MessageBoxButtons buttons = MessageBoxButtons.YesNo;
            DialogResult      resultado;

            resultado = MessageBox.Show(message, caption, buttons);
            if (resultado == System.Windows.Forms.DialogResult.Yes)
            {
                //Actualiza la caja
                Cashboxs cashbox = new Cashboxs();
                cashbox.income = total_price;
                cashbox.date   = date.Date;
                int result_updateCashbox = Database.updateCashBox1(cashbox, "income");
                if (result_updateCashbox > 0)
                {
                    Console.WriteLine("Caja actualizada");
                }
                //Actualiza el stock de productos antes de borrar el detalle
                List <Detail> detail = new List <Detail>();
                detail = Database.getDetails(id);
                foreach (Detail d in detail)
                {
                    Database.updateAddStockProduct(d.product, d.quantity);
                }



                //Borra la venta de sale y el detalle
                int result = Database.deleteSale(id);
                if (result > 0)
                {
                    List <Sales_Display> list = new List <Sales_Display>();
                    list = Database.listSales(date.Date);
                    dataGridView_sales.DataSource = list;
                    MessageBox.Show("Venta anulada", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
        private void Main_Windows1_Load(object sender, EventArgs e)
        {
            date = DateTime.Now;
            int      count    = Database.getTotalSales(date.Date);
            Cashboxs cashboxs = new Cashboxs();

            cashboxs = Database.findCashBox(date.Date);
            int client      = Database.getTotalClient(date.Date);
            int product     = Database.getTotalProduct(date.Date);
            int work_orders = Database.getTotalWorkOrder(date.Date);

            this.CenterToScreen();
            containerPanel.Controls.Add(main.Instance);
            main.Instance.Dock             = DockStyle.Fill;
            main.Instance.salenumber       = count;
            main.Instance.total_account    = cashboxs.income;
            main.Instance.total_client     = client;
            main.Instance.total_product    = product;
            main.Instance.total_work_order = work_orders;
            main.Instance.BringToFront();
            welcomeLabel.Text = send_username;
        }
        private void cashboxButton_Click(object sender, EventArgs e)
        {
            date = DateTime.Now;
            Cashboxs cashboxs = new Cashboxs();

            cashboxs = Database.findCashBox(date.Date);
            if (!containerPanel.Controls.Contains(cashbox.Instance))
            {
                containerPanel.Controls.Add(cashbox.Instance);
                cashbox.Instance.income  = cashboxs.income;
                cashbox.Instance.outcome = cashboxs.outcome;
                cashbox.Instance.id      = send_username;
                cashbox.Instance.Dock    = DockStyle.Fill;
                cashbox.Instance.BringToFront();
            }
            else
            {
                cashbox.Instance.income  = cashboxs.income;
                cashbox.Instance.outcome = cashboxs.outcome;
                cashbox.Instance.BringToFront();
            }
        }
 private void salesButton_Click(object sender, EventArgs e)
 {
     if (!containerPanel.Controls.Contains(sale.Instance))
     {
         date = DateTime.Now;
         Cashboxs cashbox = new Cashboxs();
         cashbox = Database.findCashBox(date.Date);
         if (cashbox.date != date.Date)
         {
             MessageBox.Show("Inicia la caja del dia", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else
         {
             containerPanel.Controls.Add(sale.Instance);
             sale.Instance.Dock = DockStyle.Fill;
             sale.Instance.BringToFront();
             sale.Instance.username = send_username;
         }
     }
     else
     {
         sale.Instance.BringToFront();
     }
 }
Exemple #8
0
        private void button3_Click(object sender, EventArgs e)
        {
            GetTotal();
            string item  = (comboBox_paymentMethods.GetItemText(comboBox_paymentMethods.SelectedItem)).ToString();
            string error = string.Empty;

            if (label_subTotal.Text.Trim() != "$ 0" && item != "Seleccione método" && textBox_description.Text.Trim().Length != 0)
            {
                date = DateTime.Now;
                Work_Order work_order = new Work_Order();
                work_order.date           = Convert.ToDateTime(date.ToString("dd-MM-yyy HH:mm:ss"));
                work_order.total_account  = total;
                work_order.payment_method = Int32.Parse(comboBox_paymentMethods.SelectedValue.ToString());
                work_order.cashbox_date   = date.Date;
                work_order.description    = textBox_description.Text.Trim();

                if (textBox_rut.Text.Trim().Length == 0)
                {
                    MessageBox.Show("Ingresa el rut del cliente", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    if (Utils.validarRut(textBox_rut.Text.Trim()))
                    {
                        Clients client = new Clients();
                        client = Database.findClient(textBox_rut.Text.Trim());
                        if (client.Rut == null)
                        {
                            MessageBox.Show("Cliente no registrado", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            textBox_name.Text     = client.Name;
                            client_name           = client.Name;
                            textBox_lastName.Text = client.Last_name;
                            client_lastname       = client.Last_name;
                            textBox_email.Text    = client.Email;
                            client_email          = client.Email;
                            if (client.Phone == 0)
                            {
                                textBox_phone.Text = "";
                                client_phone       = "";
                            }
                            else
                            {
                                textBox_phone.Text = client.Phone.ToString();
                                client_phone       = client.Phone.ToString();
                            }
                            textBox_address.Text = client.Address;
                            client_address       = client.Address;

                            textBox_name.Enabled     = false;
                            textBox_lastName.Enabled = false;
                            textBox_email.Enabled    = false;
                            textBox_phone.Enabled    = false;
                            textBox_address.Enabled  = false;
                        }
                    }
                    else
                    {
                        MessageBox.Show("Ingresa un Rut válido para realizar la búsqueda", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        textBox_name.Enabled     = true;
                        textBox_lastName.Enabled = true;
                        textBox_email.Enabled    = true;
                        textBox_phone.Enabled    = true;
                        textBox_address.Enabled  = true;
                    }
                }
                work_order.client   = textBox_rut.Text.Trim();
                work_order.username = username;

                int result = Database.addWorkOrder(work_order);
                if (result > 0)
                {
                    a = result;
                    foreach (DataRow dtRow in detail_table.Rows)
                    {
                        Detail_Work_Order detail = new Detail_Work_Order();
                        detail.quantity    = Convert.ToInt32(dtRow["Cantidad"]);
                        detail.total_price = Convert.ToInt32(dtRow["Total"]);
                        detail.work_order  = result;
                        detail.product     = dtRow["Código"].ToString();
                        int result1 = Database.addDetailWorkOrder(detail);
                        resultado_insert_detail = result1;
                    }
                    if (resultado_insert_detail > 0)
                    {
                        MessageBox.Show("Orden de trabajo registrada", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        foreach (DataRow dtRow in detail_table.Rows)
                        {
                            try
                            {
                                int result2 = Database.updateStockProduct(dtRow["Código"].ToString(), Convert.ToInt32(dtRow["Cantidad"]));
                            }
                            catch
                            {
                            }
                        }
                        Cashboxs cashbox = new Cashboxs();
                        cashbox.date   = date.Date;
                        cashbox.income = total;
                        Console.WriteLine(total);
                        int result3 = Database.updateCashBox(cashbox, "income");

                        //AQUI VA EL CODIGO PARA EL INFORME
                        string path     = "C:\\OnlyiPhoneFiles\\Trabajos\\";
                        string filename = path + "Trabajo_" + result + ".pdf";

                        if (!Directory.Exists(path))
                        {
                            Directory.CreateDirectory(path);
                        }

                        Document  doc    = new Document(iTextSharp.text.PageSize.LETTER, 40, 30, 50, 30);
                        var       output = new FileStream(filename, FileMode.Create);
                        PdfWriter writer = PdfWriter.GetInstance(doc, output);
                        doc.Open();

                        date = DateTime.Now;
                        var normalFont = FontFactory.GetFont(FontFactory.HELVETICA, 14);
                        var boltFond   = FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 20);
                        doc.Add(Chunk.NEWLINE);



                        Paragraph title = new Paragraph();
                        title.Add(new Chunk("Detalle de Orden", boltFond));
                        title.Alignment = Element.ALIGN_TOP;
                        title.Alignment = Element.ALIGN_CENTER;
                        doc.Add(title);



                        Paragraph date_time = new Paragraph();
                        date_time.Alignment = Element.ALIGN_CENTER;
                        date_time.Add(new Chunk(date.ToString(), normalFont));
                        doc.Add(date_time);

                        Paragraph usernam = new Paragraph();
                        usernam.Add(new Chunk("Vendedor: " + username, normalFont));
                        usernam.Alignment = Element.ALIGN_CENTER;
                        doc.Add(usernam);

                        doc.Add(new Chunk("\n"));
                        doc.Add(new Chunk("\n"));
                        doc.Add(new Chunk("\n"));
                        doc.Add(new Chunk("\n"));
                        doc.Add(new Chunk("\n"));

                        Paragraph id_venta = new Paragraph();
                        id_venta.Add(new Chunk("N° Orden: " + result, normalFont));
                        id_venta.Alignment = Element.ALIGN_LEFT;
                        doc.Add(id_venta);

                        doc.Add(new Chunk("\n"));

                        Paragraph cliente = new Paragraph();
                        cliente.Add(new Chunk("Cliente: " + rut, normalFont));
                        cliente.Alignment = Element.ALIGN_LEFT;
                        doc.Add(cliente);


                        doc.Add(new Chunk("\n"));

                        Paragraph nombre = new Paragraph();
                        nombre.Add(new Chunk("Nombre: " + client_name + " " + client_lastname, normalFont));
                        nombre.Alignment = Element.ALIGN_LEFT;
                        doc.Add(nombre);

                        //doc.Add(new Chunk("\n"));

                        //Paragraph apellido = new Paragraph();
                        //apellido.Add(new Chunk("Apellido: " + client_lastname, normalFont));
                        //apellido.Alignment = Element.ALIGN_LEFT;
                        //doc.Add(apellido);

                        doc.Add(new Chunk("\n"));

                        Paragraph email = new Paragraph();
                        email.Add(new Chunk("Email: " + client_email, normalFont));
                        email.Alignment = Element.ALIGN_LEFT;
                        doc.Add(email);

                        doc.Add(new Chunk("\n"));

                        Paragraph telefono = new Paragraph();
                        telefono.Add(new Chunk("Teléfono: " + client_phone, normalFont));
                        telefono.Alignment = Element.ALIGN_LEFT;
                        doc.Add(telefono);

                        doc.Add(new Chunk("\n"));

                        Paragraph direccion = new Paragraph();
                        direccion.Add(new Chunk("Dirección: " + client_address, normalFont));
                        direccion.Alignment = Element.ALIGN_LEFT;
                        doc.Add(direccion);



                        iTextSharp.text.Image imagen = iTextSharp.text.Image.GetInstance(Properties.Resources._18740092_1851243531863286_2642745955361773779_n, System.Drawing.Imaging.ImageFormat.Png);
                        imagen.BorderWidth = 0;
                        imagen.Alignment   = Element.ALIGN_TOP;
                        imagen.Alignment   = Element.ALIGN_LEFT;
                        float percentage = 0.0f;
                        percentage = 110 / imagen.Width;
                        imagen.ScalePercent(percentage * 100);
                        imagen.SetAbsolutePosition(40, 630);
                        doc.Add(imagen);

                        Paragraph description_title = new Paragraph();
                        description_title.Add(new Chunk("Descripción", normalFont));
                        description_title.Alignment = Element.ALIGN_LEFT;
                        doc.Add(new Chunk("\n"));
                        doc.Add(description_title);

                        Paragraph description = new Paragraph(textBox_description.Text);
                        doc.Add(new Chunk("\n"));
                        doc.Add(description);
                        doc.Add(new Chunk("\n"));
                        PdfPTable table = new PdfPTable(detail_table.Columns.Count);
                        table.AddCell(new Phrase("Código"));
                        table.AddCell(new Phrase("Item"));
                        table.AddCell(new Phrase("Cantidad"));
                        table.AddCell(new Phrase("Precio"));
                        table.AddCell(new Phrase(Chunk.NEWLINE));
                        table.AddCell(new Phrase(Chunk.NEWLINE));
                        table.AddCell(new Phrase(Chunk.NEWLINE));
                        table.AddCell(new Phrase(Chunk.NEWLINE));

                        foreach (DataGridViewRow row in gridView_detail.Rows)
                        {
                            foreach (DataGridViewCell cell in row.Cells)
                            {
                                table.AddCell(cell.Value.ToString());
                            }
                        }
                        foreach (PdfPRow row in table.Rows)
                        {
                            int aux = 0;
                            foreach (PdfPCell cell in row.GetCells())
                            {
                                cell.Border = 0;
                                if (aux == 2)
                                {
                                    cell.HorizontalAlignment = PdfPCell.ALIGN_RIGHT;
                                    aux = 3;
                                }
                                else
                                {
                                    if (aux == 3)
                                    {
                                        cell.HorizontalAlignment = PdfPCell.ALIGN_RIGHT;
                                        aux = 0;
                                    }
                                    else
                                    {
                                        aux += 1;
                                    }
                                }
                            }
                        }
                        PdfPTable total_amount = new PdfPTable(1);
                        PdfPCell  separator    = new PdfPCell(new Phrase(Chunk.NEWLINE));
                        separator.BorderWidthBottom = 0;
                        separator.BorderWidthLeft   = 0;
                        separator.BorderWidthRight  = 0;
                        separator.BorderWidthTop    = 1;

                        string subtotal_detail  = "Subtotal    $  " + subtotal;
                        string descuento_detail = "Mano de obra   $ " + textBox_descuento.Text;
                        string total_detail     = "Total    $  " + total;

                        PdfPCell tmp1 = new PdfPCell(new Phrase(subtotal_detail));
                        PdfPCell tmp2 = new PdfPCell(new Phrase(descuento_detail));
                        PdfPCell tmp3 = new PdfPCell(new Phrase(total_detail));
                        tmp1.BorderWidthBottom   = 0;
                        tmp1.BorderWidthLeft     = 0;
                        tmp1.BorderWidthRight    = 0;
                        tmp1.BorderWidthTop      = 1;
                        tmp1.HorizontalAlignment = PdfPCell.ALIGN_RIGHT;
                        tmp2.Border = 0;
                        tmp2.HorizontalAlignment = PdfPCell.ALIGN_RIGHT;
                        tmp3.Border = 0;
                        tmp3.HorizontalAlignment = PdfPCell.ALIGN_RIGHT;
                        total_amount.AddCell(tmp1);
                        total_amount.AddCell(tmp2);
                        total_amount.AddCell(separator);
                        total_amount.AddCell(tmp3);

                        doc.Add(new Chunk("\n"));
                        doc.Add(table);
                        doc.Add(total_amount);

                        doc.Add(new Chunk("\n"));
                        string    aditionalText       = getInfoAppSettings("workOrderText");
                        Paragraph agreementConditions = new Paragraph(aditionalText);
                        doc.Add(agreementConditions);

                        doc.Add(new Chunk("\n"));

                        Paragraph signature = new Paragraph("FIRMA: ____________________");
                        signature.Alignment = Element.ALIGN_RIGHT;
                        doc.Add(signature);

                        doc.Close();

                        System.Diagnostics.Process.Start(filename);

                        this.Close();
                    }
                }
            }
            else
            {
                if (label_subTotal.Text.Trim() == "$ 0")
                {
                    error = "- Ingresa productos a la lista" + "\n\r";
                }
                if (item == "Seleccione método")
                {
                    error = error + "- Elige método de pago" + "\n\r";
                }
                if (textBox_description.Text.Trim().Length == 0)
                {
                    error = error + "- Descripción vacia" + "\n\r";
                }
                MessageBox.Show(error, "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }