コード例 #1
0
        private bool validarCampos()
        {
            bool b = false;

            if (String.IsNullOrEmpty(TxtArea.Text))
            {
                TxtArea.Focus();
                throw new Exception("Ingrese área");
            }

            if (String.IsNullOrEmpty(txtEdificio.Text))
            {
                txtEdificio.Focus();
                throw new Exception("Ingrese edificio");
            }

            if (String.IsNullOrEmpty(txtAula.Text))
            {
                txtAula.Focus();
                throw new Exception("Ingrese aula");
            }

            if (String.IsNullOrEmpty(TxtPiso.Text))
            {
                TxtPiso.Focus();
                throw new Exception("Ingrese piso");
            }

            //if (DDLCategoria.SelectedIndex == 0)
            //    throw new Exception("Seleccione una categoría");

            if (DDLSede.SelectedIndex == 0)
            {
                throw new Exception("Seleccione una sede");
            }

            if (String.IsNullOrEmpty(txtUsu.Text))
            {
                txtUsu.Focus();
                throw new Exception("Ingrese usuario asignado");
            }


            if (DateTime.Parse(txtFechaCompra.Text) > DateTime.Parse("2018-12-31"))
            {
                if (String.IsNullOrEmpty(txtRuc.Text))
                {
                    txtRuc.Focus();
                    throw new Exception("Ingrese RUC");
                }

                if (String.IsNullOrEmpty(txtProveedor.Text.Trim()))
                {
                    txtRuc.Focus();
                    throw new Exception("Ingrese Proveedor");
                }

                if (String.IsNullOrEmpty(txtNroFactura.Text))
                {
                    txtNroFactura.Focus();
                    throw new Exception("Ingrese Nro Comprobante");
                }

                if (String.IsNullOrEmpty(txtFechaCompra.Text))
                {
                    txtFechaCompra.Focus();
                    throw new Exception("Ingrese Fecha de Compra");
                }

                if (String.IsNullOrEmpty(txtTiempo.Text))
                {
                    txtTiempo.Text = "0";
                    txtTiempo_TextChanged(null, null);
                }
            }

            b = true;
            return(b);
        }
コード例 #2
0
        private bool validarCampos(string tipo)
        {
            bool b = false;

            try
            {
                LogisticaN objBuscar = new LogisticaN();
                string     xcodigo   = TxtCod.Text.Trim();

                if (tipo == "insert")
                {
                    DataTable DTILogistica = objBuscar.BuscarLogistica(xcodigo);

                    if (DTILogistica.Rows.Count > 0)
                    {
                        TxtCod.Focus();
                        throw new Exception("El Codigo ya Existe");
                    }
                }
                else
                {
                    if (TxtCod.Text.Trim() != TxtCodigo.Text.Trim())
                    {
                        if (objBuscar.fun_validar_noRepetir_cod(xcodigo) > 0)
                        {
                            TxtCod.Focus();
                            throw new Exception("El Codigo ya Existe");
                        }
                    }
                }

                if (String.IsNullOrEmpty(TxtCod.Text))
                {
                    TxtCod.Focus();
                    throw new Exception("Ingrese el código");
                }

                if (String.IsNullOrEmpty(TxtDescripcion.Text))
                {
                    TxtDescripcion.Focus();
                    throw new Exception("Ingrese Descripción");
                }
                if (DDLSede.SelectedIndex == 0)
                {
                    DDLSede.Focus();
                    throw new Exception("Seleccione Sede");
                }

                if (String.IsNullOrEmpty(TxtArea.Text))
                {
                    TxtArea.Focus();
                    throw new Exception("Ingrese Area");
                }

                if (String.IsNullOrEmpty(TxtPiso.Text))
                {
                    TxtPiso.Focus();
                    throw new Exception("Ingrese Piso");
                }

                if (String.IsNullOrEmpty(txtEdificio.Text))
                {
                    txtEdificio.Focus();
                    throw new Exception("Ingrese Edificio");
                }

                if (String.IsNullOrEmpty(txtUsu.Text))
                {
                    txtUsu.Focus();
                    throw new Exception("Asigne un Usuario");
                }

                if (DDLCategoria.SelectedIndex == 0)
                {
                    DDLCategoria.Focus();
                    throw new Exception("Seleccione Categoria");
                }


                if (tipo == "insert")
                {
                    validar_campos_ruc();
                }
                else
                {
                    if (DateTime.Parse(hdFecha.Value) > DateTime.Parse("2018-12-31"))
                    {
                        validar_campos_ruc();
                    }
                }

                b = true;
                return(b);
            }
            catch (Exception ex)
            {
                this.Page.Response.Write("<script language ='JavaScript'>window.alert('" + ex.Message + "');</script>");
                return(false);
            }
        }