Beispiel #1
0
 private void ContactoDataGridView_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Up)
     {
         if (ContactoDataGridView.CurrentCell.RowIndex == 0)
         {
             nameTextBox.Focus();
         }
     }
     if (e.KeyCode == Keys.Enter)
     {
         AsignarCeldasDataGridViewAVariables();
         AsignarVariablesACamposDelFormulario();
         ReadOnlyCamposContacto(true);
         ContactoDataGridView.Visible = false;
         listadoDataGridView.Focus();
         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");
     }
     if (e.KeyCode == Keys.Escape)
     {
         ContactoDataGridView.Visible = false;
         nameTextBox.Focus();
     }
 }
Beispiel #2
0
        public void Validar_Lojas_ID(String strValorCampo, Erro objErro, ref TransactionManager objTransaction)
        {
            try
            {
                ValidaBanco objValidaBanco = new ValidaBanco();

                objValidaBanco.Valida_Chave_Extrangeira("Lojas_ID", "Lojas_ID", strValorCampo, "Lojas_IsAtivo", "Lojas_ID", "Lojas", this.GetType().Name + "." + MethodBase.GetCurrentMethod().Name, objErro, ref objTransaction);

                if ((objErro.ObterErro("Lojas_ID") != null))
                {
                    return;
                }

                ValidaCampo objValidaCampo = new ValidaCampo();


                objValidaCampo.ValidaCampoObrigatorio("Lojas_ID", strValorCampo, "Lojas_ID", true, this.GetType().Name + "." + MethodBase.GetCurrentMethod().Name, objErro);
                objValidaCampo.ValidaSoNumeros("Lojas_ID", strValorCampo, "Lojas_ID", this.GetType().Name + "." + MethodBase.GetCurrentMethod().Name, objErro);
                objValidaCampo.ValidaCapacidadeDeVariavelSemCasaDecimal("Lojas_ID", strValorCampo, "Lojas_ID", SqlDbType.Int, this.GetType().Name + "." + MethodBase.GetCurrentMethod().Name, objErro);
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #3
0
        public void Validar_Pago(string strValorCampo, Erro objErro)
        {
            try
            {
                ValidaCampo objValidaCampo = new ValidaCampo();

                objValidaCampo.ValidaCampoObrigatorio("Pago", strValorCampo, "Depósito realizado", true, string.Concat(this.GetType().Name, ".", MethodBase.GetCurrentMethod().Name), objErro);
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #4
0
 public void Validar_Banco_CD(string strValorCampo, Erro objErro, ref TransactionManager objTransaction)
 {
     try
     {
         ValidaCampo objValidaCampo = new ValidaCampo();
         objValidaCampo.ValidaCampoObrigatorio("Banco_CD", strValorCampo, "Código do Banco", true, string.Concat(this.GetType().Name, ".", MethodBase.GetCurrentMethod().Name), objErro);
         objValidaCampo.ValidaSoNumeros("Banco_CD", strValorCampo, "Código do Banco", string.Concat(this.GetType().Name, ".", MethodBase.GetCurrentMethod().Name), objErro);
     }
     catch (Exception)
     {
         throw;
     }
 }
Beispiel #5
0
        public void Validar_Valor(String strValorCampo, Erro objErro)
        {
            try
            {
                ValidaCampo objValidaCampo = new ValidaCampo();

                objValidaCampo.ValidaTamanhoMaximo("Solicitacao_Pagamento_Valor", strValorCampo, "Valor do crédito da Solicitação de Pagamento", 50, string.Concat(this.GetType().Name, ".", MethodBase.GetCurrentMethod().Name), objErro);
                objValidaCampo.ValidaCampoObrigatorio("Solicitacao_Pagamento_Valor", strValorCampo, "Valor do crédito da Solicitação de Pagamento", true, string.Concat(this.GetType().Name, ".", MethodBase.GetCurrentMethod().Name), objErro);
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #6
0
        public void Validar_Banco_ContaTipo(string strValorCampo, Erro objErro)
        {
            try
            {
                ValidaCampo objValidaCampo = new ValidaCampo();

                objValidaCampo.ValidaTamanhoMaximo("Banco_ContaTipo", strValorCampo, "Tipo de Conta Bancária", 1, string.Concat(this.GetType().Name, ".", MethodBase.GetCurrentMethod().Name), objErro);
                objValidaCampo.ValidaCampoObrigatorio("Banco_ContaTipo", strValorCampo, "Tipo de Conta Bancária", true, string.Concat(this.GetType().Name, ".", MethodBase.GetCurrentMethod().Name), objErro);
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #7
0
        public void Validar_Banco_Agencia(String strValorCampo, Erro objErro)
        {
            try
            {
                ValidaCampo objValidaCampo = new ValidaCampo();

                objValidaCampo.ValidaTamanhoMaximo("Solicitacao_Pagamento_Banco_Agencia", strValorCampo, "Agência Bancária", 20, string.Concat(this.GetType().Name, ".", MethodBase.GetCurrentMethod().Name), objErro);
                objValidaCampo.ValidaCampoObrigatorio("Solicitacao_Pagamento_Banco_Agencia", strValorCampo, "Agência Bancária", true, string.Concat(this.GetType().Name, ".", MethodBase.GetCurrentMethod().Name), objErro);
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #8
0
        public void Validar_Cliente_CPFCNPJ(string strValorCampo, Erro objErro)
        {
            try
            {
                ValidaCampo objValidaCampo = new ValidaCampo();

                objValidaCampo.ValidaCampoObrigatorio("Cliente_CPFCNPJ", strValorCampo, "Cliente", true, string.Concat(this.GetType().Name, ".", MethodBase.GetCurrentMethod().Name), objErro);
                objValidaCampo.ValidaTamanhoMaximo("Cliente_CPFCNPJ", strValorCampo, "Cliente", 15, string.Concat(this.GetType().Name, ".", MethodBase.GetCurrentMethod().Name), objErro);
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #9
0
        public void Validar_Processado(string strValorCampo, Erro objErro)
        {
            try
            {
                if (strValorCampo == String.Empty)
                {
                    return;
                }

                ValidaCampo objValidaCampo = new ValidaCampo();

                objValidaCampo.ValidaTamanhoMaximo("Processado", strValorCampo, "Depósito processado", 1, string.Concat(this.GetType().Name, ".", MethodBase.GetCurrentMethod().Name), objErro);
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #10
0
        public void Validar_Cliente_CD(String strValorCampo, Erro objErro, ref TransactionManager objTransaction)
        {
            try
            {
                ValidaBanco objValidaBanco = new ValidaBanco();

                objValidaBanco.Valida_Chave_Extrangeira("Cliente_CD", "Cliente_CD", strValorCampo, "Cliente_IsAtivo", "Código do Cliente para o Depósito", "Cliente", string.Concat(this.GetType().Name, ".", MethodBase.GetCurrentMethod().Name), objErro, ref objTransaction);

                if ((objErro.ObterErro("Cliente_CD") != null))
                {
                    return;
                }

                ValidaCampo objValidaCampo = new ValidaCampo();
                objValidaCampo.ValidaCampoObrigatorio("Cliente_CD", strValorCampo, "Código do Cliente", true, string.Concat(this.GetType().Name, ".", MethodBase.GetCurrentMethod().Name), objErro);
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #11
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;
                    }
                }
            }
        }
Beispiel #12
0
 private void IdNumberTextBox_Validating(object sender, CancelEventArgs e)
 {
     ValidaCampo.Identificacion(idNumberTextBox);
 }