private bool checkUserNamePassword() { bool retVal = false; string userName; string password; object result; string sqlCommand = ""; userName = gutil.allTrim(userNameTextBox.Text); userName = MySqlHelper.EscapeString(userName); password = gutil.allTrim(passwordTextBox.Text); password = MySqlHelper.EscapeString(password); sqlCommand = "SELECT ID FROM MASTER_USER WHERE USER_NAME = '" + userName + "' AND USER_PASSWORD = '******'"; result = DS.getDataSingleValue(sqlCommand); if (result != null) { selectedUserID = Convert.ToInt32(result); retVal = true; } return(retVal); }
private double getProductPriceValue(string productID, int customerType = 0, bool hppValue = false) { double result = 0; string priceType = ""; //DS.mySqlConnect(); if (customerType == 0) { priceType = "PRODUCT_RETAIL_PRICE"; } else if (customerType == 1) { priceType = "PRODUCT_BULK_PRICE"; } else { priceType = "PRODUCT_WHOLESALE_PRICE"; } if (hppValue) { priceType = "PRODUCT_BASE_PRICE"; } result = Convert.ToDouble(DS.getDataSingleValue("SELECT IFNULL(" + priceType + ", 0) FROM MASTER_PRODUCT WHERE PRODUCT_ID = '" + productID + "'")); return(result); }
private int getDebtID() { int result = 0; result = Convert.ToInt32(DS.getDataSingleValue("SELECT IFNULL(DEBT_ID, 0) FROM DEBT WHERE PURCHASE_INVOICE = '" + selectedPOInvoice + "'")); return(result); }
private double getHPPValue(string productID) { double result = 0; //DS.mySqlConnect(); result = Convert.ToDouble(DS.getDataSingleValue("SELECT IFNULL(PRODUCT_BASE_PRICE, 0) FROM MASTER_PRODUCT WHERE PRODUCT_ID = '" + productID + "'")); return(result); }
private bool noPMExist(string roInvoiceValue) { bool result = false; if (0 < Convert.ToInt32(DS.getDataSingleValue("SELECT COUNT(1) FROM PRODUCTS_MUTATION_HEADER WHERE PM_INVOICE = '" + roInvoiceValue + "'"))) { result = true; } return(result); }
private int getBranchID() { int result = 0; int numOfRows = 0; numOfRows = Convert.ToInt32(DS.getDataSingleValue("SELECT COUNT(1) FROM SYS_CONFIG WHERE ID = 2")); if (numOfRows > 0) { result = Convert.ToInt32(DS.getDataSingleValue("SELECT IFNULL(BRANCH_ID, 0) FROM SYS_CONFIG WHERE ID = 2")); } return(result); }
private void loadProductName() { string productName = ""; if ((newSelectedInternalProductID == selectedInternalProductID) || newSelectedInternalProductID == 0) { return; } DS.mySqlConnect(); productName = DS.getDataSingleValue("SELECT PRODUCT_NAME FROM MASTER_PRODUCT WHERE ID = " + newSelectedInternalProductID).ToString(); newProductIDTextBox.Text = productName; }
private string getProductName(string barcodeValue) { string productName = ""; if (barcodeValue.Length > 0) { try { productName = DS.getDataSingleValue("SELECT IFNULL(PRODUCT_NAME, '') FROM MASTER_PRODUCT WHERE PRODUCT_BARCODE = '" + barcodeValue + "'").ToString(); } catch (Exception e) {} } return(productName); }
private void loadUnitIDInformation() { string sqlCommand; string unitName = ""; DS.mySqlConnect(); if (selectedUnitID == 0) { return; } sqlCommand = "SELECT IFNULL(UNIT_NAME, '') FROM MASTER_UNIT WHERE UNIT_ID = " + selectedUnitID; unitName = DS.getDataSingleValue(sqlCommand).ToString(); unitTextBox.Text = unitName; }
private void salesOrderCommissionSelection_Load(object sender, EventArgs e) { PODtPicker_1.Value = startDateValue; PODtPicker_2.Value = endDateValue; deskripsiTextBox.Text = DS.getDataSingleValue("SELECT SALES_PERSON_NAME FROM MASTER_SALESPERSON WHERE ID = " + selectedUserID).ToString(); loadDataSales(); errorLabel.Text = ""; }
private bool isNoPRExist() { bool result = false; if (Convert.ToInt32(DS.getDataSingleValue("SELECT COUNT(1) FROM DELIVERY_ORDER_HEADER WHERE DO_ID = '" + MySqlHelper.EscapeString(doInvoiceTextBox.Text) + "'")) > 0) { result = true; } return(result); }
private double getTotalCashTransaction(string customerID) { string sqlCommand = ""; double result = 0; if (originModule == globalConstants.MEMBERSHIP_POINT) { sqlCommand = "SELECT IFNULL(SUM(SALES_TOTAL - SALES_DISCOUNT_FINAL), 0) FROM SALES_HEADER WHERE CUSTOMER_ID = " + customerID + " AND SALES_TOP = 1 AND DATE_FORMAT(SALES_DATE, '%Y%m%d') >= '" + startDate + "' AND DATE_FORMAT(SALES_DATE, '%Y%m%d') <= '" + endDate + "' AND SALES_VOID = 0"; } else if (originModule == globalConstants.SALES_COMMISSION) { sqlCommand = "SELECT IFNULL(SUM(SH.SALES_TOTAL - SH.SALES_DISCOUNT_FINAL), 0) " + "FROM SALES_HEADER SH, SALES_QUOTATION_HEADER SQH " + "WHERE SH.SQ_INVOICE = SQH.SQ_INVOICE AND SQH.SALESPERSON_ID = " + customerID + " AND SH.SALES_VOID = 0 AND SH.SALES_TOP = 1 AND DATE_FORMAT(SH.SALES_DATE, '%Y%m%d') >= '" + startDate + "' AND DATE_FORMAT(SH.SALES_DATE, '%Y%m%d') <= '" + endDate + "'"; } result = Convert.ToDouble(DS.getDataSingleValue(sqlCommand)); return(result); }
private bool noROExist(string roInvoiceValue) { bool result = false; if (0 < Convert.ToInt32(DS.getDataSingleValue("SELECT COUNT(1) FROM REQUEST_ORDER_HEADER WHERE RO_INVOICE = '" + roInvoiceValue + "'"))) { result = true; } return(result); }
public string getConfigPrinterName(int printerType = 1) { string printerName = ""; string sqlCommand = ""; if (Convert.ToInt32(DS.getDataSingleValue("SELECT COUNT(1) FROM SYS_CONFIG")) > 1) { if (printerType == 1) // POS RECEIPT PRINTER { sqlCommand = "SELECT IFNULL(POS_RECEIPT_PRINTER, '') FROM SYS_CONFIG WHERE ID = 2"; } else // KUARTO RECEIPT PRINTER { sqlCommand = "SELECT IFNULL(KUARTO_PRINTER, '') FROM SYS_CONFIG WHERE ID = 2"; } printerName = DS.getDataSingleValue(sqlCommand).ToString(); } return(printerName); }
private bool isNoAkunExist() { bool result = false; string noAkunParam = MySqlHelper.EscapeString(kodeTextbox.Text); if (Convert.ToInt32(DS.getDataSingleValue("SELECT COUNT(1) FROM MASTER_ACCOUNT WHERE ACCOUNT_ID = '" + noAkunParam + "'")) > 0) { result = true; } return(result); }
private void loadProductLocationData() { MySqlDataReader rdr; DataTable dt = new DataTable(); string sqlCommand; int numRecords = 0; numRecords = Convert.ToInt32(DS.getDataSingleValue("SELECT COUNT(1) FROM PRODUCT_LOCATION WHERE PRODUCT_ID = '" + selectedProductID + "'")); if (numRecords == 0) { createEntryForProductID(selectedProductID); } if (originModuleID == globalConstants.NEW_PRODUK || originModuleID == globalConstants.STOK_PECAH_BARANG) { sqlCommand = "SELECT ID, LOCATION_NAME , 0 AS 'JUMLAH' FROM MASTER_LOCATION"; } else { sqlCommand = "SELECT M.ID, LOCATION_NAME, PRODUCT_LOCATION_QTY AS 'JUMLAH' FROM MASTER_LOCATION M, PRODUCT_LOCATION P " + "WHERE P.LOCATION_ID = M.ID AND P.PRODUCT_ID = '" + selectedProductID + "'"; } using (rdr = DS.getData(sqlCommand)) { detailLokasiDataGridView.Rows.Clear(); if (rdr.HasRows) { //dt.Load(rdr); while (rdr.Read()) { detailQty.Add(rdr.GetString("JUMLAH")); detailLokasiDataGridView.Rows.Add(rdr.GetString("ID"), rdr.GetString("LOCATION_NAME"), rdr.GetString("JUMLAH")); } } rdr.Close(); } }
private void displayUserGroupName() { string groupName = ""; DS.mySqlConnect(); if (selectedGroupID > 0) { groupName = DS.getDataSingleValue("SELECT GROUP_USER_NAME FROM MASTER_GROUP WHERE GROUP_ID = " + selectedGroupID).ToString(); } groupNameTextBox.Text = groupName; }
private void loadData() { int dataCount = 0; MySqlDataReader rdr; dataCount = Convert.ToInt32(DS.getDataSingleValue("SELECT COUNT(1) FROM SYS_CONFIG_TAX")); if (dataCount > 0) { using (rdr = DS.getData("SELECT * FROM SYS_CONFIG_TAX")) { if (rdr.HasRows) { rdr.Read(); persentasePenjualan.Text = rdr.GetString("PERSENTASE_PENJUALAN"); persentasePembelian.Text = rdr.GetString("PERSENTASE_PEMBELIAN"); omsetPenjualan.Text = rdr.GetString("AVERAGE_PENJUALAN_HARIAN"); omsetPembelian.Text = rdr.GetString("AVERAGE_PEMBELIAN_HARIAN"); rasioToleransi.Text = rdr.GetString("RASIO_TOLERANSI"); } } } }
private int getCurrentMode() { int result = NEW_CONVERSION; string sqlCommand = ""; sqlCommand = "SELECT COUNT(1) FROM UNIT_CONVERT WHERE CONVERT_UNIT_ID_1 = " + selectedUnit1_ID + " AND CONVERT_UNIT_ID_2 = " + selectedUnit2_ID; if (Convert.ToInt32(DS.getDataSingleValue(sqlCommand)) > 0) { result = EDIT_CONVERSION; } return(result); }
private bool ipAddressExist() { bool result = false; int rowCount; string ipAddress = ip1Textbox.Text.Trim() + "." + ip2Textbox.Text.Trim() + "." + ip3Textbox.Text.Trim() + "." + ip4Textbox.Text.Trim(); rowCount = Convert.ToInt32(DS.getDataSingleValue("SELECT COUNT(1) FROM MASTER_BRANCH WHERE BRANCH_IP4 = '" + ipAddress + "'")); if (rowCount > 0) { result = true; } return(result); }
private bool validateOldPassword() { string oldPassword = oldPasswordTextBox.Text; oldPassword = MySqlHelper.EscapeString(oldPassword); int result; result = Convert.ToInt32(DS.getDataSingleValue("SELECT COUNT(1) FROM MASTER_USER WHERE ID = " + selectedUserID + " AND USER_PASSWORD = '******'")); if (result != 0) { return(true); } gutil.saveSystemDebugLog(0, "VALIDATE OLD PASSWORD FAILED [" + oldPassword + "]"); return(false); }
private void displaySpecificForm(int moduleID, string identifierNo) { int productID = 0; switch (moduleID) { case globalConstants.MENU_TRANSAKSI_PENJUALAN: pembayaranPiutangForm displayPiutangForm = new pembayaranPiutangForm(identifierNo); displayPiutangForm.ShowDialog(this); break; case globalConstants.MENU_PURCHASE_ORDER: pembayaranHutangForm displayHutangForm = new pembayaranHutangForm(identifierNo); displayHutangForm.ShowDialog(this); break; case globalConstants.MENU_PEMBAYARAN_PIUTANG: pembayaranPiutangForm displayPiutangFormConfirm = new pembayaranPiutangForm(identifierNo); displayPiutangFormConfirm.ShowDialog(this); break; case globalConstants.MENU_PEMBAYARAN_HUTANG_SUPPLIER: pembayaranHutangForm displayHutangFormConfirm = new pembayaranHutangForm(identifierNo); displayHutangFormConfirm.ShowDialog(this); break; case globalConstants.MENU_REQUEST_ORDER: dataMutasiBarangDetailForm displayedForm = new dataMutasiBarangDetailForm(globalConstants.CEK_DATA_MUTASI, identifierNo); displayedForm.ShowDialog(this); break; case globalConstants.MENU_PRODUK: productID = Convert.ToInt32(DS.getDataSingleValue("SELECT ID FROM MASTER_PRODUCT WHERE PRODUCT_ID = '" + identifierNo + "'")); dataProdukDetailForm displayProdukDetail = new dataProdukDetailForm(globalConstants.EDIT_PRODUK, productID); displayProdukDetail.ShowDialog(this); break; } }
public void setUserID(int selectedUserID) { userID = selectedUserID; userName = DS.getDataSingleValue("SELECT IFNULL(USER_NAME, '') FROM MASTER_USER WHERE ID = " + userID).ToString(); }
private bool saveDataTransaction() { bool result = false; string sqlCommand = ""; MySqlException internalEX = null; int numRow = 0; double unitConversion = getConvertValue(); numRow = Convert.ToInt32(DS.getDataSingleValue("SELECT COUNT(1) FROM UNIT_CONVERT WHERE CONVERT_UNIT_ID_1 = " + selectedUnit1_ID + " AND CONVERT_UNIT_ID_2 = " + selectedUnit2_ID)); if (numRow > 0) { currentMode = EDIT_CONVERSION; } else { currentMode = NEW_CONVERSION; } DS.beginTransaction(); try { DS.mySqlConnect(); switch (currentMode) { case NEW_CONVERSION: sqlCommand = "INSERT INTO UNIT_CONVERT (CONVERT_UNIT_ID_1, CONVERT_UNIT_ID_2, CONVERT_MULTIPLIER) VALUES (" + selectedUnit1_ID + ", " + selectedUnit2_ID + ", " + unitConversion + ")"; gUtil.saveSystemDebugLog(globalConstants.MENU_SATUAN, "ADD NEW UNIT CONVERT [" + selectedUnit1_ID + "/" + selectedUnit2_ID + "/" + unitConversion + "]"); break; case EDIT_CONVERSION: sqlCommand = "UPDATE UNIT_CONVERT SET CONVERT_MULTIPLIER = " + unitConversion + " WHERE CONVERT_UNIT_ID_1 = " + selectedUnit1_ID + " AND CONVERT_UNIT_ID_2 = " + selectedUnit2_ID; gUtil.saveSystemDebugLog(globalConstants.MENU_SATUAN, "UPDATE UNIT CONVERT [" + selectedUnit1_ID + "/" + selectedUnit2_ID + "/" + unitConversion + "]"); break; } if (!DS.executeNonQueryCommand(sqlCommand, ref internalEX)) { throw internalEX; } DS.commit(); result = true; } catch (Exception e) { gUtil.saveSystemDebugLog(globalConstants.MENU_SATUAN, "EXCEPTION THROWN [" + e.Message + "]"); try { DS.rollBack(); } catch (MySqlException ex) { if (DS.getMyTransConnection() != null) { gUtil.showDBOPError(ex, "ROLLBACK"); } } gUtil.showDBOPError(e, "INSERT"); result = false; } finally { DS.mySqlClose(); } return(result); }
private bool saveDataTransaction() { bool result = false; string sqlCommand = ""; string dateLogin; string dateLogOut; string dateTimeFrom; string dateTimeTo; double totalCashTransaction = 0; double totalNonCashTransaction = 0; double totalOtherTransaction = 0; MySqlException internalEX = null; double startAmount = 0; string startAmountInput = ""; double endAmount = 0; string endAmountInput = ""; DS.beginTransaction(); try { DS.mySqlConnect(); if (loginState == 0) { //startAmount = Convert.ToDouble(gUtil.allTrim(startAmountBox.Text)); startAmountInput = gUtil.allTrim(textBox1.Text); startAmountInput = startAmountInput.Replace(",", ""); startAmountInput = startAmountInput.Replace(".", ""); startAmount = Convert.ToDouble(startAmountInput); dateLogin = gUtil.getCustomStringFormatDate(DateTime.Now);//String.Format(culture, "{0:dd-M-yyyy HH:mm}", DateTime.Now); // INSERT TO CASHIER LOG sqlCommand = "INSERT INTO CASHIER_LOG (USER_ID, DATE_LOGIN, AMOUNT_START) VALUES (" + gUtil.getUserID() + ", STR_TO_DATE('" + dateLogin + "', '%d-%m-%Y %H:%i'), " + startAmount + ")"; if (!DS.executeNonQueryCommand(sqlCommand, ref internalEX)) { throw internalEX; } gUtil.saveSystemDebugLog(0, "INSERT DATA FOR A NEW CASHIER SESSION, SA=" + startAmount); } else if (loginState == 1) { endAmountInput = gUtil.allTrim(textBox2.Text); endAmountInput = endAmountInput.Replace(",", ""); endAmountInput = endAmountInput.Replace(".", ""); endAmount = Convert.ToDouble(endAmountInput); dateLogOut = gUtil.getCustomStringFormatDate(DateTime.Now); //String.Format(culture, "{0:dd-M-yyyy HH:mm}", DateTime.Now); dateTimeFrom = String.Format(culture, "{0:yyyyMMddHHmm}", dateTimeLogin); dateTimeTo = String.Format(culture, "{0:yyyyMMddHHmm}", DateTime.Now); //GET TOTAL CASH TRANSACTION sqlCommand = "SELECT IFNULL(SUM(SALES_TOTAL), 0) FROM SALES_HEADER " + "WHERE SALES_TOP = 1 AND SALES_PAYMENT_METHOD = 0 " + "AND DATE_FORMAT(SALES_DATE, '%Y%m%d%H%i') >= '" + dateTimeFrom + "' " + "AND DATE_FORMAT(SALES_DATE, '%Y%m%d%H%i') <= '" + dateTimeTo + "'"; totalCashTransaction = Convert.ToDouble(DS.getDataSingleValue(sqlCommand)); //GET TOTAL NON CASH TRANSACTION sqlCommand = "SELECT IFNULL(SUM(SALES_TOTAL), 0) FROM SALES_HEADER " + "WHERE SALES_TOP = 1 AND SALES_PAYMENT_METHOD > 0 " + "AND DATE_FORMAT(SALES_DATE, '%Y%m%d%H%i') >= '" + dateTimeFrom + "' " + "AND DATE_FORMAT(SALES_DATE, '%Y%m%d%H%i') <= '" + dateTimeTo + "'"; totalNonCashTransaction = Convert.ToDouble(DS.getDataSingleValue(sqlCommand)); //GET TOTAL OTHER TRANSACTION sqlCommand = "SELECT IFNULL(SUM(JOURNAL_NOMINAL), 0) FROM DAILY_JOURNAL DJ, MASTER_ACCOUNT MA " + "WHERE DJ.PM_ID = 1 AND DJ.ACCOUNT_ID = MA.ACCOUNT_ID AND MA.ACCOUNT_TYPE_ID = 2 " + "AND DATE_FORMAT(JOURNAL_DATETIME, '%Y%m%d%H%i') >= '" + dateTimeFrom + "' " + "AND DATE_FORMAT(JOURNAL_DATETIME, '%Y%m%d%H%i') <= '" + dateTimeTo + "'"; totalOtherTransaction = Convert.ToDouble(DS.getDataSingleValue(sqlCommand)); sqlCommand = "UPDATE CASHIER_LOG SET DATE_LOGOUT = STR_TO_DATE('" + dateLogOut + "', '%d-%m-%Y %H:%i'), AMOUNT_END = " + endAmount + ", COMMENT = '" + remarkTextBox.Text + "', TOTAL_CASH_TRANSACTION = " + totalCashTransaction + ", TOTAL_NON_CASH_TRANSACTION = " + totalNonCashTransaction + ", TOTAL_OTHER_TRANSACTION = " + totalOtherTransaction + " WHERE ID = " + logEntryID; if (!DS.executeNonQueryCommand(sqlCommand, ref internalEX)) { throw internalEX; } gUtil.saveSystemDebugLog(0, "UPDATE DATA FOR CASHIER END SESSION, EA=" + endAmount + ", TC = " + totalCashTransaction + ", TN=" + totalNonCashTransaction + ", TO=" + totalOtherTransaction); } DS.commit(); result = true; } catch (Exception e) { MessageBox.Show(e.Message); } return(result); }
private void loadNoFaktur() { noFakturValue = DS.getDataSingleValue("SELECT IFNULL(NO_FAKTUR, '') FROM SYS_CONFIG WHERE ID = 1").ToString(); noFakturTextBox.Text = noFakturValue; }
private bool saveDataTransaction() { bool result = false; string sqlCommand = ""; MySqlException internalEX = null; string selectedDate = dateJoinedDateTimePicked.Value.ToShortDateString(); string custJoinedDate = String.Format(culture, "{0:dd-MM-yyyy}", Convert.ToDateTime(selectedDate)); string custName = MySqlHelper.EscapeString(custNameTextBox.Text.Trim()); string custAddress1 = custAddress1TextBox.Text.Trim(); if (custAddress1.Equals("")) { custAddress1 = " "; } else { custAddress1 = MySqlHelper.EscapeString(custAddress1); } string custAddress2 = custAddress2TextBox.Text.Trim(); if (custAddress2.Equals("")) { custAddress2 = " "; } else { custAddress2 = MySqlHelper.EscapeString(custAddress2); } string custAddressCity = custAddressCityTextBox.Text.Trim(); if (custAddressCity.Equals("")) { custAddressCity = " "; } else { custAddressCity = MySqlHelper.EscapeString(custAddressCity); } string custPhone = custTelTextBox.Text.Trim(); if (custPhone.Equals("")) { custPhone = " "; } else { custPhone = MySqlHelper.EscapeString(custPhone); } string custFax = custFaxTextBox.Text.Trim(); if (custFax.Equals("")) { custFax = " "; } else { custFax = MySqlHelper.EscapeString(custFax); } string custEmail = custEmailTextBox.Text.Trim(); if (custEmail.Equals("")) { custEmail = " "; } else { custEmail = MySqlHelper.EscapeString(custEmail); } string custTotalSales = custTotalSalesTextBox.Text.Trim(); if (custTotalSales.Equals("")) { custTotalSales = "0"; } int custGroup = groupPelangganCombo.SelectedIndex + 1; byte custStatus = 0; if (nonAktifCheckbox.Checked) { custStatus = 0; } else { custStatus = 1; } DS.beginTransaction(); try { DS.mySqlConnect(); switch (originModuleID) { case globalConstants.NEW_CUSTOMER: custID = gUtil.getAutoGenerateID("MASTER_CUSTOMER", "", "", "CUSTOMER_ID"); sqlCommand = "INSERT INTO MASTER_CUSTOMER " + "(CUSTOMER_ID, CUSTOMER_FULL_NAME, CUSTOMER_ADDRESS1, CUSTOMER_ADDRESS2, CUSTOMER_ADDRESS_CITY, CUSTOMER_PHONE, CUSTOMER_FAX, CUSTOMER_EMAIL, CUSTOMER_ACTIVE, CUSTOMER_JOINED_DATE, CUSTOMER_TOTAL_SALES_COUNT, CUSTOMER_GROUP, SYNCHRONIZED, EDITED) " + "VALUES ('" + custID + "', '" + custName + "', '" + custAddress1 + "', '" + custAddress2 + "', '" + custAddressCity + "', '" + custPhone + "', '" + custFax + "', '" + custEmail + "', " + custStatus + ", STR_TO_DATE('" + custJoinedDate + "', '%d-%m-%Y'), " + custTotalSales + ", " + custGroup + ", 0, 1)"; gUtil.saveSystemDebugLog(globalConstants.MENU_PELANGGAN, "INSERT NEW CUSTOMER DATA [" + custName + "]"); break; case globalConstants.EDIT_CUSTOMER: int syncFlag, editedFlag; syncFlag = Convert.ToInt32(DS.getDataSingleValue("SELECT SYNCHRONIZED FROM MASTER_CUSTOMER WHERE CUSTOMER_ID = '" + selectedCustomerID + "'")); if (syncFlag == 0) // NEW DATA THAT HAS NOT BEEN SYNCHRONIZED { editedFlag = 1; } else { editedFlag = 2; } sqlCommand = "UPDATE MASTER_CUSTOMER SET " + "CUSTOMER_FULL_NAME = '" + custName + "', " + "CUSTOMER_ADDRESS1 = '" + custAddress1 + "', " + "CUSTOMER_ADDRESS2 = '" + custAddress2 + "', " + "CUSTOMER_ADDRESS_CITY = '" + custAddressCity + "', " + "CUSTOMER_PHONE = '" + custPhone + "', " + "CUSTOMER_FAX = '" + custFax + "', " + "CUSTOMER_EMAIL = '" + custEmail + "', " + "CUSTOMER_ACTIVE = " + custStatus + ", " + "CUSTOMER_JOINED_DATE = STR_TO_DATE('" + custJoinedDate + "', '%d-%m-%Y'), " + "CUSTOMER_TOTAL_SALES_COUNT = " + custTotalSales + ", " + "CUSTOMER_GROUP = " + custGroup + ", " + "EDITED = " + editedFlag + " " + "WHERE CUSTOMER_ID = " + selectedCustomerID; gUtil.saveSystemDebugLog(globalConstants.MENU_PELANGGAN, "EDIT CUSTOMER DATA [" + selectedCustomerID + "]"); break; } if (!DS.executeNonQueryCommand(sqlCommand, ref internalEX)) { throw internalEX; } DS.commit(); result = true; } catch (Exception e) { gUtil.saveSystemDebugLog(globalConstants.MENU_PELANGGAN, "EXCEPTION THROWN [" + e.Message + "]"); try { DS.rollBack(); } catch (MySqlException ex) { if (DS.getMyTransConnection() != null) { gUtil.showDBOPError(ex, "ROLLBACK"); } } gUtil.showDBOPError(e, "INSERT"); result = false; } finally { DS.mySqlClose(); } return(result); }
private bool saveData() { bool result = false; string sqlCommand = ""; MySqlException internalEX = null; int i = 0; int moduleIdValue = 0; int tempModuleID = 0; int userAccessValue = 0; DS.beginTransaction(); try { DS.mySqlConnect(); i = 0; while (i < groupAccessDataGridView.Rows.Count) { tempModuleID = Convert.ToInt32(groupAccessDataGridView.Rows[i].Cells["moduleID"].Value); if (moduleIdValue != tempModuleID) { if (moduleIdValue != 0) { if (Convert.ToInt32(DS.getDataSingleValue("SELECT COUNT(1) FROM USER_ACCESS_MANAGEMENT WHERE MODULE_ID = " + moduleIdValue + " AND GROUP_ID = " + selectedGroupID)) == 0) { // INSERT MODE sqlCommand = "INSERT INTO USER_ACCESS_MANAGEMENT (GROUP_ID, MODULE_ID, USER_ACCESS_OPTION) VALUES (" + selectedGroupID + ", " + moduleIdValue + ", " + userAccessValue + ")"; if (!DS.executeNonQueryCommand(sqlCommand, ref internalEX)) { throw internalEX; } } else { // EDIT MODE sqlCommand = "UPDATE USER_ACCESS_MANAGEMENT SET USER_ACCESS_OPTION = " + userAccessValue + " WHERE GROUP_ID = " + selectedGroupID + " AND MODULE_ID = " + moduleIdValue; if (!DS.executeNonQueryCommand(sqlCommand, ref internalEX)) { throw internalEX; } } } moduleIdValue = tempModuleID; userAccessValue = 0; } if (Convert.ToBoolean(groupAccessDataGridView.Rows[i].Cells["hakAkses"].Value)) { userAccessValue = userAccessValue + Convert.ToInt32(groupAccessDataGridView.Rows[i].Cells["featureID"].Value); } i++; } // INSERT / UPDATE if (Convert.ToInt32(DS.getDataSingleValue("SELECT COUNT(1) FROM USER_ACCESS_MANAGEMENT WHERE MODULE_ID = " + moduleIdValue + " AND GROUP_ID = " + selectedGroupID)) == 0) { // INSERT MODE sqlCommand = "INSERT INTO USER_ACCESS_MANAGEMENT (GROUP_ID, MODULE_ID, USER_ACCESS_OPTION) VALUES (" + selectedGroupID + ", " + moduleIdValue + ", " + userAccessValue + ")"; if (!DS.executeNonQueryCommand(sqlCommand, ref internalEX)) { throw internalEX; } } else { // EDIT MODE sqlCommand = "UPDATE USER_ACCESS_MANAGEMENT SET USER_ACCESS_OPTION = " + userAccessValue + " WHERE GROUP_ID = " + selectedGroupID + " AND MODULE_ID = " + moduleIdValue; if (!DS.executeNonQueryCommand(sqlCommand, ref internalEX)) { throw internalEX; } } //DS.executeNonQueryCommand(sqlCommand); DS.commit(); result = true; } catch (Exception e) { try { DS.rollBack(); } catch (MySqlException ex) { if (DS.getMyTransConnection() != null) { gutil.showDBOPError(ex, "ROLLBACK"); } } gutil.showDBOPError(e, "INSERT"); result = false; } finally { DS.mySqlClose(); } return(result); }
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { String ucapan = ""; MySqlDataReader rdr; //event printing Graphics graphics = e.Graphics; int startX = 0; int startY = 0; int colxwidth = 85; //old 75 int totrowwidth = 255; //old 250 Font font = new Font("Courier New", 9); int rowheight = (int)Math.Ceiling(font.GetHeight()); int add_offset = rowheight; int Offset = 5; int offset_plus = 3; int fontSize = 8; String underLine = "------------------------------"; //32 character string sqlCommand = ""; string whereClause = ""; //set allignemnt StringFormat sf = new StringFormat(); sf.LineAlignment = StringAlignment.Near; sf.Alignment = StringAlignment.Near; //set whole printing area System.Drawing.RectangleF rect = new System.Drawing.RectangleF(startX, startY + Offset, totrowwidth, rowheight); //set right print area System.Drawing.RectangleF rectright = new System.Drawing.RectangleF(totrowwidth - colxwidth - startX, startY + Offset, colxwidth, rowheight); //set middle print area System.Drawing.RectangleF rectcenter = new System.Drawing.RectangleF((startX + totrowwidth), startY + Offset, colxwidth, rowheight); ///string dateFrom = String.Format(culture, "{0:yyyyMMdd}", DateTime.Now); ucapan = gUtil.getCustomStringFormatDate(DateTime.Now); graphics.DrawString(ucapan, new Font("Courier New", 9), new SolidBrush(Color.Black), rect, sf); Offset = Offset + add_offset; rect.Y = startY + Offset; graphics.DrawString(underLine, new Font("Courier New", 9), new SolidBrush(Color.Black), rect, sf); Offset = Offset + add_offset; rect.Y = startY + Offset; ucapan = "LAPORAN STOK"; graphics.DrawString(ucapan, new Font("Courier New", 9), new SolidBrush(Color.Black), rect, sf); Offset = Offset + add_offset; rect.Y = startY + Offset; graphics.DrawString(underLine, new Font("Courier New", 9), new SolidBrush(Color.Black), rect, sf); Offset = Offset + add_offset; rect.Y = startY + Offset; ucapan = "PENJUALAN DAN SELISIH"; graphics.DrawString(ucapan, new Font("Courier New", fontSize), new SolidBrush(Color.Black), rect, sf); //DETAIL PENJUALAN sf.LineAlignment = StringAlignment.Near; sf.Alignment = StringAlignment.Near; float startRightX = totrowwidth - colxwidth - startX; string soldQty, selisihQty; DS.mySqlConnect(); sqlCommand = "SELECT MP.PRODUCT_NAME, IFNULL(SUM(PD.PRODUCT_SOLD_QTY), 0) AS PRODUCT_SOLD_QTY, IFNULL(SUM(PRODUCT_LEFTOVER_QTY - PRODUCT_RIIL_QTY), 0) AS SELISIH " + "FROM MASTER_PRODUCT MP, PRODUCT_DAILY_ADJUSTMENT_HEADER PH, PRODUCT_DAILY_ADJUSTMENT_DETAIL PD " + "WHERE PD.PRODUCT_ID = MP.PRODUCT_ID AND PD.PRODUCT_ADJUSTMENT_ID = PH.PRODUCT_ADJUSTMENT_ID"; if (!firstTimeClose) whereClause = " AND DATE_FORMAT(PH.PRODUCT_ADJUSTMENT_DATE, '%Y%m%d') > '" + localSuccessDate + "'"; sqlCommand = sqlCommand + " " + whereClause + " GROUP BY MP.PRODUCT_ID"; using (rdr = DS.getData(sqlCommand)) { if (rdr.HasRows) { int i = 0; while (rdr.Read()) { Offset = Offset + add_offset; rect.Y = startY + Offset; ucapan = rdr.GetString("PRODUCT_NAME"); if (ucapan.Length > 25) { ucapan = ucapan.Substring(0, 25); //maximum 25 character } else ucapan = ucapan.PadRight(25, ' '); soldQty = rdr.GetString("PRODUCT_SOLD_QTY"); selisihQty = rdr.GetString("SELISIH"); soldQty = soldQty.PadLeft(3, ' '); selisihQty = selisihQty.PadLeft(3, ' '); ucapan = ucapan + "|" + soldQty + "|" + selisihQty + "|"; // graphics.DrawString(ucapan, new Font("Courier New", fontSize), new SolidBrush(Color.Black), rect, sf); } } } DS.mySqlClose(); Offset = Offset + add_offset; Offset = Offset + add_offset; rect.Y = startY + Offset; graphics.DrawString(underLine, new Font("Courier New", 9), new SolidBrush(Color.Black), rect, sf); Offset = Offset + add_offset; rect.Y = startY + Offset; ucapan = "LAPORAN KAS"; graphics.DrawString(ucapan, new Font("Courier New", 9), new SolidBrush(Color.Black), rect, sf); Offset = Offset + add_offset; rect.Y = startY + Offset; graphics.DrawString(underLine, new Font("Courier New", 9), new SolidBrush(Color.Black), rect, sf); // ========================================================================= Offset = Offset + add_offset; rect.Y = startY + Offset; ucapan = "Penjualan Tunai"; graphics.DrawString(ucapan, new Font("Courier New", 9), new SolidBrush(Color.Black), rect, sf); //sqlCommand = "SELECT IFNULL(SUM(SALES_TOTAL - SALES_DISCOUNT_FINAL), 0) AS TOTAL_SALES " + // "FROM SALES_HEADER " + // "WHERE SALES_TOP = 1 AND SALES_PAID = 1"; sqlCommand = "SELECT IFNULL(SUM(PAYMENT_NOMINAL), 0) AS TOTAL_CREDIT " + "FROM PAYMENT_CREDIT " + "WHERE PAYMENT_CONFIRMED = 1 AND PM_ID = 1 AND PAYMENT_IS_DP = 0"; if (!firstTimeClose) //whereClause = " AND DATE_FORMAT(SALES_DATE, '%Y%m%d') > '" + localSuccessDate + "'"; whereClause = " AND DATE_FORMAT(PAYMENT_DATE, '%Y%m%d') > '" + localSuccessDate + "'"; sqlCommand = sqlCommand + " " + whereClause; double totalCashSales; totalCashSales = Convert.ToDouble(DS.getDataSingleValue(sqlCommand)); Offset = Offset + add_offset; rect.Y = startY + Offset; ucapan = totalCashSales.ToString("C", culture); graphics.DrawString(ucapan, new Font("Courier New", 9), new SolidBrush(Color.Black), rect, sf); // ========================================================================= Offset = Offset + add_offset; rect.Y = startY + Offset; ucapan = "Pendapatan Tunai non Penjualan"; graphics.DrawString(ucapan, new Font("Courier New", 9), new SolidBrush(Color.Black), rect, sf); sqlCommand = "SELECT IFNULL(SUM(DJ.JOURNAL_NOMINAL), 0) AS TOTAL_NON_SALES " + "FROM DAILY_JOURNAL DJ, MASTER_ACCOUNT MA " + "WHERE DJ.ACCOUNT_ID > 3 AND MA.ACCOUNT_TYPE_ID = 1 AND DJ.ACCOUNT_ID = MA.ACCOUNT_ID"; if (!firstTimeClose) whereClause = " AND DATE_FORMAT(DJ.JOURNAL_DATETIME, '%Y%m%d') > '" + localSuccessDate + "'"; sqlCommand = sqlCommand + " " + whereClause; double totalCashNonSales; totalCashNonSales = Convert.ToDouble(DS.getDataSingleValue(sqlCommand)); Offset = Offset + add_offset; rect.Y = startY + Offset; ucapan = totalCashNonSales.ToString("C", culture); graphics.DrawString(ucapan, new Font("Courier New", 9), new SolidBrush(Color.Black), rect, sf); // ========================================================================= Offset = Offset + add_offset; rect.Y = startY + Offset; ucapan = "Pendapatan DP"; graphics.DrawString(ucapan, new Font("Courier New", 9), new SolidBrush(Color.Black), rect, sf); sqlCommand = "SELECT IFNULL(SUM(PAYMENT_NOMINAL), 0) AS TOTAL_DP " + "FROM PAYMENT_CREDIT " + "WHERE PAYMENT_CONFIRMED = 1 AND PM_ID = 1 AND PAYMENT_IS_DP = 1"; //sqlCommand = "SELECT IFNULL(SUM(DJ.JOURNAL_NOMINAL), 0) AS NOMINAL " + // "FROM DAILY_JOURNAL DJ " + // "WHERE JOURNAL_DESCRIPTION LIKE '%PEMBAYARAN DP [%'"; if (!firstTimeClose) whereClause = " AND DATE_FORMAT(PAYMENT_DATE, '%Y%m%d') > '" + localSuccessDate + "'"; sqlCommand = sqlCommand + " " + whereClause; double totalDP; totalDP = Convert.ToDouble(DS.getDataSingleValue(sqlCommand)); Offset = Offset + add_offset; rect.Y = startY + Offset; ucapan = totalDP.ToString("C", culture); graphics.DrawString(ucapan, new Font("Courier New", 9), new SolidBrush(Color.Black), rect, sf); // ========================================================================= Offset = Offset + add_offset; rect.Y = startY + Offset; ucapan = "Pendapatan Pesanan"; graphics.DrawString(ucapan, new Font("Courier New", 9), new SolidBrush(Color.Black), rect, sf); //sqlCommand = "SELECT IFNULL(SUM(PAYMENT_NOMINAL), 0) AS TOTAL_CREDIT " + // "FROM PAYMENT_CREDIT " + // "WHERE PAYMENT_CONFIRMED = 1 AND PM_ID = 1 AND PAYMENT_IS_DP = 0"; sqlCommand = "SELECT IFNULL(SUM(SALES_TOTAL - SALES_DISCOUNT_FINAL), 0) AS TOTAL_SALES " + "FROM SALES_HEADER " + "WHERE SALES_TOP = 0"; if (!firstTimeClose) whereClause = " AND DATE_FORMAT(SALES_DATE, '%Y%m%d') > '" + localSuccessDate + "'"; sqlCommand = sqlCommand + " " + whereClause; double totalCreditPayment = 0; totalCreditPayment = Convert.ToDouble(DS.getDataSingleValue(sqlCommand)); Offset = Offset + add_offset; rect.Y = startY + Offset; ucapan = totalCreditPayment.ToString("C", culture); graphics.DrawString(ucapan, new Font("Courier New", 9), new SolidBrush(Color.Black), rect, sf); // ========================================================================= Offset = Offset + add_offset; rect.Y = startY + Offset; graphics.DrawString(underLine, new Font("Courier New", 9), new SolidBrush(Color.Black), rect, sf); double totalIncome; totalIncome = totalCashSales + totalCashNonSales + totalDP + totalCreditPayment; Offset = Offset + add_offset; rect.Y = startY + Offset; ucapan = "TOTAL : " + totalIncome.ToString("C", culture); ; graphics.DrawString(ucapan, new Font("Courier New", 9), new SolidBrush(Color.Black), rect, sf); Offset = Offset + add_offset; rect.Y = startY + Offset; graphics.DrawString(underLine, new Font("Courier New", 9), new SolidBrush(Color.Black), rect, sf); // ========================================================================= Offset = Offset + add_offset; Offset = Offset + add_offset; rect.Y = startY + Offset; ucapan = "Pengeluaran"; graphics.DrawString(ucapan, new Font("Courier New", 9), new SolidBrush(Color.Black), rect, sf); sqlCommand = "SELECT IFNULL(SUM(DJ.JOURNAL_NOMINAL), 0) AS NOMINAL " + "FROM DAILY_JOURNAL DJ, MASTER_ACCOUNT MA " + "WHERE DJ.ACCOUNT_ID > 3 AND MA.ACCOUNT_TYPE_ID = 2 AND DJ.ACCOUNT_ID = MA.ACCOUNT_ID"; if (!firstTimeClose) whereClause = " AND DATE_FORMAT(DJ.JOURNAL_DATETIME, '%Y%m%d') > '" + localSuccessDate + "'"; sqlCommand = sqlCommand + " " + whereClause; double expenseAmt = 0; expenseAmt = Convert.ToDouble(DS.getDataSingleValue(sqlCommand)); Offset = Offset + add_offset; rect.Y = startY + Offset; ucapan = expenseAmt.ToString("C", culture); graphics.DrawString(ucapan, new Font("Courier New", 9), new SolidBrush(Color.Black), rect, sf); // ========================================================================= Offset = Offset + add_offset; rect.Y = startY + Offset; ucapan = "Pembayaran Supplier"; graphics.DrawString(ucapan, new Font("Courier New", 9), new SolidBrush(Color.Black), rect, sf); sqlCommand = "SELECT IFNULL(SUM(PAYMENT_NOMINAL), 0) AS TOTAL_PAYMENT_DEBT " + "FROM PAYMENT_DEBT " + "WHERE PAYMENT_CONFIRMED = 1 AND PM_ID = 1"; if (!firstTimeClose) whereClause = " AND DATE_FORMAT(PAYMENT_CONFIRMED_DATE, '%Y%m%d') > '" + localSuccessDate + "'"; sqlCommand = sqlCommand + " " + whereClause; double totalDebtPayment; totalDebtPayment = Convert.ToDouble(DS.getDataSingleValue(sqlCommand)); Offset = Offset + add_offset; rect.Y = startY + Offset; ucapan = totalDebtPayment.ToString("C", culture); graphics.DrawString(ucapan, new Font("Courier New", 9), new SolidBrush(Color.Black), rect, sf); // ========================================================================= //DS.mySqlConnect(); //sqlCommand = "SELECT DJ.JOURNAL_DESCRIPTION, IFNULL(DJ.JOURNAL_NOMINAL, 0) AS NOMINAL " + // "FROM DAILY_JOURNAL DJ, MASTER_ACCOUNT MA " + // "WHERE DATE_FORMAT(DJ.JOURNAL_DATETIME, '%Y%m%d') = '" + dateFrom + "' AND DJ.ACCOUNT_ID > 3 AND MA.ACCOUNT_TYPE_ID = 2 AND DJ.ACCOUNT_ID = MA.ACCOUNT_ID"; //using (rdr = DS.getData(sqlCommand)) //{ // if (rdr.HasRows) // { // int i = 0; // while (rdr.Read()) // { // Offset = Offset + add_offset; // rect.Y = startY + Offset; // ucapan = rdr.GetString("JOURNAL_DESCRIPTION"); // if (ucapan.Length > 20) // { // ucapan = ucapan.Substring(0, 20); //maximum 20 character // } // else // ucapan = ucapan.PadRight(20, ' '); // expenseAmt = rdr.GetDouble("JOURNAL_NOMINAL"); // totalExpense = totalExpense + expenseAmt; // ucapan = ucapan + "|" + expenseAmt.ToString("C", culture); // // // graphics.DrawString(ucapan, new Font("Courier New", fontSize), // new SolidBrush(Color.Black), rect, sf); // } // } //} //DS.mySqlClose(); Offset = Offset + add_offset; rect.Y = startY + Offset; graphics.DrawString(underLine, new Font("Courier New", 9), new SolidBrush(Color.Black), rect, sf); double totalExpense = 0; totalExpense = expenseAmt + totalDebtPayment; Offset = Offset + add_offset; rect.Y = startY + Offset; ucapan = "TOTAL : " + totalExpense.ToString("C", culture); graphics.DrawString(ucapan, new Font("Courier New", 9), new SolidBrush(Color.Black), rect, sf); Offset = Offset + add_offset; rect.Y = startY + Offset; graphics.DrawString(underLine, new Font("Courier New", 9), new SolidBrush(Color.Black), rect, sf); double totalFinalCash = 0; totalFinalCash = totalIncome + totalExpense; Offset = Offset + add_offset; Offset = Offset + add_offset; Offset = Offset + add_offset; rect.Y = startY + Offset; graphics.DrawString(underLine, new Font("Courier New", 9), new SolidBrush(Color.Black), rect, sf); Offset = Offset + add_offset; rect.Y = startY + Offset; ucapan = "KAS GRANDTOTAL : " + totalFinalCash.ToString("C", culture); graphics.DrawString(ucapan, new Font("Courier New", 9), new SolidBrush(Color.Black), rect, sf); Offset = Offset + add_offset; rect.Y = startY + Offset; graphics.DrawString(underLine, new Font("Courier New", 9), new SolidBrush(Color.Black), rect, sf); }
private bool saveDataTransaction() { bool result = false; string sqlCommand = ""; MySqlException internalEX = null; string groupName = MySqlHelper.EscapeString(namaGroupTextBox.Text.Trim()); string groupDesc = MySqlHelper.EscapeString(deskripsiTextBox.Text.Trim()); byte groupStatus = 0; byte groupCashier = 0; if (nonAktifCheckbox.Checked) { groupStatus = 0; } else { groupStatus = 1; } if (cashierCheckBox.Checked) { groupCashier = 1; } else { groupCashier = 0; } DS.beginTransaction(); try { DS.mySqlConnect(); switch (originModuleID) { case globalConstants.NEW_GROUP_USER: case globalConstants.PENGATURAN_GRUP_AKSES: sqlCommand = "INSERT INTO MASTER_GROUP (GROUP_USER_NAME, GROUP_USER_DESCRIPTION, GROUP_USER_ACTIVE, GROUP_IS_CASHIER) VALUES ('" + groupName + "', '" + groupDesc + "', " + groupStatus + ", " + groupCashier + ")"; break; case globalConstants.EDIT_GROUP_USER: sqlCommand = "UPDATE MASTER_GROUP SET GROUP_USER_NAME = '" + groupName + "', GROUP_USER_DESCRIPTION = '" + groupDesc + "', GROUP_USER_ACTIVE = " + groupStatus + ", GROUP_IS_CASHIER = " + groupCashier + " WHERE GROUP_ID = " + selectedGroupID; break; } if (!DS.executeNonQueryCommand(sqlCommand, ref internalEX)) { throw internalEX; } DS.commit(); result = true; } catch (Exception e) { try { DS.rollBack(); } catch (MySqlException ex) { if (DS.getMyTransConnection() != null) { gutil.showDBOPError(ex, "ROLLBACK"); } } gutil.showDBOPError(e, "INSERT"); result = false; } finally { if (originModuleID == globalConstants.PENGATURAN_GRUP_AKSES && result == true) { selectedGroupID = Convert.ToInt32(DS.getDataSingleValue("SELECT MAX(GROUP_ID) FROM MASTER_GROUP WHERE GROUP_USER_NAME = '" + groupName + "' AND GROUP_USER_DESCRIPTION = '" + groupDesc + "' ")); parentForm.setSelectedGroupID(selectedGroupID); } DS.mySqlClose(); } return(result); }