private void btnSaveFcurrency_Click(object sender, EventArgs e) { for (int i = 0; i < ProgramConfig.MAX_FCURRENCY_COUNT; i++) { try { DataGridViewCheckBoxCell selectedCell = (DataGridViewCheckBoxCell)dgvFCurrency.Rows[i].Cells[clmnFCurrSelected.Name]; if (selectedCell.Value != null && (bool)selectedCell.Value == true) { //NAME String name = dgvFCurrency.Rows[i].Cells[clmnFCurrName.Index].Value.ToString(); //PRICE decimal price = Convert.ToDecimal(dgvFCurrency.Rows[i].Cells[clmnFCurrRate.Index].Value); // Send command CPResponse response = new CPResponse(bridge.Printer.SetCurrencyInfo(i, name, price)); if (response.ErrorCode == 0) { FCurrency curr = new FCurrency(); curr.ID = i; curr.Name = response.GetNextParam(); curr.Rate = decimal.Parse(response.GetNextParam()); MainForm.SetCurrency(curr.ID, curr); } } } catch (TimeoutException) { bridge.Log(FormMessage.TIMEOUT_ERROR); } catch { bridge.Log(FormMessage.OPERATION_FAILS); } } }
private int LoadCurrency() { int successCount = 0; for (int i = 0; i < ProgramConfig.MAX_FCURRENCY_COUNT; i++) { try { CPResponse response = new CPResponse(bridge.Printer.GetCurrencyInfo(i)); if (response.ErrorCode == 0) { FCurrency curr = new FCurrency(); curr.ID = i; curr.Name = response.GetNextParam(); curr.Rate = decimal.Parse(response.GetNextParam()); MainForm.SetCurrency(curr.ID, curr); } } catch { } } return successCount; }
private void btnGetFCurrency_Click(object sender, EventArgs e) { dgvFCurrency.Rows.Clear(); for (int i = 0; i < ProgramConfig.MAX_FCURRENCY_COUNT; i++) { try { CPResponse response = new CPResponse(bridge.Printer.GetCurrencyInfo(i)); if (response.ErrorCode == 0) { FCurrency curr = new FCurrency(); curr.ID = i; curr.Name = response.GetNextParam(); curr.Rate = decimal.Parse(response.GetNextParam()); int index = dgvFCurrency.Rows.Add(); dgvFCurrency.Rows[index].Cells[clmnFCurrId.Name].Value = curr.ID + 1; dgvFCurrency.Rows[index].Cells[clmnFCurrName.Name].Value = curr.Name; dgvFCurrency.Rows[index].Cells[clmnFCurrRate.Name].Value = curr.Rate; MainForm.SetCurrency(curr.ID, curr); } } catch (TimeoutException) { bridge.Log(FormMessage.TIMEOUT_ERROR); } catch { bridge.Log(FormMessage.OPERATION_FAILS); } } }