private void dgvDatosCaja_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            CajaTalonarioEmpresa ObjCajaTalonarioEmpresa = new CajaTalonarioEmpresa();

            if (rbtActivos.Checked)
            {
                if (this.dgvDatosCaja.Columns[e.ColumnIndex].Name == "Deshabilitar")
                {
                    ObjCajaTalonarioEmpresa.EstadoCajaTalo(dgvDatosCaja.CurrentRow.Cells[2].Value.ToString(), 2);
                    cargarDatos("1");
                }
            }
            else if (rbtInactivos.Checked)
            {
                if (this.dgvDatosCaja.Columns[e.ColumnIndex].Name == "Deshabilitar")
                {
                    ObjCajaTalonarioEmpresa.EstadoCajaTalo(dgvDatosCaja.CurrentRow.Cells[2].Value.ToString(), 1);
                    cargarDatos("0");
                }
            }

            if (this.dgvDatosCaja.Columns[e.ColumnIndex].Name == "Modificar")
            {
                //MessageBox.Show("modificar toca " + DgvDatosEmpleado.CurrentRow.Cells[3].Value.ToString());
                GlobalIDCajaTalonario = dgvDatosCaja.CurrentRow.Cells[2].Value.ToString();
                inicializarDatos();
                tcCajaTalonario.SelectedIndex = 0;
                bandera_Estado = true;
                //Llenar el DataTable
                DataTable dt = consultas.BoolDataTable("Select * from TbCajasTalonario where IDCAJATALONARIO = '" + GlobalIDCajaTalonario + "'");
                //Verificar si tiene Datos
                if (dt.Rows.Count > 0)
                {
                    DataRow myRow = dt.Rows[0];
                    ////Cargar los demas Datos
                    txtSerie1Caja.Text           = myRow["SERIE1"].ToString();
                    txtSerie2Caja.Text           = myRow["SERIE2"].ToString();
                    txtDocumentoInicialCaja.Text = myRow["DOCUMENTOINICIAL"].ToString();
                    txtDocumentoFinalCaja.Text   = myRow["DOCUMENTOFINAL"].ToString();
                    txtDocumentoActualCaja.Text  = myRow["DOCUMENTOACTUAL"].ToString();
                    dtpFechaCaducidadCaja.Value  = Convert.ToDateTime(myRow["FECHACADUCIDAD"].ToString());
                    ckbActivoCaja.Checked        = Convert.ToBoolean(myRow["ESTADO"]);
                    txtEstacionCaja.Text         = myRow["ESTACION"].ToString();
                    TxtIP.Text = myRow["IPESTACION"].ToString();
                    txtAutorizacionCaja.Text = myRow["AUTORIZACION"].ToString();

                    cbSucursalCaja.SelectedValue = Convert.ToInt32(myRow["IDSUCURSAL"]);
                    int indexSUCURSAL = cbSucursalCaja.SelectedIndex;
                    cbSucursalCaja.SelectedIndex = indexSUCURSAL;

                    cbBodegaCaja.SelectedValue = Convert.ToInt32(myRow["IDBODEGA"]);
                    int indexBODEGA = cbBodegaCaja.SelectedIndex;
                    cbBodegaCaja.SelectedIndex = indexBODEGA;
                }
                btnLimpiar.Text = "&Cancelar";
                btnGuardar.Text = "&Modificar";
            }
        }
示例#2
0
 private void btnGuardarUsuario_Click(object sender, EventArgs e)
 {
     if (txtSerie1Caja.Text != "" && txtSerie2Caja.Text != "" && txtDocumentoActualCaja.Text != "" && txtDocumentoFinalCaja.Text != "" && txtDocumentoInicialCaja.Text != "" && txtAutorizacionCaja.Text != "" && txtEstacionCaja.Text != "" && TxtIP.Text != "")
     {
         CajaTalonarioEmpresa ObjCajaTalonarioEmpresa = new CajaTalonarioEmpresa(Convert.ToInt32(cbSucursalCaja.SelectedValue), Convert.ToInt32(cbBodegaCaja.SelectedValue), cbTipoDocumentoCaja.SelectedValue.ToString(), txtDocumentoInicialCaja.Text, txtDocumentoFinalCaja.Text, txtDocumentoActualCaja.Text, dtpFechaCaducidadCaja.Value.ToShortDateString().ToString(), ckbActivoCaja.Checked, txtEstacionCaja.Text, TxtIP.Text, txtSerie1Caja.Text, txtSerie2Caja.Text, txtAutorizacionCaja.Text);
         if (!bandera_Estado)                                       // Para identificar si se va ingresar
         {
             String resultado = ObjCajaTalonarioEmpresa.Insertar(); // retorna true si esta correcto todo
             if (resultado == "Datos Guardados")
             {
                 inicializarDatos();
                 cargarDatos("1");
                 MessageBox.Show("Registrado Correctamente ", "Exito", MessageBoxButtons.OK);
                 rbtActivos.Checked = true;
             }
             else if (resultado == "Error al Registrar")
             {
                 MessageBox.Show("Error al guardar", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
             else if (resultado == "Existe")
             {
                 MessageBox.Show("Ya Existe la Serie", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
         }
         else if (bandera_Estado)                                                         // Para identificar si se va modificar
         {
             String Resultado = ObjCajaTalonarioEmpresa.Modificar(GlobalIDCajaTalonario); // retorna true si esta correcto todo
             if (Resultado == "Correcto")
             {
                 MessageBox.Show("Actualizado", "Exito");
                 rbtActivos.Checked    = true;
                 GlobalIDCajaTalonario = "";
             }
             else
             {
                 MessageBox.Show("Error al actualizar", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
             inicializarDatos();
             bandera_Estado  = false;
             btnGuardar.Text = "&Guardar";
         }
     }
     else
     {
         MessageBox.Show("Ingrese los datos ", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }