Пример #1
0
        private void txtPalletExportacion_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (panelErrorExportacion.Visible == true)
            {
                panelErrorExportacion.Visible = false;
            }

            if (ValidarCamposClienteProductor() == false)
            {
                e.Handled = true;
                return;
            }

            if (e.KeyChar == Convert.ToChar(Keys.Enter))
            {
                if (txtPalletExportacion.Text.Trim() == "")
                {
                    lblMensajeExportacion.Text    = "Ingrese Pallet";
                    panelErrorExportacion.Visible = true;

                    return;
                }

                txtPalletExportacion.Text = txtPalletExportacion.Text.ToUpper();

                if (Existe_Pallet_Lista(dgvListaExportacion, txtPalletExportacion.Text) == true)
                {
                    lblMensajeExportacion.Text    = "Pallet ya esta en la Lista";
                    panelErrorExportacion.Visible = true;
                    txtPalletExportacion.SelectAll();
                    return;
                }

                N_Exportacion        exportacion1 = new N_Exportacion();
                E_Pallet_Exportacion pallet1      = new E_Pallet_Exportacion();

                pallet1.Codigo       = txtPalletExportacion.Text;
                pallet1.ID_Cliente   = cmbExportador.SelectedValue.ToString();
                pallet1.ID_Productor = cmbProductor.SelectedValue.ToString();
                if (exportacion1.Existe_Pallet(pallet1) == true)
                {
                    if (pallet1.Estado != "0")
                    {
                        lblMensajeExportacion.Text    = "Pallet fue asignado";
                        panelErrorExportacion.Visible = true;
                        txtPalletExportacion.SelectAll();
                        return;
                    }
                    int rowNuevo;
                    rowNuevo = 0;                          //dgvLista.Rows.Count;

                    dgvListaExportacion.Rows.Insert(0, 1); //  .Add(1);
                    dgvListaExportacion.Rows[rowNuevo].Cells["item"].Value           = (dgvListaExportacion.Rows.Count);
                    dgvListaExportacion.Rows[rowNuevo].Cells["folio"].Value          = pallet1.Codigo;
                    dgvListaExportacion.Rows[rowNuevo].Cells["Peso_Teorico"].Value   = pallet1.Peso;
                    dgvListaExportacion.Rows[rowNuevo].Cells["cantidad_cajas"].Value = pallet1.Cajas;
                    dgvListaExportacion.Rows[rowNuevo].Cells["cantidad_potes"].Value = pallet1.Potes;
                    dgvListaExportacion.Rows[rowNuevo].Cells["total_peso"].Value     = pallet1.Total_Peso;
                    dgvListaExportacion.Rows[0].Selected = true;
                    lblPesoTeorico.Text = Total_Kilos_Lista(dgvListaExportacion, "Total_Peso").ToString();
                }
                else
                {
                    lblMensajeExportacion.Text    = "Pallet no Existe";
                    panelErrorExportacion.Visible = true;
                    // txtPalletExportacion.SelectAll();
                }

                txtPalletExportacion.Text = "";
            }
        }