Example #1
0
        private bool ValidateUser(string UserName, string Password)
        {
            bool boolReturnValue = false;

            try
            {
                var db    = new WerkERPContext();
                var query = db.Usuarios.Where(s => s.usuario1 == UserName && s.password == Password).SingleOrDefault();

                if (query == null)
                {
                    boolReturnValue = false;
                }
                else
                {
                    boolReturnValue = true;
                }
            }
            catch (Exception exp)
            {
                boolReturnValue = false;
            }

            return(boolReturnValue);
        }
Example #2
0
        public void BrokeCheckRequestOPDetail(int IdDetail)
        {
            try
            {
                var db = new WerkERPContext();
                var solicitudOPDetalles = db.SolicitudOrdenPagoDetalles.Where(s => s.id_solicitud_orden_pago_detalle == IdDetail).SingleOrDefault();

                solicitudOPDetalles.id_cheque = null;

                db.SaveChanges();
                ErrorLabel.Text = String.Empty;

                ChequesAsignadosGridView.DataBind();
                RequestOPDetailsListView.DataBind();
            }
            catch (DbEntityValidationException ex)
            {
                ErrorLabel.Visible = true;
                ErrorLabel.Text    = ex.Message;
            }
            catch (Exception exp)
            {
                ErrorLabel.Text    = exp.Message;
                ErrorLabel.Visible = true;
            }
        }
Example #3
0
        public IQueryable <WerkUI.Models.Cheque> GetChecks()
        {
            try
            {
                var db = new WerkERPContext();
                //var query = db.Cheques;
                int idChequera;
                if (ddlCheqeras.SelectedValue == "")
                {
                    return(null);
                }
                else
                {
                    idChequera = Convert.ToInt32(ddlCheqeras.SelectedValue);
                }

                var query = db.Cheques.Where(s => s.id_chequera == idChequera);

                return(query);
            }
            catch (Exception exp)
            {
                ErrorLabel.Text    = exp.Message;
                ErrorLabel.Visible = true;
                return(null);
            }
        }
Example #4
0
        public void UpdateRequestOPDetail(WerkUI.Models.SolicitudOrdenPagoDetalle subject)
        {
            try
            {
                var db = new WerkERPContext();
                var solicitudOPDetalles = db.SolicitudOrdenPagoDetalles.Where(s => s.id_solicitud_orden_pago_detalle == subject.id_solicitud_orden_pago_detalle).SingleOrDefault();
                solicitudOPDetalles.importe              = subject.importe;
                solicitudOPDetalles.importe_aprobado     = subject.importe;
                solicitudOPDetalles.nro_concepto         = subject.nro_concepto;
                solicitudOPDetalles.observacion          = subject.observacion;
                solicitudOPDetalles.nro_despacho_interno = subject.nro_despacho_interno;

                db.SaveChanges();
                ErrorLabel.Text = String.Empty;
            }
            catch (DbEntityValidationException ex)
            {
                ErrorLabel.Visible = true;
                ErrorLabel.Text    = ex.Message;
            }
            catch (Exception exp)
            {
                ErrorLabel.Text    = exp.Message;
                ErrorLabel.Visible = true;
            }
        }
Example #5
0
        protected void AsignarChequeBtn_Click(object sender, EventArgs e)
        {
            decimal vImporte = 0;
            int     vId;
            int     vIdCheque;

            try
            {
                var db = new WerkERPContext();
                vIdCheque = Convert.ToInt32(ddlCheques.SelectedValue.ToString());

                for (int i = 0; i <= RequestOPDetailsListView.Items.Count - 1; i++)
                {
                    ListViewItem row = (ListViewItem)RequestOPDetailsListView.Items[i];
                    CheckBox     chk = (CheckBox)row.FindControl("chkConcept");
                    if (chk.Checked)
                    {
                        try
                        {
                            vImporte += Convert.ToDecimal(((Label)row.FindControl("lblImporteAprobado")).Text);

                            vId = Convert.ToInt32(((Label)row.FindControl("lblID")).Text);
                            var solicitudOPDetalle = db.SolicitudOrdenPagoDetalles.Where(s => s.id_solicitud_orden_pago_detalle == vId).SingleOrDefault();
                            solicitudOPDetalle.id_cheque = vIdCheque;
                        }
                        catch (Exception ax)
                        {
                            vImporte = 0;
                        }
                    }
                }

                var cheque = db.Cheques.Where(s => s.id_cheque == vIdCheque).SingleOrDefault();

                if (cheque.monto == null)
                {
                    cheque.monto = vImporte;
                }
                else
                {
                    cheque.monto += vImporte;
                }

                cheque.id_orden_pago = requestID;
                cheque.fecha_emision = DateTime.Now;

                db.SaveChanges();
                ErrorLabel.Text = String.Empty;
                ChequesAsignadosGridView.DataBind();
                RequestOPDetailsListView.DataBind();
            }
            catch (Exception exp)
            {
                ErrorLabel.Text    = exp.Message;
                ErrorLabel.Visible = true;
            }
        }
Example #6
0
        public void InsertRequestOP()
        {
            var db          = new WerkERPContext();
            var solicitudOP = new WerkUI.Models.SolicitudOrdenPago();

            TryUpdateModel(solicitudOP);
            if (ModelState.IsValid)
            {
                try
                {
                    solicitudOP.id_estado       = 1;
                    solicitudOP.fecha_solicitud = DateTime.Now;
                    solicitudOP.cod_usuario     = GetUserID(User.Identity.Name);

                    if (VerifyNroOP(solicitudOP.nro_comprobante.ToString()))
                    {
                        ErrorLabel.Visible = true;
                        ErrorLabel.Text    = "El Nro. de comprobante ya existe.";
                    }
                    else
                    {
                        db.SolicitudOrdenPagoes.Add(solicitudOP);
                        db.SaveChanges();
                        ErrorLabel.Text = String.Empty;

                        //Si la operacion a sido exitosa voy a los detalles de la nueva SOP
                        Response.Redirect("~/OrdenPago/RequestOPDetails.aspx?RequestID=" + solicitudOP.id_solicitud_orden_pago.ToString() + "&RequestNumber=" + solicitudOP.nro_comprobante);
                    }
                }
                catch (DbEntityValidationException ex)
                {
                    ErrorLabel.Visible = true;
                    ErrorLabel.Text    = ex.Message;
                }
                catch (Exception exp)
                {
                    if (exp.InnerException.HResult.ToString() == "-2146233087")
                    {
                        ErrorLabel.Text = "El numero de comprobante corresponde a otra solicitud.";
                    }
                    else
                    {
                        ErrorLabel.Text = exp.Message;
                    }

                    ErrorLabel.Visible = true;
                }
            }
        }
Example #7
0
 public IQueryable <WerkUI.Models.SolicitudOrdenPago> GetRequestOPs()
 {
     try
     {
         var db    = new WerkERPContext();
         var query = db.SolicitudOrdenPagoes;
         return(query);
     }
     catch (Exception exp)
     {
         ErrorLabel.Text    = exp.Message;
         ErrorLabel.Visible = true;
         return(null);
     }
 }
Example #8
0
 public IQueryable <WerkUI.Models.Banco> GetBanks()
 {
     try
     {
         var db    = new WerkERPContext();
         var query = db.Bancos;
         return(query);
     }
     catch (Exception exp)
     {
         ErrorLabel.Text    = exp.Message;
         ErrorLabel.Visible = true;
         return(null);
     }
 }
Example #9
0
 public IQueryable <WerkUI.Models.SolicitudOrdenPagoDetalle> GetRequestOPDetails()
 {
     try
     {
         var db    = new WerkERPContext();
         var query = db.SolicitudOrdenPagoDetalles.Where(s => s.id_solicitud_orden_pago == requestID);
         return(query);
     }
     catch (Exception exp)
     {
         ErrorLabel.Text    = exp.Message;
         ErrorLabel.Visible = true;
         return(null);
     }
 }
Example #10
0
 public String  GetConceptByNumber(String conceptNumber)
 {
     try
     {
         var db    = new WerkERPContext();
         var query = db.ConceptosLiquidacions.Where(s => s.nro_concepto == conceptNumber).SingleOrDefault();
         return(query.descripcion);
     }
     catch (Exception exp)
     {
         ErrorLabel.Text    = exp.Message;
         ErrorLabel.Visible = true;
         return(null);
     }
 }
Example #11
0
 public Boolean VerifyConcpetoLiquidacion(String nroConceptoLiquidacion)
 {
     try
     {
         var db    = new WerkERPContext();
         var query = db.ConceptosLiquidacions.Where(s => s.nro_concepto == nroConceptoLiquidacion).SingleOrDefault();
         if (query.cod_concepto_liquidacion.ToString() != "")
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     { return(false); }
 }
Example #12
0
 public Boolean VerifyNroOP(String nroComprobante)
 {
     try
     {
         var db    = new WerkERPContext();
         var query = db.ORDENPAGOCLIENTEs.Where(s => s.NUMEROCOMPROBANTE == nroComprobante).SingleOrDefault();
         if (query.CODCOMPROBANTE.ToString() != "")
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     { return(false); }
 }
Example #13
0
 public Boolean VerifyDespachoInterno(String nroDespachoInterno)
 {
     try
     {
         var db    = new WerkERPContext();
         var query = db.DESPACHOINTERNOes.Where(s => s.NUMDESPACHOINTERNO == nroDespachoInterno).SingleOrDefault();
         if (query.CODDESPACHOINTERNO.ToString() != "")
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     { return(false); }
 }
Example #14
0
        public IQueryable <WerkUI.Models.SolicitudOrdenPago> GetRequestOPs()
        {
            int codUser;

            try
            {
                var db = new WerkERPContext();
                codUser = GetUserID(User.Identity.Name);
                var query = db.SolicitudOrdenPagoes.Where(s => s.cod_usuario == codUser);
                return(query);
            }
            catch (Exception exp)
            {
                ErrorLabel.Text    = exp.Message;
                ErrorLabel.Visible = true;
                return(null);
            }
        }
Example #15
0
 public static int GetUserID(object usuario)
 {
     try
     {
         var db    = new WerkERPContext();
         var query = db.Usuarios.Where(s => s.usuario1 == usuario).SingleOrDefault();
         if (query.usuario1.ToString() != "")
         {
             return(query.cod_usuario);
         }
         else
         {
             return(-1);
         }
     }
     catch (Exception ex)
     { return(-1); }
 }
Example #16
0
        public void InsertRequestOPDetail()
        {
            var db = new WerkERPContext();
            var solicitudOPDetalles = new WerkUI.Models.SolicitudOrdenPagoDetalle();

            TryUpdateModel(solicitudOPDetalles);
            if (ModelState.IsValid)
            {
                try
                {
                    solicitudOPDetalles.cod_moneda = 1;
                    solicitudOPDetalles.id_solicitud_orden_pago = requestID;
                    solicitudOPDetalles.importe_aprobado        = solicitudOPDetalles.importe;

                    if (!VerifyDespachoInterno(solicitudOPDetalles.nro_despacho_interno.ToString()))
                    {
                        ErrorLabel.Visible = true;
                        ErrorLabel.Text    = "El número de Despacho Interno no es válido.";
                    }
                    else if (!VerifyConcpetoLiquidacion(solicitudOPDetalles.nro_concepto))
                    {
                        ErrorLabel.Visible = true;
                        ErrorLabel.Text    = "El numero de Concepto de Liquidación no es válido.";
                    }
                    else
                    {
                        db.SolicitudOrdenPagoDetalles.Add(solicitudOPDetalles);
                        db.SaveChanges();
                        ErrorLabel.Text = String.Empty;
                    }
                }
                catch (DbEntityValidationException ex)
                {
                    ErrorLabel.Visible = true;
                    ErrorLabel.Text    = ex.Message;
                }
                catch (Exception exp)
                {
                    ErrorLabel.Text    = exp.Message;
                    ErrorLabel.Visible = true;
                }
            }
        }
Example #17
0
        public IQueryable <WerkUI.Models.Chequera> GetChequeras()
        {
            try
            {
                var db = new WerkERPContext();
                //var query = db.Chequeras;
                int idBanco = Convert.ToInt32(ddlBancos.SelectedValue);
                var query   = db.Chequeras.Where(s => s.id_banco == idBanco);


                return(query);
            }
            catch (Exception exp)
            {
                ErrorLabel.Text    = exp.Message;
                ErrorLabel.Visible = true;
                return(null);
            }
        }
Example #18
0
        public String GetDIClient(String DI)
        {
            decimal codCLiente;

            try
            {
                var db    = new WerkERPContext();
                var query = db.DESPACHOINTERNOes.Where(s => s.NUMDESPACHOINTERNO == DI).SingleOrDefault();
                codCLiente = Convert.ToDecimal(query.CODCLIENTE);
                var clientQuery = db.CLIENTES.Where(c => c.CODCLIENTE == codCLiente).SingleOrDefault();

                return(query.NUMDESPACHOINTERNO + " - " + clientQuery.APELLIDO);
            }
            catch (Exception exp)
            {
                ErrorLabel.Text    = exp.Message;
                ErrorLabel.Visible = true;
                return(null);
            }
        }
Example #19
0
 public void DeleteRequestOPDetail(WerkUI.Models.SolicitudOrdenPagoDetalle subject)
 {
     try
     {
         var db = new WerkERPContext();
         var solicitudOPDetalles = db.SolicitudOrdenPagoDetalles.Where(s => s.id_solicitud_orden_pago_detalle == subject.id_solicitud_orden_pago_detalle).SingleOrDefault();
         db.SolicitudOrdenPagoDetalles.Remove(solicitudOPDetalles);
         db.SaveChanges();
         ErrorLabel.Text = String.Empty;
     }
     catch (DbEntityValidationException ex)
     {
         ErrorLabel.Visible = true;
         ErrorLabel.Text    = ex.Message;
     }
     catch (Exception exp)
     {
         ErrorLabel.Text    = exp.Message;
         ErrorLabel.Visible = true;
     }
 }
Example #20
0
        public static string GetUserLogin(object codFuncionario)
        {
            int tranformed;

            try
            {
                tranformed = Convert.ToInt32(codFuncionario.ToString());
                var db    = new WerkERPContext();
                var query = db.Usuarios.Where(s => s.cod_usuario == tranformed).SingleOrDefault();
                if (query.usuario1.ToString() != "")
                {
                    return(query.usuario1.ToString());
                }
                else
                {
                    return("");
                }
            }
            catch (Exception ex)
            { return(""); }
        }
Example #21
0
        public void UpdateRequestOP(WerkUI.Models.SolicitudOrdenPago subject)
        {
            try
            {
                var db          = new WerkERPContext();
                var solicitudOP = db.SolicitudOrdenPagoes.Where(s => s.id_solicitud_orden_pago == subject.id_solicitud_orden_pago).SingleOrDefault();
                solicitudOP.nro_comprobante = subject.nro_comprobante;

                db.SaveChanges();
                ErrorLabel.Text = String.Empty;
            }
            catch (DbEntityValidationException ex)
            {
                ErrorLabel.Visible = true;
                ErrorLabel.Text    = ex.Message;
            }
            catch (Exception exp)
            {
                ErrorLabel.Text    = exp.Message;
                ErrorLabel.Visible = true;
            }
        }