Ejemplo n.º 1
0
 protected void btnValidar_Click(object sender, EventArgs e)
 {
     try
     {
         Page.Validate("Numbers");
         if (Page.IsValid)
         {
             //txtCodObra.Enabled = false;
             //DCliente();
             SimServ Validator = new SimServ();
             if (CHKPlanta.SelectedItem.Value == "1")
             {
                 FillGrid(Validator.ValObra(Int64.Parse(txtCodObra.Text), true));
             }
             else
             {
                 FillGrid(Validator.ValObra(Int64.Parse(txtCodObra.Text), false));
             }
         }
     }
     catch (Exception ex)
     {
         var a = ex;
         throw;
     }
 }
Ejemplo n.º 2
0
        private String GetData(String Segcli, String SegReg, string planta)
        {
            SimServ valSeg = new SimServ();

            Boolean prueba = false;

            if (planta != "0")
            {
                prueba = true;
            }
            return(valSeg.ValSegmentacion(Segcli, SegReg, prueba));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// OBTIENE LOS DATOS DEL CLIENTE
        /// </summary>
        public void DCliente()
        {
            try
            {
                lblErrorCod.Visible = false;
                SI_OS_CustomerStatementClient    cli = new SI_OS_CustomerStatementClient("HTTP_Port");
                requestCustomerStatementRequest  d   = new requestCustomerStatementRequest();
                requestCustomerStatementResponse x   = new requestCustomerStatementResponse();
                d.MT_CustomerStatementReq               = new DT_CustomerStatementReq();
                d.MT_CustomerStatementReq.I_KUNNR       = txtCodObra.Text.Trim();
                d.MT_CustomerStatementReq.I_VKORG       = "7544";
                d.MT_CustomerStatementReq.I_VTWEG       = "00";
                d.MT_CustomerStatementReq.I_SPART       = (txtSector.Text.Trim() == "" ? "0" : (txtSector.Text.Trim().Length == 1 & int.Parse(txtSector.Text) < 10 ? "0" + txtSector.Text.Trim() : txtSector.Text.Trim()));
                d.MT_CustomerStatementReq.I_FCURR       = "COP";
                d.MT_CustomerStatementReq.I_TCURR       = "COP";
                cli.ClientCredentials.UserName.UserName = "******";
                cli.ClientCredentials.UserName.Password = "******";
                SI_OS_CustomerStatement inter2 = cli;
                x.MT_CustomerStatementResp = inter2.requestCustomerStatement(d).MT_CustomerStatementResp;
                if (x.MT_CustomerStatementResp.E_EXCEPTION == string.Empty | x.MT_CustomerStatementResp.E_EXCEPTION == null)
                {
                    txtCodObra.Enabled = false;
                    btnValidar.Enabled = false;
                    txtSector.Enabled  = false;
                    DataTable dt      = new DataTable();
                    DataTable dtEC    = new DataTable();
                    DataTable dtSeg   = new DataTable();
                    DataTable dtBl    = new DataTable();
                    DataTable dtVen   = new DataTable();
                    DataTable dtVenL  = new DataTable();
                    DataTable dtExAll = new DataTable();
                    DataRow   row;
                    SimServ   Master = new SimServ();
                    if (x.MT_CustomerStatementResp.E_BITOC.Trim() != "" & txtCodObra.Text.Trim() != "")
                    {
                        CAlert("1;|2;" + x.MT_CustomerStatementResp.E_BITOC.Trim() + "|3;" + txtCodObra.Text.Trim());
                    }
                    dtSeg            = (DataTable)ECmSp("SPSIUSEGCLI|@TCOM;4|@IDCLIENTE;" + Int64.Parse(x.MT_CustomerStatementResp.E_BITOC) + "|@IDSCANAL;9000032821", cnnSAPDB, 1);
                    Session["CliEx"] = ECmSp("SPSIT_CE|@IDCON;11|@IDCLIENTE;" + Int64.Parse(x.MT_CustomerStatementResp.E_BITOC) + "|@IDOBRA;" + Int64.Parse(txtCodObra.Text), cnnCOS, 1);
                    dtExAll          = (DataTable)ECmSp("SPSIT_CE|@IDCON;12|@IDCLIENTE;" + Int64.Parse(x.MT_CustomerStatementResp.E_BITOC) + "|@IDOBRA;" + Int64.Parse(txtCodObra.Text) + "|@IdPais;" + ((IUsr)Session["Usr"]).usr.Pais.IdPais, cnnCOS, 1);
                    dtVen            = (DataTable)ECmSp("SPS_R_OV|@TCOM;1|@IDORG;7460|@IDSECTOR;" + int.Parse(txtSector.Text) + "|@IDOBRA;" + txtCodObra.Text.Trim(), cnnSAPDB, 1);
                    if (dtVen.Rows.Count > 0)
                    {
                        dtVenL = (DataTable)ECmSp("SPSIU_VEN|@TCOM;1|@IDVEN;" + dtVen.Rows[0]["IdCodVen"].ToString(), cnnCOS, 1);
                    }
                    dtBl = (DataTable)ECmSp("SPSIT_BC|@TCOM;4|@IDCLIENTE;" + int.Parse(x.MT_CustomerStatementResp.E_BITOC).ToString() + "|@IDOBRA;" + txtCodObra.Text.Trim(), cnnCOS, 1);
                    dt.Columns.Add("NOMOBRA");
                    dt.Columns.Add("CODCLI");
                    dt.Columns.Add("NOMCLI");
                    dt.Columns.Add("FPAGO");
                    if (dtSeg.Rows.Count > 0)
                    {
                        dt.Columns.Add("NSEG");
                    }
                    if (dtVen.Rows.Count > 0)
                    {
                        dt.Columns.Add("VEN");
                    }
                    if (dtVenL.Rows.Count > 0)
                    {
                        dt.Columns.Add("TELVEN");
                    }
                    row    = dt.NewRow();
                    row[0] = x.MT_CustomerStatementResp.E_CNAME;
                    row[1] = x.MT_CustomerStatementResp.E_BITOC;
                    row[2] = x.MT_CustomerStatementResp.E_BITON;
                    row[3] = Master.GetZTERM(long.Parse(txtCodObra.Text), Int32.Parse(txtSector.Text) < 10?txtSector.Text.Split('0')[1]:txtSector.Text);//x.MT_CustomerStatementResp.E_ZTERM;
                    if (dtSeg.Rows.Count > 0)
                    {
                        for (int i = 0; i <= dtSeg.Rows.Count - 1; i++)
                        {
                            if (Int64.Parse(dtSeg.Rows[i][0].ToString()) == 9000032821)
                            {
                                Session["IdSCanal"] = Int64.Parse(dtSeg.Rows[i][0].ToString());
                                row[4] = dtSeg.Rows[i][1];
                                break;
                            }
                            if (Int64.Parse(dtSeg.Rows[i][0].ToString()) == 9000032822)
                            {
                                Session["IdSCanal"] = Int64.Parse(dtSeg.Rows[i][0].ToString());
                                row[4] = dtSeg.Rows[i][1];
                                break;
                            }
                            if (i == dtSeg.Rows.Count - 1)
                            {
                                Session["IdSCanal"] = Int64.Parse(dtSeg.Rows[i][0].ToString());
                                row[4] = dtSeg.Rows[i][1];
                            }
                        }
                        gv_DataCli.Columns[4].Visible = true;
                    }
                    if (dtVen.Rows.Count > 0)
                    {
                        if (dtSeg.Rows.Count > 0)
                        {
                            row[5] = dtVen.Rows[0]["NVen"];
                            gv_DataCli.Columns[5].Visible = true;
                            if (dtVenL.Rows.Count > 0)
                            {
                                row[6] = dtVenL.Rows[0]["Tel"];
                                gv_DataCli.Columns[6].Visible = true;
                            }
                        }
                        else
                        {
                            row[4] = dtVen.Rows[0]["NVen"];
                            gv_DataCli.Columns[5].Visible = true;
                            if (dtVenL.Rows.Count > 0)
                            {
                                row[5] = dtVenL.Rows[0]["Tel"];
                                gv_DataCli.Columns[6].Visible = true;
                            }
                        }
                    }



                    Session["dtBl"] = dtBl;

                    gvBlCli.DataSource = dtBl;
                    gvBlCli.DataBind();

                    Session["dtExAll"] = dtExAll;

                    gv_ExCli.DataSource = dtExAll;
                    gv_ExCli.DataBind();

                    dt.Rows.Add(row);
                    gv_DataCli.DataSource = dt;
                    gv_DataCli.DataBind();
                    gv_DataCli.Visible = true;

                    //Estado de cuenta

                    btnNCal.Visible = false;
                    lblAPG.Visible  = false;
                    lblEC.Visible   = false;
                    lblECT.Visible  = false;
                    dtEC.Columns.Add("CUPO");
                    dtEC.Columns.Add("SFAVOR");
                    dtEC.Columns.Add("CTOTAL");
                    dtEC.Columns.Add("CMPSAP");
                    dtEC.Columns.Add("CMPGINCO");
                    dtEC.Columns.Add("TSCUPO");
                    row = dtEC.NewRow();

                    var rpctIlc = ServiceI <BCfgServ> .Instance.getPctILC(((IUsr)Session["Usr"]).usr.Pais.IdPais);

                    Double pctIlc = 0;
                    if (rpctIlc != null)
                    {
                        pctIlc = (rpctIlc.Value == String.Empty ? 0 : DNum(rpctIlc.Value));
                        pctIlc = (pctIlc >= 1 ? pctIlc / 100 : pctIlc) + 1;
                    }
                    else
                    {
                        pctIlc = 1;
                    }

                    row[0] = DNum(x.MT_CustomerStatementResp.E_LIMCR) * 100 * pctIlc;
                    row[1] = DNum(x.MT_CustomerStatementResp.E_SLDAF);
                    row[2] = DNum(x.MT_CustomerStatementResp.E_CARTT);
                    //row[3] = (x.MT_CustomerStatementResp.E_IPFAC.Replace('.', ',').Contains('-') ? (double.Parse(x.MT_CustomerStatementResp.E_IPFAC.Replace('.', ',').Replace('-', ' ')) * -1) : double.Parse(x.MT_CustomerStatementResp.E_IPFAC.Replace('.', ','))) * 100;
                    row[3] = DNum(x.MT_CustomerStatementResp.E_IPFAC) * 100;
                    //row[4] = CmpGinCliente(int.Parse(dt.Rows[0]["CODCLI"].ToString()));
                    row[4] = 0;

                    row[5] = double.Parse(row[0].ToString()) + (double.Parse(row[1].ToString()) * (-1));
                    row[5] = double.Parse(row[5].ToString()) - double.Parse(row[2].ToString());
                    row[5] = double.Parse(row[5].ToString()) - double.Parse(row[3].ToString());
                    row[5] = double.Parse(row[5].ToString()) - double.Parse(row[4].ToString());

                    dtEC.Rows.Add(row);

                    Session["EstadoCuenta"] = dtEC;
                    gv_EC_Cli.DataSource    = dtEC;
                    gv_EC_Cli.DataBind();
                    gv_EC_Cli.Visible = true;
                    GvStyle(2, dtEC);

                    //Ocultar Columna Comprometido en GINCO
                    gv_EC_Cli.HeaderRow.Cells[4].Visible = false;
                    gv_EC_Cli.Rows[0].Cells[4].Visible   = false;

                    //////////////////

                    Boolean  val = false;
                    DateTime date;
                    var      exE = ((DataTable)Session["CliEx"]).AsEnumerable();
                    if (exE.Count() > 0)
                    {
                        foreach (var ex in exE)
                        {
                            if (ex["IdTEx"].ToString().Trim() == "PMT")
                            {
                                val = true;
                                break;
                            }
                            if (DateTime.TryParse(ex["dtVig"].ToString(), out date))
                            {
                                if ((DateTime.Parse(ex["dtVig"].ToString()) >= DateTime.Today))
                                {
                                    val = true;
                                    break;
                                }
                            }
                        }
                    }
                    if (val)
                    {
                        lblEC.Text = "Excepciones Activas.";
                        try
                        {
                            var res = (from ex in exE
                                       where (DateTime.TryParse(ex["dtVig"].ToString(), out date) ? DateTime.Parse(ex["dtVig"].ToString()) >= DateTime.Today : true)
                                       select new { Excepción = ex["NTEx"] as string, FechaVigencia = (DateTime.TryParse(ex["dtVig"].ToString(), out date) ? String.Format("{0:yyyy-MM-dd}", ex["dtVig"]) : ex["dtVig"].ToString()), MsgEx = ex["MsgEx"] as string }).ToList();
                            gv_ExClientes.DataSource = res;
                            gv_ExClientes.DataBind();
                            gv_ExClientes.Visible = true;
                            lblExMsg.Text         = "Puede proceder con la programación en RMS!!!";
                            lblEC.Visible         = true;
                            //lblECT.Visible = true;
                            lblExMsg.CssClass = "labelInfo";
                            lblExMsg.Visible  = true;
                        }
                        catch (Exception)
                        {
                            throw;
                        }
                    }
                    else
                    {
                        if (double.Parse(row[5].ToString()) < 0)
                        {
                            lblSN.Visible  = true;
                            lblANP.Text    = "NO EFECTUAR LA PROGRAMACIÓN SI NO SE REGISTRA UN AJUSTE!!";
                            lblANP.Visible = true;
                        }
                        else
                        {
                            lblSN.Visible = false;
                            //lblAC.Visible = false;

                            //btnCal.Visible = true;
                            btnNCal.Visible = true;
                        }

                        var CliEx = (DataTable)ECmSp("SPSIT_CE|@IDCON;10|@IDCLIENTE;" + Int64.Parse(x.MT_CustomerStatementResp.E_BITOC), cnnCOS, 1);
                        var ce    = CliEx.Rows.Count > 0 ? CliEx.AsEnumerable() : null;
                        if (ce != null)
                        {
                            lblEC.Text = "Excepciones Activas.";
                            var res = (from ex in ce
                                       where (DateTime.TryParse(ex["dtVig"].ToString(), out date) ? DateTime.Parse(ex["dtVig"].ToString()) >= DateTime.Today : true)
                                       select new { Excepción = ex["NTEx"] as string, FechaVigencia = (DateTime.TryParse(ex["dtVig"].ToString(), out date) ? String.Format("{0:yyyy-MM-dd}", ex["dtVig"]) : ex["dtVig"].ToString()), MsgEx = ex["MsgEx"] as string }).ToList();
                            gv_ExClientes.DataSource = res;
                            gv_ExClientes.DataBind();
                            gv_ExClientes.Visible = true;
                            lblExMsg.Visible      = false;
                            lblEC.Visible         = true;
                        }
                    }

                    ServLog RegLog = new ServLog();
                    RegLog.SaveCLog(((IUsr)Session["Usr"]).usr.CemexId, Int64.Parse(txtCodObra.Text.ToString()), Int32.Parse(txtSector.Text.ToString()), x.MT_CustomerStatementResp.E_CNAME, Int64.Parse(x.MT_CustomerStatementResp.E_BITOC), x.MT_CustomerStatementResp.E_BITON, Master.GetZTERM(long.Parse(txtCodObra.Text), Int32.Parse(txtSector.Text) < 10 ? txtSector.Text.Split('0')[1] : txtSector.Text) /*x.MT_CustomerStatementResp.E_ZTERM*/, dtVen.Rows.Count > 0 ? (dtVen.Rows[0]["NVen"]).ToString() : "", (Int64)(DNum(x.MT_CustomerStatementResp.E_LIMCR) * 100 * pctIlc), (Int64)DNum(x.MT_CustomerStatementResp.E_SLDAF), (Int64)DNum(x.MT_CustomerStatementResp.E_CARTT), (Int64)(DNum(x.MT_CustomerStatementResp.E_IPFAC) * 100), Int64.Parse(row[5].ToString()), dtExAll.Rows.Count > 0 ? (dtExAll.Rows[0].ItemArray[0]).ToString() : "");
                }
                else
                {
                    //pnlAditivos.Visible = false;
                    //pnlAB.Visible = false;
                    gv_DataCli.Visible  = false;
                    gv_EC_Cli.Visible   = false;
                    lblErrorCod.Visible = true;
                }
            }

            catch (Exception e)
            {  

              throw; }
        }