Typica is a free program for professional coffee roasters. https://typica.us
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

greensales.xml 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <window id="greensales">
  2. <layout type="vertical">
  3. <layout type="horizontal">
  4. <label>Date:</label>
  5. <calendar id="date" />
  6. <label>Customer:</label>
  7. <line id="customer" />
  8. <label>Weight Unit:</label>
  9. <sqldrop data="0" display="0" showdata="false" editable="false" id="units" />
  10. </layout>
  11. <sqltablearray columns="2" id="coffees">
  12. <column name="Coffee" delegate="sql" showdata="true" null="false" data="0" display="1">
  13. <![CDATA[
  14. SELECT id, name FROM coffees WHERE quantity <> 0 ORDER BY name
  15. ]]>
  16. </column>
  17. <column name="Weight" delegate="numeric" />
  18. </sqltablearray>
  19. <button name="Submit" id="submit" type="push" />
  20. </layout>
  21. <program>
  22. <![CDATA[
  23. var window = this;
  24. this.windowTitle = 'Typica - Enter Green Coffee Sales';
  25. var unitBox = findChildObject(this, 'units');
  26. unitBox.addItem("g");
  27. unitBox.addItem("Kg");
  28. unitBox.addItem("oz");
  29. unitBox.addItem("lb");
  30. var convertToPounds = function(w, u) {
  31. switch(u)
  32. {
  33. case "g":
  34. return w * 0.0022;
  35. case "oz":
  36. return w * 0.0625;
  37. case "Kg":
  38. return w * 2.2;
  39. }
  40. return w;
  41. };
  42. var dateField = findChildObject(this, 'date');
  43. var customerField = findChildObject(this, 'customer');
  44. var items = findChildObject(this, 'coffees');
  45. var submit = findChildObject(this, 'submit');
  46. submit.clicked.connect(function() {
  47. var query = new QSqlQuery();
  48. query.prepare("INSERT INTO sale VALUES(:time, :item, :quantity, :customer)");
  49. query.bind(":time", dateField.text);
  50. if(customerField.text == "") {
  51. query.bind(":customer", null);
  52. }
  53. else {
  54. query.bind(":customer", customerField.text);
  55. }
  56. var coffeesArray = sqlToArray(items.columnArray(0, 32));
  57. if(coffeesArray.length > 0)
  58. {
  59. for(var i = 0; i < coffeesArray.length; i++)
  60. {
  61. if(items.data(i, 0, 32).value == '')
  62. {
  63. continue;
  64. }
  65. if(items.data(i, 1, 0).value == '')
  66. {
  67. continue;
  68. }
  69. query.bind(":item", items.data(i, 0, 32).value);
  70. query.bind(":quantity", convertToPounds(items.data(i, 1, 0).value, unitBox.currentText));
  71. query.exec();
  72. }
  73. }
  74. query = query.invalidate();
  75. window.close();
  76. });
  77. ]]>
  78. </program>
  79. </window>