Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void habilitar(List<servicio.DenominationType> enable,
- List<servicio.DenominationType> disable, Boolean status, String denominacion) {
- //creamos la denominacion como tipo del web service
- Service_CI10.DenominationType den = new Service_CI10.DenominationType
- {
- cc = "MXN",
- fv = denominacion + "00",
- Piece = "0",
- Status = "0"
- };
- if (status == true)
- enable.Add(den);
- else
- disable.Add(den);
- }
- public String noReciclable(servicio.InventoryResponseType resinventory) {
- string[] decimal_no_rec = { "20000", "10000", "5000", "2000" };
- foreach (String denominacion in decimal_no_rec)
- {
- //Exist necesita una funcion como segundo parametro, por ellos se hace una exprecion lambda
- //en la que decimos que dicha funcion sera el equals.
- //Lo que se hace es que para cada elemento en resinventory.Cash[0].Denomination se busca
- //si hay un elemento que sea igual a la denominacion pedida
- //en caso de encontrar una entonces se envia la respuesta de que denominacion fue.
- if (Array.Exists(resinventory.Cash[0].Denomination, no_reciclable => no_reciclable.Equals(denominacion))) {
- return denominacion;
- }
- }
- return null;
- }
- private void BtnCobrarMonto_Click(object sender, EventArgs e)
- {
- if (StatusEquipo() == "1")
- {
- if (txtMonto.Text.TrimStart().TrimEnd() == "")
- {
- MessageBox.Show("Ingrese un monto valido");
- txtMonto.Text = "0";
- }
- Double Monto = Double.Parse(txtMonto.Text);
- if (Monto > 0)
- {
- servicio.InventoryResponseType resinventory = ConsultarInventarioDisponible();//Obtneog el inventario actual del equipo
- /*
- servicio.DenominationType[] disable = new servicio.DenominationType[6];
- servicio.DenominationType[] enable = new servicio.DenominationType[6];
- int indice_habilitar = 0, indiceDesha = 0;
- */
- List<servicio.DenominationType> on = new List<servicio.DenominationType>();
- List<servicio.DenominationType> off = new List<servicio.DenominationType>();
- Double TotalCash = TotalCashType(resinventory);
- //Recuerda cambiar ServiceSortek por service
- habilitar(on, off, TotalCash > 800, "500");
- habilitar(on, off, TotalCash > 1300, "1000");
- String tercera = noReciclable(resinventory);
- habilitar(on.off, TotalCash > 200, tercera);
- /*
- if ((TotalCashType(resinventory) > 800))
- {
- servicio.DenominationType quinientosdenominacion = new servicio.DenominationType();
- quinientosdenominacion.cc = "MXN";
- quinientosdenominacion.fv = "50000";
- quinientosdenominacion.Piece = "0";
- quinientosdenominacion.Status = "0";
- enable[indice_habilitar] = quinientosdenominacion;
- indice_habilitar += 1;
- }
- else
- {
- servicio.DenominationType quinientosdenominacion = new servicio.DenominationType();
- quinientosdenominacion.cc = "MXN";
- quinientosdenominacion.fv = "50000";
- quinientosdenominacion.Piece = "0";
- quinientosdenominacion.Status = "0";
- disable[indiceDesha] = quinientosdenominacion;
- indiceDesha += 1;
- }
- if ((TotalCashType(resinventory) > 1300))
- {
- servicio.DenominationType mildenominacion = new servicio.DenominationType();
- mildenominacion.cc = "MXN";
- mildenominacion.fv = "100000";
- mildenominacion.Piece = "0";
- mildenominacion.Status = "0";
- enable[indice_habilitar] = mildenominacion;
- indice_habilitar += 1;
- }
- else
- {
- servicio.DenominationType mildenominacion = new servicio.DenominationType();
- mildenominacion.cc = "MXN";
- mildenominacion.fv = "100000";
- mildenominacion.Piece = "0";
- mildenominacion.Status = "0";
- disable[indiceDesha] = mildenominacion;
- indiceDesha += 1;
- }
- */
- /**********BUSCO LA VARIABLE QUE NO ESTA RECICLABLE***********
- string[] decimal_no_rec = { "20000", "10000", "5000", "2000" };
- string tercera_dec_No_rec = null;
- for (int fam_No_rec = 0; fam_No_rec < decimal_no_rec.Length; fam_No_rec++)
- {
- bool encontrado = false;
- for (int bus_rec = 0; bus_rec < resinventory.Cash[0].Denomination.Length; bus_rec++)
- {
- if (resinventory.Cash[0].Denomination[bus_rec].fv == decimal_no_rec[fam_No_rec])
- {
- encontrado = true;
- break;
- }
- }
- if (!encontrado)
- {
- tercera_dec_No_rec = decimal_no_rec[fam_No_rec];
- break;
- }
- }
- if ((TotalCashType(resinventory) > 200))
- {
- servicio.DenominationType denominacion_desc = new servicio.DenominationType();
- denominacion_desc.cc = "MXN";
- denominacion_desc.fv = tercera_dec_No_rec;
- denominacion_desc.Piece = "0";
- denominacion_desc.Status = "0";
- enable[indice_habilitar] = denominacion_desc;
- indice_habilitar += 1;
- }
- else
- {
- servicio.DenominationType denominacion_desc = new servicio.DenominationType();
- denominacion_desc.cc = "MXN";
- denominacion_desc.fv = tercera_dec_No_rec;
- denominacion_desc.Piece = "0";
- denominacion_desc.Status = "0";
- disable[indiceDesha] = denominacion_desc;
- indiceDesha += 1;
- }
- */
- /*******************MANDO LA INDICACION DE QUE DENOMINACIONES HABILITAR/DESHABILITAR*******************/
- servicio.DisableDenomRequestType disden = new servicio.DisableDenomRequestType();
- disden.Id = (1).ToString();
- disden.SeqNo = (777).ToString();
- //mandar el usuario
- disden.SessionID = ("").ToString();
- disden.Cash = new servicio.CashType();
- disden.Cash.type = "5";
- disden.Cash.Denomination = off.ToArray();
- servicio.DisableDenomResponseType dr = POS.DisableDenomOperation(disden);
- /////////////////////////////////////////
- servicio.EnableDenomRequestType endin = new servicio.EnableDenomRequestType();
- endin.Id = (1).ToString();
- endin.SeqNo = (777).ToString();
- endin.SessionID = ("").ToString();
- endin.Cash = new servicio.CashType();
- endin.Cash.type = "5";
- endin.Cash.Denomination = on.ToArray();
- servicio.EnableDenomResponseType es = POS.EnableDenomOperation(endin);
- ///******************************Hago el cobro************************************/
- String trama = null;
- //TODO: hacer el chequeo de la respuesta para el enable y disable
- Console.WriteLine(off.ToString() + on.ToString());
- foreach (servicio.DenominationType den in off) {
- trama += (", " + Double.Parse(den.fv) * 0.01).ToString();
- }
- /*
- for (int mostrar_disable = 0; mostrar_disable < disable.Length; mostrar_disable++)
- {
- if (disable[mostrar_disable] != null)
- {
- trama += (", " + Double.Parse(disable[mostrar_disable].fv) * 0.01).ToString();
- }
- }
- */
- // if (trama != null) MessageBox.Show("Por el momento no acepto denominaciones" + trama);
- //else MessageBox.Show("Acepto todas las denominaciones");
- servicio.ChangeRequestType cobro = new servicio.ChangeRequestType();
- String UltimaTransaccion = gestorDeConeccionBD.ObtenerUltimaTransaccion();
- //cobro.Id = UltimaTransaccion;
- //cobro.SeqNo = DateTime.Now.ToString("PAGOddMMyyHHmmss");
- cobro.Id = DateTime.Now.ToString("PAGOddMMyyHHmmss");
- cobro.SeqNo = UltimaTransaccion;
- //cobro.SeqNo = "pago";
- cobro.SessionID = this.Text;
- cobro.Amount = (Double.Parse(txtMonto.Text.TrimStart().TrimEnd()) * 100).ToString();
- POS.ChangeOperationAsync(cobro);
- lblCancel.Text = "0";
- txtMonto.Text = "";
- }
- //std.ChangeOperation(cobro);
- else if (Double.Parse(txtMonto.Text) < 1)
- {
- MessageBox.Show("el monto no puede ser cero o menor");
- //servicio.ChangeRequestType cobro = new servicio.ChangeRequestType();
- //cobro.Id = (id += 1).ToString();
- //cobro.SeqNo = (seqno += 1).ToString();
- //cobro.SessionID = (session += 1).ToString();
- //cobro.Amount = (Double.Parse(textBox1.Text) * 100).ToString();
- //std.ChangeOperationAsync(cobro);
- }
- else
- {
- MessageBox.Show("No se acepta valor cero como para cobrar");
- }
- }
- else MessageBox.Show("Equipo ocupado..");
- }
- public servicio.InventoryResponseType ConsultarInventarioDisponibleI()
- {
- servicio.InventoryRequestType inventory = new servicio.InventoryRequestType();
- //String UltimaTransaccion = gestorDeConeccionBD.ObtenerUltimaTransaccion();
- inventory.Id = "666";
- inventory.SeqNo = DateTime.Now.ToString("ddMMyyHHmmss");
- inventory.SessionID = ("SORTEK").ToString();
- inventory.Option = new servicio.InventoryOptionType();
- inventory.Option.type = "2";//Disponible
- return POS.InventoryOperation(inventory);
- }
- public double TotalCashType(servicio.InventoryResponseType IRT_get_inventory_RESPONSE)
- {
- servicio.DenominationType[] catch_Denomination = IRT_get_inventory_RESPONSE.Cash[0].Denomination;
- double TotalInventario = 0;
- for (int count = 0; count < catch_Denomination.Length; count++)
- {
- double Denominacion = Double.Parse(catch_Denomination[count].fv) * 0.01;
- int nom_pieces = int.Parse(catch_Denomination[count].Piece);
- TotalInventario = TotalInventario + (Denominacion * nom_pieces);
- }
- return TotalInventario;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement