Пример #1
0
        private void GetRiesgoPropioNCredito()
        {
            Conn  = new Coneccion();
            Query = @"SELECT TOP 1 NOKOEN,DIEN,FOEN,CRTO,CRSD,CRCH,CRPA,CRLT,MOCTAEN FROM MAEEN WITH ( NOLOCK )  WHERE KOEN= @RUT";

            try
            {
                Conn.ConnGlasser.Open();
                Conn.CmdPlabal = new SqlCommand(Query, Conn.ConnGlasser);
                Conn.CmdPlabal.Parameters.AddWithValue("@RUT", Rut);



                dr = Conn.CmdPlabal.ExecuteReader();
                dr.Read();
                if (dr.HasRows)
                {
                    Validadores validadores = new Validadores();
                    string      Rpr         = dr["CRPA"].ToString();
                    string      Crtr        = dr["CRTO"].ToString();
                    RiesgoPropio = Math.Round(validadores.ParseoDouble(Rpr), 0);
                    Credito      = Math.Round(validadores.ParseoDouble(Crtr), 0);
                }
                dr.Close();
                Conn.ConnGlasser.Close();
            }
            catch (Exception EX)
            {
                string        ERRORSTR = "Mensaje:" + EX.Message + " trace: " + EX.StackTrace + " Rut:" + Rut + " empresa:" + Empresa;
                ErrorCatching gETerror = new ErrorCatching();
                gETerror.ErrorCatch(ERRORSTR, HttpContext.Current.Request.Url.ToString());
                dr.Close();
                Conn.ConnGlasser.Close();
            }
        }
Пример #2
0
        public BA_PRODUKTE GetByCod(string CodigoAlfak)
        {
            BA_PRODUKTE Item;

            Conn = new Coneccion();
            string Select = "SELECT  A.EXT_STAT AS 'STAT',A.EAN,A.BA_SN_MAKRO_NAME,A.BA_MASS_GEWICHT,A.BA_MASS_DICKE,ART.PRD_NR AS 'ARTPRDNR', GRP.PRDKTGRP_NR AS 'PRDKTGRPNR' , B.BA_MENGENEINH,B.BA_BEZ3, B.BA_BEZ1,C.BEZ AS 'FAMILIA',A.*,B.* " +
                            "FROM PHGLASS.SYSADM.BA_PRODUKTE A, PHGLASS.SYSADM.BA_PRODUKTE_BEZ B, SYSADM.KA_WGR C, SYSADM.KA_PRODUKTART ART, SYSADM.KA_PRODUKTGRP GRP " +
                            "WHERE A.BA_WGR = C.ID AND A.BA_PRODUKT = B.BA_PRODUKT and A.BA_PRODUKT=@CodAlfak AND A.BA_PRODUKTART = ART.BEZ AND ART.BEZ = GRP.PRDKTART_ID AND A.BA_PRODUKTGRP = GRP.PRDKTGRP_ID";

            try
            {
                Conn.ConnAlfak.Open();
                Conn.Cmd = new SqlCommand(Select, Conn.ConnAlfak);
                Conn.Cmd.Parameters.AddWithValue("@CodAlfak", CodigoAlfak);
                dr = Conn.Cmd.ExecuteReader();
                dr.Read();
                if (dr.HasRows)
                {
                    Validadores VAL = new Validadores();
                    Item = new BA_PRODUKTE {
                        Descripcion      = dr["BA_BEZ1"].ToString(),
                        CodigoAlfak      = dr["BA_PRODUKT"].ToString(),
                        Abreviacion      = dr["BA_MCODE"].ToString(),
                        Id_familiaAlfak  = dr["BA_WGR"].ToString(),
                        Familia_Alfak    = dr["FAMILIA"].ToString(),
                        BA_BEZ3          = dr["BA_BEZ3"].ToString(),
                        BA_MENGENEINH    = dr["BA_MENGENEINH"].ToString(),
                        ARTPRDNR         = dr["ARTPRDNR"].ToString(),
                        PRDKTGRPNR       = dr["PRDKTGRPNR"].ToString(),
                        BA_MASS_DICKE    = VAL.ParseoDouble(dr["BA_MASS_DICKE"].ToString()),
                        BA_MASS_GEWICHT  = VAL.ParseoDouble(dr["BA_MASS_GEWICHT"].ToString()),
                        BA_SN_MAKRO_NAME = dr["BA_SN_MAKRO_NAME"].ToString(),
                        EAN      = dr["EAN"].ToString(),
                        EXT_STAT = dr["STAT"].ToString(),
                    };
                }
                else
                {
                    Item = new BA_PRODUKTE {
                    };
                }
                dr.Close();
                Conn.ConnAlfak.Close();
            }
            catch (Exception ex)
            {
                throw ex;
            }



            return(Item);
        }
