Advertisement
Guest User

None

a guest
Sep 19th, 2019
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 12.52 KB | None | 0 0
  1.         private void habilitar(List<servicio.DenominationType> enable,
  2.                                  List<servicio.DenominationType> disable, Boolean status, String denominacion) {
  3.             //creamos la denominacion como tipo del web service
  4.             Service_CI10.DenominationType den = new Service_CI10.DenominationType
  5.             {
  6.                 cc = "MXN",
  7.                 fv = denominacion + "00",
  8.                 Piece = "0",
  9.                 Status = "0"
  10.             };
  11.             if (status == true)
  12.                 enable.Add(den);
  13.             else
  14.                 disable.Add(den);
  15.         }
  16.  
  17.         public String noReciclable(servicio.InventoryResponseType resinventory) {
  18.             string[] decimal_no_rec = { "20000", "10000", "5000", "2000" };
  19.             foreach (String denominacion in decimal_no_rec)
  20.             {
  21.                 //Exist necesita una funcion como segundo parametro, por ellos se hace una exprecion lambda
  22.                 //en la que decimos que dicha funcion sera el equals.
  23.                 //Lo que se hace es que para cada elemento en resinventory.Cash[0].Denomination se busca
  24.                 //si hay un elemento que sea igual a la denominacion pedida
  25.                 //en caso de encontrar una entonces se envia la respuesta de que denominacion fue.
  26.                 if (Array.Exists(resinventory.Cash[0].Denomination, no_reciclable => no_reciclable.Equals(denominacion))) {
  27.                     return denominacion;
  28.                 }
  29.             }
  30.             return null;
  31.         }
  32.  
  33.         private void BtnCobrarMonto_Click(object sender, EventArgs e)
  34.         {
  35.             if (StatusEquipo() == "1")
  36.             {
  37.                 if (txtMonto.Text.TrimStart().TrimEnd() == "")
  38.                 {
  39.                     MessageBox.Show("Ingrese un monto valido");
  40.                     txtMonto.Text = "0";
  41.                 }
  42.                 Double Monto = Double.Parse(txtMonto.Text);
  43.                 if (Monto > 0)
  44.                 {
  45.                     servicio.InventoryResponseType resinventory = ConsultarInventarioDisponible();//Obtneog el inventario actual del equipo
  46.                     /*
  47.                     servicio.DenominationType[] disable = new servicio.DenominationType[6];
  48.                     servicio.DenominationType[] enable = new servicio.DenominationType[6];
  49.                     int indice_habilitar = 0, indiceDesha = 0;
  50.                     */
  51.                     List<servicio.DenominationType> on = new List<servicio.DenominationType>();
  52.                     List<servicio.DenominationType> off = new List<servicio.DenominationType>();
  53.                     Double TotalCash = TotalCashType(resinventory);
  54.                     //Recuerda cambiar ServiceSortek por service
  55.                     habilitar(on, off, TotalCash > 800, "500");
  56.                     habilitar(on, off, TotalCash > 1300, "1000");
  57.                     String tercera = noReciclable(resinventory);
  58.                     habilitar(on.off, TotalCash > 200, tercera);
  59.                     /*
  60.                     if ((TotalCashType(resinventory) > 800))
  61.                     {
  62.                         servicio.DenominationType quinientosdenominacion = new servicio.DenominationType();
  63.                         quinientosdenominacion.cc = "MXN";
  64.                         quinientosdenominacion.fv = "50000";
  65.                         quinientosdenominacion.Piece = "0";
  66.                         quinientosdenominacion.Status = "0";
  67.                         enable[indice_habilitar] = quinientosdenominacion;
  68.                         indice_habilitar += 1;
  69.                     }
  70.                     else
  71.                     {
  72.                         servicio.DenominationType quinientosdenominacion = new servicio.DenominationType();
  73.                         quinientosdenominacion.cc = "MXN";
  74.                         quinientosdenominacion.fv = "50000";
  75.                         quinientosdenominacion.Piece = "0";
  76.                         quinientosdenominacion.Status = "0";
  77.                         disable[indiceDesha] = quinientosdenominacion;
  78.                         indiceDesha += 1;
  79.                     }
  80.                    
  81.                     if ((TotalCashType(resinventory) > 1300))
  82.                     {
  83.                         servicio.DenominationType mildenominacion = new servicio.DenominationType();
  84.                         mildenominacion.cc = "MXN";
  85.                         mildenominacion.fv = "100000";
  86.                         mildenominacion.Piece = "0";
  87.                         mildenominacion.Status = "0";
  88.                         enable[indice_habilitar] = mildenominacion;
  89.                         indice_habilitar += 1;
  90.                     }
  91.                     else
  92.                     {
  93.                         servicio.DenominationType mildenominacion = new servicio.DenominationType();
  94.                         mildenominacion.cc = "MXN";
  95.                         mildenominacion.fv = "100000";
  96.                         mildenominacion.Piece = "0";
  97.                         mildenominacion.Status = "0";
  98.                         disable[indiceDesha] = mildenominacion;
  99.                         indiceDesha += 1;
  100.                     }
  101.                     */
  102.  
  103.                     /**********BUSCO LA VARIABLE QUE NO ESTA RECICLABLE***********
  104.                     string[] decimal_no_rec = { "20000", "10000", "5000", "2000" };
  105.                     string tercera_dec_No_rec = null;
  106.                     for (int fam_No_rec = 0; fam_No_rec < decimal_no_rec.Length; fam_No_rec++)
  107.                     {
  108.                         bool encontrado = false;
  109.                         for (int bus_rec = 0; bus_rec < resinventory.Cash[0].Denomination.Length; bus_rec++)
  110.                         {
  111.                             if (resinventory.Cash[0].Denomination[bus_rec].fv == decimal_no_rec[fam_No_rec])
  112.                             {
  113.                                 encontrado = true;
  114.                                 break;
  115.                             }
  116.                         }
  117.                         if (!encontrado)
  118.                         {
  119.                             tercera_dec_No_rec = decimal_no_rec[fam_No_rec];
  120.                             break;
  121.                         }
  122.                     }
  123.  
  124.                     if ((TotalCashType(resinventory) > 200))
  125.                     {
  126.                         servicio.DenominationType denominacion_desc = new servicio.DenominationType();
  127.                         denominacion_desc.cc = "MXN";
  128.                         denominacion_desc.fv = tercera_dec_No_rec;
  129.                         denominacion_desc.Piece = "0";
  130.                         denominacion_desc.Status = "0";
  131.                         enable[indice_habilitar] = denominacion_desc;
  132.                         indice_habilitar += 1;
  133.                     }
  134.                     else
  135.                     {
  136.                         servicio.DenominationType denominacion_desc = new servicio.DenominationType();
  137.                         denominacion_desc.cc = "MXN";
  138.                         denominacion_desc.fv = tercera_dec_No_rec;
  139.                         denominacion_desc.Piece = "0";
  140.                         denominacion_desc.Status = "0";
  141.                         disable[indiceDesha] = denominacion_desc;
  142.                         indiceDesha += 1;
  143.  
  144.                     }
  145.                     */
  146.                     /*******************MANDO LA INDICACION DE QUE DENOMINACIONES HABILITAR/DESHABILITAR*******************/
  147.                     servicio.DisableDenomRequestType disden = new servicio.DisableDenomRequestType();
  148.                     disden.Id = (1).ToString();
  149.                     disden.SeqNo = (777).ToString();
  150.                     //mandar el usuario
  151.                     disden.SessionID = ("").ToString();
  152.                     disden.Cash = new servicio.CashType();
  153.                     disden.Cash.type = "5";
  154.                     disden.Cash.Denomination = off.ToArray();
  155.                     servicio.DisableDenomResponseType dr = POS.DisableDenomOperation(disden);
  156.                     /////////////////////////////////////////
  157.                     servicio.EnableDenomRequestType endin = new servicio.EnableDenomRequestType();
  158.                     endin.Id = (1).ToString();
  159.                     endin.SeqNo = (777).ToString();
  160.                     endin.SessionID = ("").ToString();
  161.                     endin.Cash = new servicio.CashType();
  162.                     endin.Cash.type = "5";
  163.                     endin.Cash.Denomination = on.ToArray();
  164.                     servicio.EnableDenomResponseType es = POS.EnableDenomOperation(endin);
  165.                     ///******************************Hago el cobro************************************/
  166.                     String trama = null;
  167.                     //TODO: hacer el chequeo de la respuesta para el enable y disable
  168.  
  169.                     Console.WriteLine(off.ToString() + on.ToString());
  170.                     foreach (servicio.DenominationType den in off) {
  171.                         trama += (", " + Double.Parse(den.fv) * 0.01).ToString();
  172.                     }
  173.                     /*
  174.                     for (int mostrar_disable = 0; mostrar_disable < disable.Length; mostrar_disable++)
  175.                     {
  176.  
  177.                         if (disable[mostrar_disable] != null)
  178.                         {
  179.                             trama += (", " + Double.Parse(disable[mostrar_disable].fv) * 0.01).ToString();
  180.                         }
  181.                     }
  182.                     */
  183.                     // if (trama != null) MessageBox.Show("Por el momento no acepto denominaciones" + trama);
  184.                     //else MessageBox.Show("Acepto todas las denominaciones");
  185.  
  186.                     servicio.ChangeRequestType cobro = new servicio.ChangeRequestType();
  187.                     String UltimaTransaccion = gestorDeConeccionBD.ObtenerUltimaTransaccion();
  188.                     //cobro.Id = UltimaTransaccion;
  189.  
  190.                     //cobro.SeqNo = DateTime.Now.ToString("PAGOddMMyyHHmmss");
  191.                     cobro.Id = DateTime.Now.ToString("PAGOddMMyyHHmmss");
  192.  
  193.                     cobro.SeqNo = UltimaTransaccion;
  194.  
  195.                     //cobro.SeqNo = "pago";
  196.                     cobro.SessionID = this.Text;
  197.                     cobro.Amount = (Double.Parse(txtMonto.Text.TrimStart().TrimEnd()) * 100).ToString();
  198.                     POS.ChangeOperationAsync(cobro);
  199.                     lblCancel.Text = "0";
  200.                     txtMonto.Text = "";
  201.                 }
  202.                 //std.ChangeOperation(cobro);
  203.  
  204.                 else if (Double.Parse(txtMonto.Text) < 1)
  205.                 {
  206.                     MessageBox.Show("el monto no puede ser cero o menor");
  207.                     //servicio.ChangeRequestType cobro = new servicio.ChangeRequestType();
  208.                     //cobro.Id = (id += 1).ToString();
  209.                     //cobro.SeqNo = (seqno += 1).ToString();
  210.                     //cobro.SessionID = (session += 1).ToString();
  211.                     //cobro.Amount = (Double.Parse(textBox1.Text) * 100).ToString();
  212.                     //std.ChangeOperationAsync(cobro);
  213.                 }
  214.                 else
  215.                 {
  216.                     MessageBox.Show("No se acepta valor cero como para cobrar");
  217.                 }
  218.  
  219.             }
  220.             else MessageBox.Show("Equipo ocupado..");
  221.         }
  222.  
  223.         public servicio.InventoryResponseType ConsultarInventarioDisponibleI()
  224.         {
  225.             servicio.InventoryRequestType inventory = new servicio.InventoryRequestType();
  226.             //String UltimaTransaccion = gestorDeConeccionBD.ObtenerUltimaTransaccion();
  227.             inventory.Id = "666";
  228.             inventory.SeqNo = DateTime.Now.ToString("ddMMyyHHmmss");
  229.             inventory.SessionID = ("SORTEK").ToString();
  230.             inventory.Option = new servicio.InventoryOptionType();
  231.             inventory.Option.type = "2";//Disponible
  232.             return POS.InventoryOperation(inventory);
  233.  
  234.  
  235.         }
  236.         public double TotalCashType(servicio.InventoryResponseType IRT_get_inventory_RESPONSE)
  237.         {
  238.             servicio.DenominationType[] catch_Denomination = IRT_get_inventory_RESPONSE.Cash[0].Denomination;
  239.             double TotalInventario = 0;
  240.  
  241.             for (int count = 0; count < catch_Denomination.Length; count++)
  242.             {
  243.                 double Denominacion = Double.Parse(catch_Denomination[count].fv) * 0.01;
  244.                 int nom_pieces = int.Parse(catch_Denomination[count].Piece);
  245.                 TotalInventario = TotalInventario + (Denominacion * nom_pieces);
  246.             }
  247.             return TotalInventario;
  248.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement