コード例 #1
0
        private void BusquedaTextBox_TextChanged(object sender, EventArgs e)
        {
            string busqueda = busquedaTextBox.Text.Replace("'", "\\'").Trim();

            stockDataGridView.DataSource = ConsultasSql.Busqueda(tabla: "product", condicion: "name", valor: $"{busqueda}", "stock", "ASC", "stock_indicator", "ASC", campo: "name, stock, minimum_stock_level, stock_indicator");
            stockDataGridView.ClearSelection();
        }
コード例 #2
0
        public void DatosIniciales()
        {
            listadoDataGridView.DataSource = ConsultasSql.ConsultaGeneral(TableBdd);

            listadoDataGridView.Columns["number"].HeaderText = "NÚMERO";
            listadoDataGridView.Columns["number"].Width      = 110;
            listadoDataGridView.Columns["number"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            listadoDataGridView.Columns["name"].Width               = 180;
            listadoDataGridView.Columns["name"].HeaderText          = "CONTACTO";
            listadoDataGridView.Columns["date_of_issue"].HeaderText = "FECHA";
            listadoDataGridView.Columns["date_of_issue"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
            listadoDataGridView.Columns["date_of_issue"].DefaultCellStyle.Format    = "MMMM dd, yyyy";
            listadoDataGridView.Columns["product"].HeaderText  = "PRODUCTO";
            listadoDataGridView.Columns["product"].Width       = 120;
            listadoDataGridView.Columns["quantity"].HeaderText = "CANT.";
            listadoDataGridView.Columns["quantity"].Width      = 50;
            listadoDataGridView.Columns["quantity"].DefaultCellStyle.Format       = "N0";
            listadoDataGridView.Columns["quantity"].DefaultCellStyle.Alignment    = DataGridViewContentAlignment.MiddleRight;
            listadoDataGridView.Columns["total_value"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            listadoDataGridView.Columns["type_document"].HeaderText = "TIPO";
            listadoDataGridView.Columns["type_document"].Width      = 65;
            listadoDataGridView.Columns["type_document"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
            listadoDataGridView.Columns["status_document"].HeaderText = "ESTADO";
            listadoDataGridView.Columns["status_document"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
            listadoDataGridView.Columns["status_document"].Width = 70;

            listadoDataGridView.Columns["total_value"].Visible        = false;
            listadoDataGridView.Columns["idDocument"].Visible         = false;
            listadoDataGridView.Columns["invoice_detailment"].Visible = false;
            listadoDataGridView.Columns["payment_method"].Visible     = false;
            listadoDataGridView.Columns["subtotal"].Visible           = false;
        }
コード例 #3
0
        public void Busqueda()
        {
            string busqueda = busquedaTextBox.Text.Replace("'", "\\'").Trim();

            listadoDataGridView.DataSource = ConsultasSql.Busqueda(tabla: TableBdd, condicion: "name", valor: $"{ busqueda }");
            listadoDataGridView.Sort(listadoDataGridView.Columns["name"], ListSortDirection.Ascending);
        }
コード例 #4
0
        private void Guardar()
        {
            string name = descripcionTextBox.Text.Replace("'", "\\'").Trim();

            if (name.Length > 0)
            {
                if (aceptarButton.Text == "Actualizar")
                {
                    if (ConsultasSql.Actualizar(TableBdd, $"name = '{name}'", "id", $"'{IdField}'"))
                    {
                        CerrarYRefrescarFormulario();
                    }
                }

                if (aceptarButton.Text == "Guardar")
                {
                    if (ConsultasSql.Insertar(TableBdd, "name", $"'{ name }'"))
                    {
                        CerrarYRefrescarFormulario();
                    }
                }
            }
            else
            {
                MessageBox.Show("Campo descripcion en blanco");
            }
        }
コード例 #5
0
        private void listadoDataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0 && listadoDataGridView.CurrentCell.OwningColumn.Name == "editButton")
            {
                DatosGuardarActualizar
                (
                    listadoDataGridView.Rows[e.RowIndex].Cells["id"].Value.ToString(),
                    "Actualizar",
                    listadoDataGridView.Rows[e.RowIndex].Cells["id_number"].Value.ToString(),
                    listadoDataGridView.Rows[e.RowIndex].Cells["business_name"].Value.ToString(),
                    listadoDataGridView.Rows[e.RowIndex].Cells["tradename"].Value.ToString(),
                    listadoDataGridView.Rows[e.RowIndex].Cells["address"].Value.ToString(),
                    listadoDataGridView.Rows[e.RowIndex].Cells["landline"].Value.ToString(),
                    listadoDataGridView.Rows[e.RowIndex].Cells["mobile_phone"].Value.ToString(),
                    listadoDataGridView.Rows[e.RowIndex].Cells["email"].Value.ToString(),
                    listadoDataGridView.Rows[e.RowIndex].Cells["client"].Value.ToString(),
                    listadoDataGridView.Rows[e.RowIndex].Cells["provider"].Value.ToString(),
                    listadoDataGridView.Rows[e.RowIndex].Cells["special_taxpayer"].Value.ToString(),
                    listadoDataGridView.Rows[e.RowIndex].Cells["additional_information"].Value.ToString(),
                    listadoDataGridView.Rows[e.RowIndex].Cells["typeIdentificationId"].Value.ToString()
                );
            }

            if (e.RowIndex >= 0 && listadoDataGridView.CurrentCell.OwningColumn.Name == "deleteButton")
            {
                if (MessageBox.Show($"¿Estas seguro que deseas eliminar a {listadoDataGridView.Rows[e.RowIndex].Cells["business_name"].Value}?", "Eliminar contacto", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                {
                    if (ConsultasSql.Eliminar(TableBdd, "id", $"'{listadoDataGridView.Rows[e.RowIndex].Cells["id"].Value}'"))
                    {
                        DatosIniciales();
                    }
                }
            }
        }
コード例 #6
0
        public void DatosIniciales()
        {
            listadoDataGridView.DataSource = ConsultasSql.ConsultaGeneral(TableBdd, campoOrden: "business_name");
            listadoDataGridView.Sort(listadoDataGridView.Columns["business_name"], ListSortDirection.Ascending);
            listadoDataGridView.Columns["business_name"].HeaderText = "Nombre";
            listadoDataGridView.Columns["business_name"].Width      = 320;

            listadoDataGridView.Columns["id_number"].HeaderText = "Identificación";
            listadoDataGridView.Columns["landline"].HeaderText  = "Telefono";
            listadoDataGridView.Columns["landline"].Width       = 90;
            listadoDataGridView.Columns["email"].HeaderText     = "Correo";
            listadoDataGridView.Columns["email"].Width          = 120;

            listadoDataGridView.Columns["id"].Visible                     = false;
            listadoDataGridView.Columns["tradename"].Visible              = false;
            listadoDataGridView.Columns["address"].Visible                = false;
            listadoDataGridView.Columns["mobile_phone"].Visible           = false;
            listadoDataGridView.Columns["client"].Visible                 = false;
            listadoDataGridView.Columns["provider"].Visible               = false;
            listadoDataGridView.Columns["special_taxpayer"].Visible       = false;
            listadoDataGridView.Columns["additional_information"].Visible = false;
            listadoDataGridView.Columns["status"].Visible                 = false;
            listadoDataGridView.Columns["created_at"].Visible             = false;
            listadoDataGridView.Columns["modified_at"].Visible            = false;
            listadoDataGridView.Columns["revision"].Visible               = false;
            listadoDataGridView.Columns["typeIdentificationId"].Visible   = false;
        }
コード例 #7
0
        private void AddPresetButton_Click(object sender, EventArgs e)
        {
            parameterDataTable           = ConsultasSql.ConsultaGeneral(TableBdd, campoOrden: "preset");
            presetComboBox.DataSource    = parameterDataTable;
            presetComboBox.DisplayMember = "preset";
            presetComboBox.ValueMember   = "id";
            DataRow dataRow = parameterDataTable.NewRow();

            dataRow["id"]     = "nulo";
            dataRow["preset"] = presetComboBox.Items.Count + 1;
            parameterDataTable.Rows.Add(dataRow);
            parameterDataTable.DefaultView.Sort = "preset desc";
            presetComboBox.DataSource           = parameterDataTable;

            printerNameComboBox.SelectedIndex = 0;
            fontFamilyComboBox.SelectedIndex  = 0;
            fontSizeTextBox.Text        = "8";
            headerXTextBox.Text         = "0";
            headerYTextBox.Text         = "0";
            mainXTextBox.Text           = "0";
            mainYTextBox.Text           = "0";
            footerXTextBox.Text         = "0";
            footerYTextBox.Text         = "0";
            numberDocument1TextBox.Text = "000";
            numberDocument2TextBox.Text = "000";
            numberDocument3TextBox.Text = "000000000";
            aceptarButton.Text          = "Guardar";
        }
コード例 #8
0
        public void Busqueda()
        {
            string busqueda = busquedaTextBox.Text.Replace("'", "\\'").Trim();

            listadoDataGridView.DataSource = ConsultasSql.Busqueda(TableBdd, "business_name", $"{ busqueda }", campoOrden: "business_name");
            listadoDataGridView.Sort(listadoDataGridView.Columns["business_name"], ListSortDirection.Ascending);
        }
コード例 #9
0
        private void CargaContacto(string campoCondicion, TextBox textBox)
        {
            string campoValor = textBox.Text.Replace("'", "\\'").Trim();

            DataTableContacto = ConsultasSql.Busqueda(tabla: "contact", condicion: campoCondicion, valor: campoValor, campo: "id, id_number, business_name, address, landline", campoOrden: "business_name");
            if (campoValor.Length > 0 && DataTableContacto.Rows.Count > 0)
            {
                ContactoDataGridView.DataSource               = DataTableContacto;
                ContactoDataGridView.Size                     = new Size(350, 120);
                ContactoDataGridView.Location                 = new Point(textBox.Location.X + 10, textBox.Location.Y + 26);
                ContactoDataGridView.ColumnHeadersVisible     = false;
                ContactoDataGridView.RowHeadersVisible        = false;
                ContactoDataGridView.AllowUserToAddRows       = false;
                ContactoDataGridView.AllowUserToDeleteRows    = false;
                ContactoDataGridView.BackgroundColor          = Color.White;
                ContactoDataGridView.AllowUserToResizeColumns = false;
                ContactoDataGridView.AllowUserToResizeRows    = false;
                ContactoDataGridView.SelectionMode            = DataGridViewSelectionMode.FullRowSelect;
                ContactoDataGridView.ReadOnly                 = true;

                Controls.Add(ContactoDataGridView);
                ContactoDataGridView.BringToFront();
                ContactoDataGridView.Visible = true;

                ContactoDataGridView.Columns["id_number"].Width     = 90;
                ContactoDataGridView.Columns["business_name"].Width = 256;
                ContactoDataGridView.Columns["id"].Visible          = false;
                ContactoDataGridView.Columns["address"].Visible     = false;
                ContactoDataGridView.Columns["landline"].Visible    = false;
            }
            else
            {
                ContactoDataGridView.Visible = false;
            }
        }
コード例 #10
0
        public void CargarDatos(int presetIndex = 0)
        {
            parameterDataTable           = ConsultasSql.ConsultaGeneral(TableBdd, campoOrden: "preset");
            presetComboBox.DataSource    = parameterDataTable;
            presetComboBox.DisplayMember = "preset";
            presetComboBox.ValueMember   = "id";
            DataRow dataRow = parameterDataTable.Rows[presetIndex];

            printerNameComboBox.Text      = dataRow["printerName"].ToString();
            fontFamilyComboBox.Text       = dataRow["printerFontFamily"].ToString();
            fontSizeTextBox.Text          = dataRow["printerFontSize"].ToString();
            headerXTextBox.Text           = dataRow["printerHeaderPositionX"].ToString();
            headerYTextBox.Text           = dataRow["printerHeaderPositionY"].ToString();
            mainXTextBox.Text             = dataRow["printerMainPositionX"].ToString();
            mainYTextBox.Text             = dataRow["printerMainPositionY"].ToString();
            footerXTextBox.Text           = dataRow["printerFooterPositionX"].ToString();
            footerYTextBox.Text           = dataRow["printerFooterPositionY"].ToString();
            printerPageHeightTextBox.Text = dataRow["printerPageHeight"].ToString();
            printerPageWidthTextBox.Text  = dataRow["printerPageWidth"].ToString();
            string numberInvoice = dataRow["numberInvoice"].ToString();

            numberDocument1TextBox.Text = numberInvoice.Substring(0, 3);
            numberDocument2TextBox.Text = numberInvoice.Substring(3, 3);
            numberDocument3TextBox.Text = numberInvoice.Substring(6, 9);
            aceptarButton.Text          = "Actualizar";
        }
コード例 #11
0
 private void IdNumberTextBox_TextChanged(object sender, EventArgs e)
 {
     if (idNumberTextBox.Text.Trim() != "9999999999999")
     {
         CargaContacto("id_number", idNumberTextBox);
     }
     if (ConsultasSql.VerificarItemExistente("contact", "id, id_number", "id_number", "=", idNumberTextBox.Text))
     {
         IdContact = "";
         if (idNumberTextBox.Text.Trim().Length >= 10)
         {
             IdContact           = "nuevo";
             idContactLabel.Text = "** PROVEEDOR NUEVO **";
         }
         else
         {
             IdContact           = "";
             idContactLabel.Text = "";
         }
     }
     else
     {
         idContactLabel.Text = "";
     }
 }
コード例 #12
0
        private void InicioSesion()
        {
            Acceso = Conexion.InicializarInstanciaMySQL(Conexion.User, Conexion.Password, Settings.Default.servidor, Conexion.Database);
            if (Acceso == "True")
            {
                DataTableUser = ConsultasSql.ConsultaIndividual("user", "*", "username", "=", $"{ textBoxUsuario.Text }", "password", "=", $"{ textBoxClave.Text }");
                if (DataTableUser.Rows.Count >= 1)
                {
                    Settings.Default.username = textBoxUsuario.Text;
                    Settings.Default.Save();
                    Settings.Default.Reload();
                    MainForm.Show();
                    Hide();
                }
                else
                {
                    MessageBox.Show("Usuario y/o contraseña erroneos", "CompudavSystem", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    Intentos += 1;

                    if (Intentos >= 3)
                    {
                        textBoxClave.Text   = "";
                        textBoxUsuario.Text = "";
                        textBoxUsuario.Focus();
                    }
                    else
                    {
                        textBoxClave.Text = "";
                        textBoxClave.Focus();
                    }
                }
            }
        }
コード例 #13
0
 private void CargaDeDatosCombobox(ComboBox comboBox, string table, string displayMember = "name", string valueMember = "id", string campoOrden = "name")
 {
     comboBox.DataSource         = ConsultasSql.ConsultaGeneral(table, campoOrden: campoOrden);
     comboBox.DisplayMember      = displayMember;
     comboBox.ValueMember        = valueMember;
     comboBox.AutoCompleteSource = AutoCompleteSource.ListItems;
     comboBox.AutoCompleteMode   = AutoCompleteMode.SuggestAppend;
 }
コード例 #14
0
        public void Busqueda()
        {
            DateTime dateTimeStart = toDateTimePicker.Value;
            string   fechaInicio   = $"'{dateTimeStart: yyyy-MM-dd} 00:00:00'";
            DateTime dateTimeEnd   = fromDateTimePicker.Value;
            string   fechaFin      = $"'{dateTimeEnd: yyyy-MM-dd} 23:59:59'";
            string   busqueda      = busquedaTextBox.Text.Replace("'", "\\'").Trim();

            listadoDataGridView.DataSource = ConsultasSql.Busqueda(tabla: TableBdd, condicion1: "name", condicion2: "number", condicion3: "product", valor: $"{ busqueda }", campoFecha: "date_of_issue", fechaInicio: $"{ fechaInicio }", fechaFin: $"{ fechaFin }", campo: "*", campoOrden: "date_of_issue", orden: "DESC");
        }
コード例 #15
0
        public void DatosIniciales()
        {
            listadoDataGridView.DataSource = ConsultasSql.ConsultaGeneral(TableBdd);
            listadoDataGridView.Sort(listadoDataGridView.Columns["name"], ListSortDirection.Ascending);
            listadoDataGridView.Columns["name"].HeaderText = "Descripción";
            listadoDataGridView.Columns["name"].Width      = 242;

            listadoDataGridView.Columns["id"].Visible          = false;
            listadoDataGridView.Columns["revision"].Visible    = false;
            listadoDataGridView.Columns["status"].Visible      = false;
            listadoDataGridView.Columns["created_at"].Visible  = false;
            listadoDataGridView.Columns["modified_at"].Visible = false;
        }
コード例 #16
0
        private void GetIdContact(string idNumber)
        {
            DataTable data = ConsultasSql.ConsultaIndividual("contact", "id", "id_number", "=", idNumber);

            if (data.Rows.Count > 0)
            {
                IdContact = data.Rows[0][0].ToString();
            }
            else
            {
                IdContact = "nuevo";
            }
        }
コード例 #17
0
        private void Guardar()
        {
            string idNumber     = (idNumberTextBox.Text.Trim() == "") ? "null" : $"'{idNumberTextBox.Text.Trim()}'";
            string businessName = businessNameTextBox.Text.Replace("'", "\\'").Trim();

            businessName = (businessName == "") ? "null" : $"'{businessName}'";
            string tradename = tradenameTextBox.Text.Replace("'", "\\'").Trim();

            tradename = (tradename == "") ? "null" : $"'{tradename}'";
            string address = addressTextBox.Text.Replace("'", "\\'").Trim();

            address = (address == "") ? "null" : $"'{address}'";
            string landline    = (landlineTextBox.Text.Trim() == "") ? "null" : $"'{landlineTextBox.Text.Trim()}'";
            string mobilePhone = (mobilePhoneTextBox.Text.Trim() == "") ? "null" : $"'{mobilePhoneTextBox.Text.Trim()}'";
            string email       = emailTextBox.Text.Replace("'", "\\'").Trim();

            email = (email == "") ? "null" : $"'{email}'";
            bool   client                = clientCheckBox.Checked;
            bool   provider              = providerCheckBox.Checked;
            bool   specialTaxpayer       = specialTaxpayerCheckBox.Checked;
            string additionalInformation = additionalInformationTextBox.Text.Replace("'", "\\'").Trim();

            additionalInformation = (additionalInformation == "") ? "null" : $"'{additionalInformation}'";
            string typeIdentification = (typeIdentificationComboBox.SelectedValue.ToString() == "nulo") ? "null" : $"'{typeIdentificationComboBox.SelectedValue}'";

            if (aceptarButton.Text == "Actualizar")
            {
                if (ConsultasSql.Actualizar(TableBdd,
                                            $"id_number = {idNumber}, business_name = {businessName}, tradename = {tradename}, address = {address}, " +
                                            $"landline = {landline}, mobile_phone = {mobilePhone}, email = {email}, client = {client}, provider = {provider}, " +
                                            $"special_taxpayer = {specialTaxpayer}, additional_information = {additionalInformation}, typeIdentificationId = {typeIdentification}",
                                            "id", $"'{IdField}'"))
                {
                    CerrarYRefrescarFormulario();
                }
            }

            if (aceptarButton.Text == "Guardar")
            {
                if (ConsultasSql.Insertar(
                        TableBdd,
                        "id_number, business_name, tradename, address, landline, mobile_phone, " +
                        "email, client, provider, special_taxpayer, additional_information, typeIdentificationId",
                        $"{idNumber}, {businessName}, {tradename}, {address}, {landline}, {mobilePhone}, {email}, " +
                        $"{client}, {provider}, {specialTaxpayer}, {additionalInformation}, {typeIdentification}"
                        ))
                {
                    CerrarYRefrescarFormulario();
                }
            }
        }
コード例 #18
0
        private void FiltrarProducto()
        {
            string campoValor = BusquedaProductoTextBox.Text.Replace("'", "\\'").Trim();

            DataTableProducto = ConsultasSql.Busqueda(tabla: "product_iva_rate_view", condicion1: "name", condicion2: "main_code", valor: campoValor, campo: "id, main_code, name, stock, cost, iva_rate_name");
            ProductoDataGridView.DataSource = DataTableProducto;

            ProductoDataGridView.Columns["main_code"].Width       = 100;
            ProductoDataGridView.Columns["name"].Width            = 275;
            ProductoDataGridView.Columns["id"].Visible            = false;
            ProductoDataGridView.Columns["stock"].Visible         = false;
            ProductoDataGridView.Columns["cost"].Visible          = false;
            ProductoDataGridView.Columns["iva_rate_name"].Visible = false;
        }
コード例 #19
0
        private void ListadoDataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0 && listadoDataGridView.CurrentCell.OwningColumn.Name == "editButton")
            {
                DatosGuardarActualizar
                (
                    listadoDataGridView.Rows[e.RowIndex].Cells["id"].Value.ToString(),
                    "Actualizar",
                    listadoDataGridView.Rows[e.RowIndex].Cells["main_code"].Value.ToString(),
                    listadoDataGridView.Rows[e.RowIndex].Cells["aux_code"].Value.ToString(),
                    listadoDataGridView.Rows[e.RowIndex].Cells["name"].Value.ToString(),
                    listadoDataGridView.Rows[e.RowIndex].Cells["detail"].Value.ToString(),
                    listadoDataGridView.Rows[e.RowIndex].Cells["stock"].Value.ToString(),
                    listadoDataGridView.Rows[e.RowIndex].Cells["minimum_stock_level"].Value.ToString(),
                    listadoDataGridView.Rows[e.RowIndex].Cells["cost"].Value.ToString(),
                    listadoDataGridView.Rows[e.RowIndex].Cells["percentage_price"].Value.ToString(),
                    listadoDataGridView.Rows[e.RowIndex].Cells["price"].Value.ToString(),
                    listadoDataGridView.Rows[e.RowIndex].Cells["pvp"].Value.ToString(),
                    listadoDataGridView.Rows[e.RowIndex].Cells["percentage_price2"].Value.ToString(),
                    listadoDataGridView.Rows[e.RowIndex].Cells["price2"].Value.ToString(),
                    listadoDataGridView.Rows[e.RowIndex].Cells["pvp2"].Value.ToString(),
                    listadoDataGridView.Rows[e.RowIndex].Cells["percentage_price3"].Value.ToString(),
                    listadoDataGridView.Rows[e.RowIndex].Cells["price3"].Value.ToString(),
                    listadoDataGridView.Rows[e.RowIndex].Cells["pvp3"].Value.ToString(),
                    listadoDataGridView.Rows[e.RowIndex].Cells["categoryId"].Value.ToString(),
                    listadoDataGridView.Rows[e.RowIndex].Cells["manufacturerId"].Value.ToString(),
                    listadoDataGridView.Rows[e.RowIndex].Cells["iceRateId"].Value.ToString(),
                    listadoDataGridView.Rows[e.RowIndex].Cells["ivaRateId"].Value.ToString(),
                    listadoDataGridView.Rows[e.RowIndex].Cells["typeProductId"].Value.ToString(),
                    listadoDataGridView.Rows[e.RowIndex].Cells["unitMeasurementId"].Value.ToString()
                );
            }

            if (e.RowIndex >= 0 && listadoDataGridView.CurrentCell.OwningColumn.Name == "deleteButton")
            {
                if (MessageBox.Show($"¿Estas seguro que deseas eliminar {listadoDataGridView.Rows[e.RowIndex].Cells["name"].Value} del catálogo?", "Eliminar item", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                {
                    if (ConsultasSql.Eliminar(TableBdd, "id", $"'{listadoDataGridView.Rows[e.RowIndex].Cells["id"].Value}'"))
                    {
                        DatosIniciales();
                    }
                }
            }
        }
コード例 #20
0
        private void AceptarButton_Click(object sender, EventArgs e)
        {
            string preset                 = $"'{presetComboBox.Text}'";
            string printerName            = $"'{printerNameComboBox.Text}'";
            string printerFontFamily      = $"'{fontFamilyComboBox.Text}'";
            string printerFontSize        = $"{fontSizeTextBox.Text}";
            string printerHeaderPositionX = $"{headerXTextBox.Text}";
            string printerHeaderPositionY = $"{headerYTextBox.Text}";
            string printerMainPositionX   = $"{mainXTextBox.Text}";
            string printerMainPositionY   = $"{mainYTextBox.Text}";
            string printerFooterPositionX = $"{footerXTextBox.Text}";
            string printerFooterPositionY = $"{footerYTextBox.Text}";
            string printerPageWidth       = $"{printerPageWidthTextBox.Text}";
            string printerPageHeight      = $"{printerPageHeightTextBox.Text}";
            string numberInvoice          = $"'{numberDocument1TextBox.Text}{numberDocument2TextBox.Text}{numberDocument3TextBox.Text}'";

            if (aceptarButton.Text == "Guardar")
            {
                if (ConsultasSql.Insertar(TableBdd,
                                          "preset, printerName, printerFontFamily, printerFontSize, printerHeaderPositionX, " +
                                          "printerHeaderPositionY, printerMainPositionX, printerMainPositionY, " +
                                          "printerFooterPositionX, printerFooterPositionY, printerPageWidth, printerPageHeight, numberInvoice",
                                          $"{preset}, {printerName}, {printerFontFamily}, {printerFontSize}, {printerHeaderPositionX}, " +
                                          $"{printerHeaderPositionY}, {printerMainPositionX}, {printerMainPositionY}, " +
                                          $"{printerFooterPositionX}, {printerFooterPositionY}, {printerPageWidth}, {printerPageHeight}, {numberInvoice}"
                                          ))
                {
                    CargarDatos();
                }
            }
            if (aceptarButton.Text == "Actualizar")
            {
                if (ConsultasSql.Actualizar(TableBdd,
                                            $"preset = {preset}, printerName = {printerName}, printerFontFamily = {printerFontFamily}, printerFontSize = {printerFontSize}, " +
                                            $"printerHeaderPositionX = {printerHeaderPositionX}, printerHeaderPositionY = {printerHeaderPositionY}, printerMainPositionX = {printerMainPositionX}, " +
                                            $"printerMainPositionY = {printerMainPositionY}, printerFooterPositionX = {printerFooterPositionX}, printerFooterPositionY = {printerFooterPositionY}, " +
                                            $"printerPageWidth = {printerPageWidth}, printerPageHeight = {printerPageHeight}, numberInvoice = {numberInvoice}",
                                            "id", $"'{presetComboBox.SelectedValue}'"))
                {
                    MessageBox.Show("Preset actualizado correctamente");
                }
            }
        }
コード例 #21
0
 private void ListadoDataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex >= 0 && listadoDataGridView.CurrentCell.OwningColumn.Name == "anularButton")
     {
         if ($"{listadoDataGridView.Rows[e.RowIndex].Cells["status_document"].Value}" == "Anulado")
         {
             MessageBox.Show("Factura anulada", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else
         {
             if (MessageBox.Show($"¿Estas seguro que deseas anular la factura \n#{listadoDataGridView.Rows[e.RowIndex].Cells["number"].Value} del contacto \n{listadoDataGridView.Rows[e.RowIndex].Cells["name"].Value}?", "Anular factura", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
             {
                 DataTable dataStatus       = ConsultasSql.ConsultaIndividual("status_document", "id", "name", "=", "Anulado");
                 string    statusDocumentId = dataStatus.Rows[0][0].ToString();
                 if (ConsultasSql.Actualizar("document", $"statusDocumentId = '{statusDocumentId}'", "id", $"'{listadoDataGridView.Rows[e.RowIndex].Cells["idDocument"].Value}'"))
                 {
                     DataTable dataInvoiceDetailment = ConsultasSql.ConsultaIndividual("invoice_detailment", "quantity, productId", "documentId", "=", $"{listadoDataGridView.Rows[e.RowIndex].Cells["idDocument"].Value}");
                     for (int i = 0; i < dataInvoiceDetailment.Rows.Count; i++)
                     {
                         DataTable dataMinimumStock = ConsultasSql.ConsultaIndividual("product", "stock, minimum_stock_level", "id", "=", $"{dataInvoiceDetailment.Rows[i]["productId"]}");
                         int       minimumStockInt  = int.Parse(dataMinimumStock.Rows[0][1].ToString());
                         int       stockInt         = int.Parse(dataMinimumStock.Rows[0][0].ToString());
                         decimal   quantityDecimal  = decimal.Parse(dataInvoiceDetailment.Rows[i][0].ToString());
                         int       quantityInt      = Convert.ToInt32(quantityDecimal);
                         if ($"{listadoDataGridView.Rows[e.RowIndex].Cells["type_document"].Value}" == "COMPRA")
                         {
                             stockInt -= quantityInt;
                             ConsultasSql.Actualizar("product", $"stock = {stockInt}, stock_indicator = { stockInt - minimumStockInt}", "id", $"'{dataInvoiceDetailment.Rows[i]["productId"]}'");
                         }
                         if ($"{listadoDataGridView.Rows[e.RowIndex].Cells["type_document"].Value}" == "VENTA")
                         {
                             stockInt += quantityInt;
                             ConsultasSql.Actualizar("product", $"stock = {stockInt}, stock_indicator = { stockInt + minimumStockInt}", "id", $"'{dataInvoiceDetailment.Rows[i]["productId"]}'");
                         }
                     }
                     DatosIniciales();
                 }
             }
         }
     }
 }
コード例 #22
0
        public void DatosIniciales()
        {
            listadoDataGridView.DataSource = ConsultasSql.ConsultaGeneral(TableBdd);
            listadoDataGridView.Sort(listadoDataGridView.Columns["name"], ListSortDirection.Ascending);
            listadoDataGridView.Columns["name"].HeaderText = "Descripción";
            listadoDataGridView.Columns["name"].Width      = 364;

            listadoDataGridView.Columns["cost"].HeaderText  = "Costo";
            listadoDataGridView.Columns["cost"].Width       = 65;
            listadoDataGridView.Columns["pvp"].HeaderText   = "Oferta";
            listadoDataGridView.Columns["pvp"].Width        = 65;
            listadoDataGridView.Columns["pvp2"].HeaderText  = "Normal";
            listadoDataGridView.Columns["pvp2"].Width       = 65;
            listadoDataGridView.Columns["stock"].HeaderText = "Stock";
            listadoDataGridView.Columns["stock"].Width      = 55;

            listadoDataGridView.Columns["id"].Visible                  = false;
            listadoDataGridView.Columns["main_code"].Visible           = false;
            listadoDataGridView.Columns["aux_code"].Visible            = false;
            listadoDataGridView.Columns["detail"].Visible              = false;
            listadoDataGridView.Columns["minimum_stock_level"].Visible = false;
            listadoDataGridView.Columns["stock_indicator"].Visible     = false;
            listadoDataGridView.Columns["percentage_price"].Visible    = false;
            listadoDataGridView.Columns["price"].Visible               = false;
            listadoDataGridView.Columns["percentage_price2"].Visible   = false;
            listadoDataGridView.Columns["price2"].Visible              = false;
            listadoDataGridView.Columns["percentage_price3"].Visible   = false;
            listadoDataGridView.Columns["price3"].Visible              = false;
            listadoDataGridView.Columns["pvp3"].Visible                = false;
            listadoDataGridView.Columns["status"].Visible              = false;
            listadoDataGridView.Columns["created_at"].Visible          = false;
            listadoDataGridView.Columns["modified_at"].Visible         = false;
            listadoDataGridView.Columns["revision"].Visible            = false;
            listadoDataGridView.Columns["categoryId"].Visible          = false;
            listadoDataGridView.Columns["manufacturerId"].Visible      = false;
            listadoDataGridView.Columns["iceRateId"].Visible           = false;
            listadoDataGridView.Columns["ivaRateId"].Visible           = false;
            listadoDataGridView.Columns["typeProductId"].Visible       = false;
            listadoDataGridView.Columns["unitMeasurementId"].Visible   = false;
        }
コード例 #23
0
 private void PresetComboBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     dataFilter = ConsultasSql.ConsultaIndividual(TableBdd, "*", "preset", "=", presetComboBox.Text);
     if (dataFilter.Rows.Count > 0)
     {
         DataRow dataRow = dataFilter.Rows[0];
         printerNameComboBox.Text      = dataRow["printerName"].ToString();
         fontFamilyComboBox.Text       = dataRow["printerFontFamily"].ToString();
         fontSizeTextBox.Text          = dataRow["printerFontSize"].ToString();
         headerXTextBox.Text           = dataRow["printerHeaderPositionX"].ToString();
         headerYTextBox.Text           = dataRow["printerHeaderPositionY"].ToString();
         mainXTextBox.Text             = dataRow["printerMainPositionX"].ToString();
         mainYTextBox.Text             = dataRow["printerMainPositionY"].ToString();
         footerXTextBox.Text           = dataRow["printerFooterPositionX"].ToString();
         footerYTextBox.Text           = dataRow["printerFooterPositionY"].ToString();
         printerPageHeightTextBox.Text = dataRow["printerPageHeight"].ToString();
         printerPageWidthTextBox.Text  = dataRow["printerPageWidth"].ToString();
         string numberInvoice = dataRow["numberInvoice"].ToString();
         numberDocument1TextBox.Text = numberInvoice.Substring(0, 3);
         numberDocument2TextBox.Text = numberInvoice.Substring(3, 3);
         numberDocument3TextBox.Text = numberInvoice.Substring(6, 9);
     }
 }
コード例 #24
0
        private void ListadoDataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0 && listadoDataGridView.CurrentCell.OwningColumn.Name == "editButton")
            {
                DatosGuardarActualizar
                (
                    listadoDataGridView.Rows[e.RowIndex].Cells["id"].Value.ToString(),
                    "Actualizar",
                    listadoDataGridView.Rows[e.RowIndex].Cells["name"].Value.ToString()
                );
            }

            if (e.RowIndex >= 0 && listadoDataGridView.CurrentCell.OwningColumn.Name == "deleteButton")
            {
                if (MessageBox.Show("¿Estas seguro que deseas eliminar este item?", "Eliminar item", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                {
                    if (ConsultasSql.Eliminar(TableBdd, "id", $"'{listadoDataGridView.Rows[e.RowIndex].Cells["id"].Value}'"))
                    {
                        DatosIniciales();
                    }
                }
            }
        }
コード例 #25
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            PrinterFont       = new Font(Settings.Default.printerFontFamily, Settings.Default.printerFontSize, FontStyle.Regular);
            PrinterName       = Settings.Default.printerName;
            printerLabel.Text = PrinterName;

            ValidaCampo.Requerido(idNumberTextBox, "Por favor ingrese el numero de Identificación");
            ValidaCampo.Requerido(nameTextBox, "Por favor ingrese el Nombre");
            ValidaCampo.Requerido(addressTextBox, "Por favor ingrese la Dirección");
            ValidaCampo.Requerido(listadoDataGridView, mainPanel, "Por favor selecciona al menos un item");
            ValidaCampo.Requerido(numberDocument1TextBox, numberDocument3TextBox, 3, "Por favor escribe correctamente el numero de factura");
            ValidaCampo.Requerido(numberDocument2TextBox, numberDocument3TextBox, 3, "Por favor escribe correctamente el numero de factura");
            ValidaCampo.Requerido(numberDocument3TextBox, numberDocument3TextBox, 9, "Por favor escribe correctamente el numero de factura");

            string idNumber     = (idNumberTextBox.Text.Trim() == "") ? "null" : idNumberTextBox.Text.Trim();
            string businessName = nameTextBox.Text.Replace("'", "\\'").Trim();

            businessName = (businessName == "") ? "null" : $"'{businessName}'";
            string address = addressTextBox.Text.Replace("'", "\\'").Trim();

            address = (address == "") ? "null" : $"'{address}'";
            string additional_information = additionalInformationTextBox.Text.Replace("'", "\\'").Trim();

            additional_information = (additional_information == "") ? "null" : $"'{additional_information}'";
            string   landline         = (landlineTextBox.Text.Trim() == "") ? "null" : landlineTextBox.Text.Trim();
            string   numberInvoice    = $"{numberDocument1TextBox.Text}{numberDocument2TextBox.Text}{numberDocument3TextBox.Text}";
            string   typeIssuanceId   = $"'{GetIdItemTable("type_issuance", "name", "Emisión Normal")}'";
            string   typeDocumentId   = $"'{GetIdItemTable("type_document", "name", "FACTURA COMPRA")}'";
            string   statusDocumentId = $"'{GetIdItemTable("status_document", "name", "Autorizado")}'";
            string   paymentMethodId  = $"'{GetIdItemTable("payment_method", "name", "Otros con utilización del Sistema Financiero")}'";
            DateTime dateTime         = dateIssueDateTimePicker.Value;
            string   date_of_issue    = $"'{dateTime: yyyy-MM-dd} 18:59:59'";

            if (ValidaCampo.ErrorStatus)
            {
                if (SavedTimes == 0)
                {
                    GetIdContact(idNumber);
                    if (IdContact == "nuevo")
                    {
                        if (ConsultasSql.Insertar("contact",
                                                  "id_number, business_name, address, landline, provider",
                                                  $"'{idNumber}', {businessName}, {address}, '{landline}', true"))
                        {
                            GetIdContact(idNumber);
                        }
                    }
                    string idDocument = $"'{Guid.NewGuid()}'";
                    string contactId  = $"{IdContact}";
                    if (ConsultasSql.Insertar("document", idDocument, "number, date_of_issue, subtotal, additional_discount, total_discount, subtotal_iva0, " +
                                              "subtotal_iva12, iva_value, total_value, additional_information, typeIssuanceId, typeDocumentId, statusDocumentId, contactId, paymentMethodId",
                                              $"'{numberInvoice}', {date_of_issue}, {subtotalTextBox.Text}, {valorDescuentoTextBox.Text}, {Math.Round(SubtotalDescuentoDecimal, 2)}, {subtotal0TextBox.Text}, " +
                                              $"{subtotal12TextBox.Text}, {ivaTextBox.Text}, {totalTextBox.Text}, {additional_information}, {typeIssuanceId}, {typeDocumentId}, {statusDocumentId}, '{contactId}', {paymentMethodId}"))
                    {
                        for (int i = 0; i < listadoDataGridView.Rows.Count - 1; i++)
                        {
                            string quantity         = $"{listadoDataGridView.Rows[i].Cells["cantidadColumn"].Value}";
                            string unitary_discount = $"{listadoDataGridView.Rows[i].Cells["cantidadColumn"].Value}";
                            string subtotal         = $"{listadoDataGridView.Rows[i].Cells["subtotalColumn"].Value}";
                            string productId        = $"{listadoDataGridView.Rows[i].Cells["idColumn"].Value}";
                            if (ConsultasSql.Insertar("invoice_detailment", "quantity, unitary_discount, subtotal, documentId, productId",
                                                      $"{quantity}, {unitary_discount}, {subtotal}, {idDocument}, '{productId}'"))
                            {
                                string stock           = GetStockItem("product", "id", productId, 0);
                                string minimumStock    = GetStockItem("product", "id", productId, 1);
                                int    quantityInt     = int.Parse(quantity);
                                int    stockInt        = int.Parse(stock);
                                int    minimumStockInt = int.Parse(minimumStock);
                                stockInt += quantityInt;
                                ConsultasSql.Actualizar("product", $"stock = {stockInt}, stock_indicator = {stockInt + minimumStockInt}", "id", $"'{productId}'");
                            }
                        }
                        MessageBox.Show("Factura de compra registrada correctamente.");
                        SavedTimes                          += 1;
                        saveButton.BackColor                 = ColorTranslator.FromHtml("#56BA54");
                        saveButton.Text                      = "Registrado";
                        listadoDataGridView.Enabled          = false;
                        idNumberTextBox.Enabled              = false;
                        nameTextBox.Enabled                  = false;
                        addressTextBox.Enabled               = false;
                        landlineTextBox.Enabled              = false;
                        additionalInformationTextBox.Enabled = false;
                        descuentoTextBox.Enabled             = false;
                        descuentoButton.Enabled              = false;
                    }
                }
            }
        }
コード例 #26
0
        public void DatosIniciales()
        {
            StockIndicator = 0;
            DateTime dateTimeStart = toDateTimePicker.Value;
            string   fechaInicio   = $"'{dateTimeStart: yyyy-MM-dd} 00:00:00'";
            DateTime dateTimeEnd   = fromDateTimePicker.Value;
            string   fechaFin      = $"'{dateTimeEnd: yyyy-MM-dd} 23:59:59'";

            listadoDataGridView.DataSource = ConsultasSql.TopItems("document_history", "product", "quantity", "subtotal", "type_document", "VENTA", "status_document", "Autorizado", "date_of_issue", fechaInicio, fechaFin, "5");
            listadoDataGridView.Columns["product"].Width = 318;
            listadoDataGridView.Columns["product"].DefaultCellStyle.Padding = new Padding(15, 0, 0, 0);
            listadoDataGridView.Columns["quantity"].Width = 60;
            listadoDataGridView.Columns["quantity"].DefaultCellStyle.Format    = "N0";
            listadoDataGridView.Columns["quantity"].DefaultCellStyle.Padding   = new Padding(0, 0, 15, 0);
            listadoDataGridView.Columns["quantity"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            listadoDataGridView.Columns["subtotal"].Width = 120;
            listadoDataGridView.Columns["subtotal"].DefaultCellStyle.Format    = "C2";
            listadoDataGridView.Columns["subtotal"].DefaultCellStyle.Padding   = new Padding(0, 0, 15, 0);
            listadoDataGridView.Columns["subtotal"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            listadoDataGridView.Columns["date_of_issue"].Visible = false;

            listadoDataGridView.DefaultCellStyle.SelectionBackColor = ColorTranslator.FromHtml("#E5E5E5");
            listadoDataGridView.DefaultCellStyle.SelectionForeColor = ColorTranslator.FromHtml("#000000");

            DataTable dataValorTotal = ConsultasSql.SumaTotalItem("facturas_autorizadas", "total_value", "date_of_issue", fechaInicio, fechaFin);

            decimal.TryParse(dataValorTotal.Rows[0][0].ToString(), out decimal totalVentasDecimal);
            totalVentasTextBox.Text = Math.Round(totalVentasDecimal, 2).ToString("C2");

            DataTable dataTotalFacturasImpresas = ConsultasSql.TotalFacturas("facturas_autorizadas", "!=", "date_of_issue", fechaInicio, fechaFin);

            int.TryParse(dataTotalFacturasImpresas.Rows[0][0].ToString(), out int totalFacturasImpresas);
            DataTable dataTotalFacturasGuardadas = ConsultasSql.TotalFacturas("facturas_autorizadas", "=", "date_of_issue", fechaInicio, fechaFin);

            int.TryParse(dataTotalFacturasGuardadas.Rows[0][0].ToString(), out int totalFacturasGuardadas);

            int totalFacturas = totalFacturasImpresas + totalFacturasGuardadas;

            if (totalFacturas == 0)
            {
                totalFacturasTextBox.Text     = "No hay facturas registradas";
                facturasImpresasTextBox.Text  = "";
                facturasGuardadasTextBox.Text = "";
            }
            else if (totalFacturas >= 1)
            {
                totalFacturasTextBox.Text     = $"Facturas totales : {totalFacturas}";
                facturasImpresasTextBox.Text  = $"Facturas impresas : {totalFacturasImpresas}";
                facturasGuardadasTextBox.Text = $"Facturas guardadas : {totalFacturasGuardadas}";
            }

            stockDataGridView.DataSource            = ConsultasSql.ConsultaGeneral("product", "stock", "ASC", "stock_indicator", "ASC", "name, stock, minimum_stock_level, stock_indicator");
            stockDataGridView.Columns["name"].Width = 408;
            stockDataGridView.Columns["name"].DefaultCellStyle.Padding = new Padding(15, 0, 0, 0);
            stockDataGridView.Columns["stock"].Width = 90;
            stockDataGridView.Columns["stock"].DefaultCellStyle.Format = "N0";
            stockDataGridView.Columns["minimum_stock_level"].Visible   = false;
            stockDataGridView.Columns["stock_indicator"].Visible       = false;
            stockDataGridView.DefaultCellStyle.SelectionBackColor      = ColorTranslator.FromHtml("#E5E5E5");
            stockDataGridView.DefaultCellStyle.SelectionForeColor      = ColorTranslator.FromHtml("#000000");
            stockDataGridView.DefaultCellStyle.BackColor = ColorTranslator.FromHtml("#ACFAC1");

            listadoDataGridView.ClearSelection();
            stockDataGridView.ClearSelection();
        }
コード例 #27
0
        private string GetIdItemTable(string tabla, string campo1, string valor1, string campo2, string valor2)
        {
            DataTable data = ConsultasSql.ConsultaIndividual(tabla, "id", campo1, "=", valor1, campo2, "=", valor2);

            return(data.Rows[0][0].ToString());
        }
コード例 #28
0
        private string GetStockItem(string tabla, string campo, string valor, int posicion)
        {
            DataTable data = ConsultasSql.ConsultaIndividual(tabla, "stock, minimum_stock_level", campo, "=", valor);

            return(data.Rows[0][posicion].ToString());
        }
コード例 #29
0
        private void Guardar()
        {
            string mainCode = mainCodeTextBox.Text.Replace("'", "\\'").Trim();

            mainCode = (mainCode == "") ? "null" : $"'{mainCode}'";
            string auxCode = auxCodeTextBox.Text.Replace("'", "\\'").Trim();

            auxCode = (auxCode == "") ? "null" : $"'{auxCode}'";
            string name = nameTextBox.Text.Replace("'", "\\'").Trim();

            name = (name == "") ? "null" : $"'{name}'";
            string descripcion = descripcionTextBox.Text.Replace("'", "\\'").Trim();

            descripcion = (descripcion == "") ? "null" : $"'{descripcion}'";

            string stock             = (stockTextBox.Text.Trim() == "") ? "0" : stockTextBox.Text.Trim();
            string minimumStockLevel = (minimumStockLevelTextBox.Text.Trim() == "") ? "0" : minimumStockLevelTextBox.Text.Trim();
            string stockIndicator    = (int.Parse(stock) - int.Parse(minimumStockLevel)).ToString();

            string cost             = (costTextBox.Text.Trim() == "") ? "null" : costTextBox.Text.Trim();
            string percentagePrice1 = (percentagePrice1TextBox.Text.Trim() == "") ? "null" : percentagePrice1TextBox.Text.Trim();
            string price1           = (price1TextBox.Text.Trim() == "") ? "null" : price1TextBox.Text.Trim();
            string pvp = (pvp1TextBox.Text.Trim() == "") ? "null" : pvp1TextBox.Text.Trim();
            string percentagePrice2 = (percentagePrice2TextBox.Text.Trim() == "") ? "null" : percentagePrice2TextBox.Text.Trim();
            string price2           = (price2TextBox.Text.Trim() == "") ? "null" : price2TextBox.Text.Trim();
            string pvp2             = (pvp2TextBox.Text.Trim() == "") ? "null" : pvp2TextBox.Text.Trim();
            string percentagePrice3 = (percentagePrice3TextBox.Text.Trim() == "") ? "null" : percentagePrice3TextBox.Text.Trim();
            string price3           = (price3TextBox.Text.Trim() == "") ? "null" : price3TextBox.Text.Trim();
            string pvp3             = (pvp3TextBox.Text.Trim() == "") ? "null" : pvp3TextBox.Text.Trim();

            string category        = (categoryComboBox.SelectedValue.ToString() == "nulo") ? "null" : $"'{categoryComboBox.SelectedValue}'";
            string manufacturer    = (manufacturerComboBox.SelectedValue.ToString() == "nulo") ? "null" : $"'{manufacturerComboBox.SelectedValue}'";
            string iceRate         = (iceRateComboBox.SelectedValue.ToString() == "nulo") ? "null" : $"'{iceRateComboBox.SelectedValue}'";
            string ivaRate         = (ivaRateComboBox.SelectedValue.ToString() == "nulo") ? "null" : $"'{ivaRateComboBox.SelectedValue}'";
            string typeProduct     = (typeProductComboBox.SelectedValue.ToString() == "nulo") ? "null" : $"'{typeProductComboBox.SelectedValue}'";
            string unitMeasurement = (unitMeasurementComboBox.SelectedValue.ToString() == "nulo") ? "null" : $"'{unitMeasurementComboBox.SelectedValue}'";

            if (aceptarButton.Text == "Actualizar")
            {
                if (ConsultasSql.Actualizar(TableBdd,
                                            $"main_code = {mainCode}, aux_code = {auxCode}, name = {name}, detail = {descripcion}, " +
                                            $"stock = {stock}, minimum_stock_level = {minimumStockLevel}, stock_indicator = {stockIndicator}, cost = {cost}, " +
                                            $"percentage_price = {percentagePrice1}, price = {price1}, pvp = {pvp}, " +
                                            $"percentage_price2 = {percentagePrice2}, price2 = {price2}, pvp2 = {pvp2}, " +
                                            $"percentage_price3 = {percentagePrice3}, price3 = {price3}, pvp3 = {pvp3}, " +
                                            $"categoryId = {category}, manufacturerId = {manufacturer}, iceRateId = {iceRate}, " +
                                            $"ivaRateId = {ivaRate}, typeProductId = {typeProduct}, unitMeasurementId = {unitMeasurement}",
                                            "id", $"'{IdField}'"))
                {
                    CerrarYRefrescarFormulario();
                }
            }

            if (aceptarButton.Text == "Guardar")
            {
                if (ConsultasSql.Insertar(
                        TableBdd,
                        "main_code, aux_code, name, detail, stock, minimum_stock_level, stock_indicator, " +
                        "cost, percentage_price, price, pvp, percentage_price2, price2, pvp2, percentage_price3, price3, pvp3, " +
                        "categoryId, manufacturerId, iceRateId, ivaRateId, typeProductId, unitMeasurementId",
                        $"{mainCode}, {auxCode}, {name}, {descripcion}, {stock}, {minimumStockLevel}, {stockIndicator}," +
                        $"{cost}, {percentagePrice1}, {price1}, {pvp}, {percentagePrice2}, {price2}, {pvp2}, {percentagePrice3}, {price3}, {pvp3}, " +
                        $"{category}, {manufacturer}, {iceRate}, {ivaRate}, {typeProduct}, {unitMeasurement}"
                        ))
                {
                    CerrarYRefrescarFormulario();
                }
            }
        }