Пример #3
0
        private double GetAmountNVV()
        {
            Conn  = new Coneccion();
            Query = @"SELECT SUM(MAEDDO.VABRLI ) " +
                    "FROM MAEDDO MAEDDO WITH ( NOLOCK )  " +
                    "INNER JOIN MAEEDO MAEEDO WITH ( NOLOCK ) ON MAEEDO.IDMAEEDO = MAEDDO.IDMAEEDO " +
                    "WHERE MAEDDO.ENDO = @RUT AND " +
                    "MAEDDO.TIDO IN ('NVV','RES','PRO','OCC','GDD','GDP','GDV','GRC','GRD','GRP') " +
                    "AND MAEDDO.EMPRESA=@Empresa  AND MAEDDO.ESLIDO=' '  AND MAEDDO.LILG IN ('SI','GR')  AND MAEEDO.ESDO<>'N' ";

            try
            {
                Conn.ConnGlasser.Open();
                Conn.CmdPlabal = new SqlCommand(Query, Conn.ConnGlasser);
                Conn.CmdPlabal.Parameters.AddWithValue("@RUT", Rut);
                Conn.CmdPlabal.Parameters.AddWithValue("@Empresa", Empresa);



                dr = Conn.CmdPlabal.ExecuteReader();
                dr.Read();
                if (dr.HasRows)
                {
                    Validadores validadores = new Validadores();
                    return(validadores.ParseoDouble(dr[0].ToString()));
                }
                else
                {
                    return(0);
                }
            }
            catch (Exception EX)
            {
                string        ERRORSTR = "Mensaje:" + EX.Message + " trace: " + EX.StackTrace + " Rut:" + Rut + " empresa:" + Empresa;
                ErrorCatching gETerror = new ErrorCatching();
                gETerror.ErrorCatch(ERRORSTR, HttpContext.Current.Request.Url.ToString());
                dr.Close();
                Conn.ConnGlasser.Close();
                return(0);
            }
        }
Пример #4
0
        private double  GetAmountCHEQUES()
        {
            Conn  = new Coneccion();
            Query = @"SELECT sum(VABRDO) " +
                    "FROM MAEEDO EDO WITH ( NOLOCK ) " +
                    "WHERE EDO.ENDO = @RUT AND EDO.TIDO IN  ('CHV')  AND " +
                    "EDO.EMPRESA=@Empresa  AND EDO.ESPGDO = 'P'  AND EDO.ESDO<>'N'  AND EDO.NUDONODEFI = 0 ";

            try
            {
                Conn.ConnGlasser.Open();
                Conn.CmdPlabal = new SqlCommand(Query, Conn.ConnGlasser);
                Conn.CmdPlabal.Parameters.AddWithValue("@RUT", Rut);
                Conn.CmdPlabal.Parameters.AddWithValue("@Empresa", Empresa);



                dr = Conn.CmdPlabal.ExecuteReader();
                dr.Read();
                if (dr.HasRows)
                {
                    Validadores validadores = new Validadores();
                    return(Math.Round(validadores.ParseoDouble(dr[0].ToString()), 0));
                }
                else
                {
                    return(0);
                }
            }
            catch (Exception EX)
            {
                string        ERRORSTR = "Mensaje:" + EX.Message + " trace: " + EX.StackTrace + " Rut:" + Rut + " empresa:" + Empresa;
                ErrorCatching gETerror = new ErrorCatching();
                gETerror.ErrorCatch(ERRORSTR, HttpContext.Current.Request.Url.ToString());
                dr.Close();
                Conn.ConnGlasser.Close();
                return(0);
            }
        }
Пример #5
0
        /* Hay que arreglar esta funcion, no está devolviendo ningun valor*/
        private double GetAmountPedidos()
        {
            Conn  = new Coneccion();
            Query = @"SELECT SUM (totalPedido) FROM e_Pedidos WHERE Estado='INGo' ";

            try
            {
                Conn.ConnPlabal.Open();
                Conn.CmdPlabal = new SqlCommand(Query, Conn.ConnPlabal);
                Conn.CmdPlabal.Parameters.AddWithValue("@RUT", Rut);
                Conn.CmdPlabal.Parameters.AddWithValue("@Empresa", Empresa);



                dr = Conn.CmdPlabal.ExecuteReader();
                dr.Read();
                if (dr.HasRows)
                {
                    Validadores validadores = new Validadores();
                    return(validadores.ParseoDouble(dr[0].ToString()));
                }
                else
                {
                    return(0);
                }
            }
            catch (Exception EX)
            {
                string        ERRORSTR = "Mensaje:" + EX.Message + " trace: " + EX.StackTrace + " Rut:" + Rut + " empresa:" + Empresa;
                ErrorCatching gETerror = new ErrorCatching();
                gETerror.ErrorCatch(ERRORSTR, HttpContext.Current.Request.Url.ToString());
                dr.Close();
                Conn.ConnPlabal.Close();
                return(0);
            }
        }
Пример #6
0
    protected void BtnGenConsumo_Click(object sender, EventArgs e)
    {
        string Msj        = "";
        string _TIDO      = "GDI";
        string _Modalidad = "PHPRO";
        string _Empresa   = "01";
        string _Endo      = "76829725-8";
        string _Sudo      = "PHU";
        string _Kofudo    = "CMP";
        string _ListaPre  = "TABPP02C";

        _DETALLE = new List <DetalleConsumo>();
        Validadores val = new Validadores();

        foreach (GridViewRow row in GrdDetalle.Rows)
        {
            DetalleConsumo detalle = new DetalleConsumo {
                _NUMOT     = row.Cells[0].Text,
                _CODIGO    = row.Cells[1].Text,
                _CANTIDADF = val.ParseoDouble(row.Cells[2].Text),
                _UNIDADC   = row.Cells[3].Text,
                _TIPO      = row.Cells[4].Text,
                _NIVELSUP  = row.Cells[5].Text,
                _SUBNREG   = row.Cells[6].Text,
                _OPERACION = row.Cells[7].Text,
                _SUOT      = row.Cells[8].Text,
                _KOFUCRE   = row.Cells[9].Text,
                _IDPOTD    = row.Cells[10].Text,
                _IDPOTL    = row.Cells[11].Text,
                _MODO      = row.Cells[12].Text,
                _TIMODO    = row.Cells[13].Text,
                _TIPOUNI   = row.Cells[14].Text,
                _UNIDAD    = row.Cells[15].Text,
                _TAMODO    = val.ParseoDouble(row.Cells[16].Text),
                _PPPRPMSUC = val.ParseoDouble(row.Cells[17].Text),
                _CODMAQ    = row.Cells[18].Text,
            };
            _DETALLE.Add(detalle);
        }
        int  total    = GrdDetalle.Rows.Count;
        bool CrearDoc = true;
        GenerarMAEDDOyMAEEDO generar = new GenerarMAEDDOyMAEEDO();
        int    contador = 1;
        bool   Doitem   = false;
        double t        = Convert.ToDouble(total) / 28;
        int    CantDoc  = Convert.ToInt32(Math.Ceiling(t));

        string[] DocList = new string[CantDoc];

        foreach (var item in _DETALLE)
        {
            if (CrearDoc)
            {
                GenerarDocumento Doc = new GenerarDocumento(_Empresa, _Modalidad, _TIDO);
                if (Doc.IsSuccess)
                {
                    DateTime      HOY    = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
                    Tablas.MAEEDO MAEEDO = new Tablas.MAEEDO
                    {
                        EMPRESA    = _Empresa,
                        TIDO       = _TIDO,
                        IDMAEEDO   = Doc.IDMAEEDO,
                        NUDO       = Doc.NroDocumento,
                        ENDO       = _Endo,
                        SUENDO     = "",
                        ENDOFI     = "",
                        TIGEDO     = "I",
                        SUDO       = _Sudo,
                        LUVTDO     = "",
                        FEEMDO     = HOY,
                        KOFUDO     = _Kofudo,
                        ESDO       = "C",
                        ESPGDO     = "S",
                        CAPRAD     = 0,
                        MEARDO     = "N",
                        MODO       = item._MODO,
                        TIMODO     = item._TIMODO,
                        TAMODO     = item._TAMODO,
                        NUCTAP     = 0,
                        VACTDTNEDO = 0,
                        NUIVDO     = 0,
                        POIVDO     = 0,
                        NUIMDO     = 0,
                        VAIMDO     = 0,
                        POPIDO     = 0,
                        VAPIDO     = 0,
                        FE01VEDO   = DateTime.Now,
                        FEULVEDO   = DateTime.Now,
                        FEER       = DateTime.Now,
                        NUVEDO     = 0,
                        VAABDO     = 0,
                        MARCA      = "",
                        NUTRANSMI  = "",
                        NUCOCO     = "",
                        KOTU       = "1",
                        LIBRO      = "",
                        LCLV       = val.ParseoDateTime("0"),
                        ESFADO     = "",
                        KOTRPCVH   = "",
                        NULICO     = "",
                        PERIODO    = "",
                        NUDONODEFI = false,
                        TRANSMASI  = "",
                        POIVARET   = 0,
                        VAIVARET   = 0,
                        RESUMEN    = "",
                        LAHORA     = DateTime.Now,
                        KOFUAUDO   = "",
                        KOOPDO     = "",
                        ESPRODDO   = "",
                        DESPACHO   = 0,
                        HORAGRAB   = (DateTime.Now.Hour * 60 + DateTime.Now.Minute) * 60,
                        RUTCONTACT = "",
                        SUBTIDO    = "",
                        TIDOELEC   = false,
                        ESDOIMP    = "",
                        CUOGASDIF  = "0",
                        BODESTI    = "",
                        PROYECTO   = "",
                        FECHATRIB  = val.ParseoDateTime("0"),
                        NUMOPERVEN = "0",
                        BLOQUEAPAG = "",
                        VALORRET   = 0,
                        FLIQUIFCV  = val.ParseoDateTime("0"),
                        VADEIVDO   = 0,
                        KOCANAL    = "",
                        KOCRYPT    = Doc.KOCRYPT,
                        LEYZONA    = "",
                        KOSIFIC    = "",
                        LISACTIVA  = _ListaPre,
                        KOFUAUTO   = "",
                        SUENDOFI   = "",
                        VAIVDOZF   = 0,
                        ENDOMANDA  = "",
                        FLUVTCALZA = "",
                        ARCHIXML   = "",
                        IDXML      = "0",
                        SERIENUDO  = "",
                        VALORAJU   = "0",
                    };
                    generar.GetMAEEDO(MAEEDO);
                    CantDoc--;
                    DocList[CantDoc] = MAEEDO.NUDO;
                    Doitem           = true;
                }
                else
                {
                    Doitem = false;
                    Msj    = "Hubo un error al tratar de generar el documento";
                    break;
                }
            }

            if (Doitem)
            {
                string _NULIDO = contador.ToString();

                generar.AddItemMAEDDO(item);
            }


            if (contador == 28)
            {
                if (total > 28)
                {
                    total = total - 28;
                }

                CrearDoc = true;
                contador = 1;
                bool[] retorno = generar.LuzCamaraAccion();
                if (!retorno[0] && !retorno[1])
                {
                    if (!retorno[0])
                    {
                        Msj = "Error al intentar generar el encabezado del documento";
                    }
                    if (!retorno[1])
                    {
                        Msj = "Error al intentar ingresar un item";
                    }

                    break;
                }
            }
            else if (contador == total)
            {
                bool[] retorno = generar.LuzCamaraAccion();
                if (!retorno[0] && !retorno[1])
                {
                    if (!retorno[0])
                    {
                        Msj = "Error al intentar generar el encabezado del documento";
                    }
                    if (!retorno[1])
                    {
                        Msj = "Error al intentar ingresar un item";
                    }

                    break;
                }
                else
                {
                    Msj = "El consumo ha sido creado exitosamente con la(s) siguiente(s) " + _TIDO + ": " + string.Join(", ", DocList);
                }
            }

            else
            {
                CrearDoc = false;
                contador++;
            }
        }

        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "myalert", "alert('" + Msj + "'); window.location='" +
                                                Page.ResolveUrl("~/View/Planificacion/Consumo.aspx") + "';", true);
    }