private bool syncLocalDataToServer(Data_Access localDS, string fileName) { System.IO.StreamReader file = new System.IO.StreamReader(fileName); string sqlCommand = ""; MySqlException internalEX = null; bool result = false; localDS.beginTransaction(Data_Access.HQ_SERVER); try { while ((sqlCommand = file.ReadLine()) != null) { if (sqlCommand.Length > 0) if (!localDS.executeNonQueryCommand(sqlCommand, ref internalEX)) throw internalEX; } file.Close(); localDS.commit(); result = true; } catch (Exception ex) { gUtil.saveSystemDebugLog(0, "[TUTUP TOKO] FAILED TO SYNC LOCAL DATA TO SERVER [" + ex.Message + "]"); } return result; }
private void startExportData(string fileName, Data_Access DAccess) { StreamWriter sw = null; string sqlCommand = ""; string strCmdText = "USE 'sys_pos_larasbakery_server';"; string dateFrom = String.Format(culture, "{0:yyyyMMdd}", DateTime.Now); if (!File.Exists(fileName)) sw = File.CreateText(fileName); else { File.Delete(fileName); sw = File.CreateText(fileName); } //sw.WriteLine(strCmdText); // EXPORT SALES HEADER sqlCommand = "SELECT * FROM SALES_HEADER WHERE SALES_PAID = 1"; writeTableContentToInsertStatement("SALES_HEADER", sw, DAccess, false, false, false, sqlCommand); // EXPORT SALES DETAIL sqlCommand = "SELECT SD.* FROM SALES_DETAIL SD, SALES_HEADER SH WHERE SH.SALES_PAID = 1 AND SD.SALES_INVOICE = SH.SALES_INVOICE"; writeTableContentToInsertStatement("SALES_DETAIL", sw, DAccess, false, false, false, sqlCommand); // EXPORT CREDIT sqlCommand = "SELECT C.* FROM CREDIT C, SALES_HEADER SH WHERE SH.SALES_PAID = 1 AND C.SALES_INVOICE = SH.SALES_INVOICE AND C.CREDIT_PAID = 1"; writeTableContentToInsertStatement("CREDIT", sw, DAccess, false, false, false, sqlCommand); // EXPORT PAYMENT_CREDIT sqlCommand = "SELECT PC.* FROM PAYMENT_CREDIT PC, CREDIT C, SALES_HEADER SH WHERE SH.SALES_PAID = 1 AND C.SALES_INVOICE = SH.SALES_INVOICE AND PC.CREDIT_ID = C.CREDIT_ID AND C.CREDIT_PAID = 1"; writeTableContentToInsertStatement("PAYMENT_CREDIT", sw, DAccess, false, false, false, sqlCommand); // EXPORT DAILY JOURNAL sqlCommand = "SELECT * FROM DAILY_JOURNAL";// WHERE DATE_FORMAT(JOURNAL_DATETIME, '%Y%m%d') = '" + dateFrom + "'"; writeTableContentToInsertStatement("DAILY_JOURNAL", sw, DAccess, false, false, false, sqlCommand); // EXPORT DEBT sqlCommand = "SELECT D.* FROM DEBT D, PURCHASE_HEADER PH WHERE PH.PURCHASE_PAID = 1 AND D.PURCHASE_INVOICE = PH.PURCHASE_INVOICE AND D.DEBT_PAID = 1"; writeTableContentToInsertStatement("DEBT", sw, DAccess, false, false, false, sqlCommand); // EXPORT PAYMENT DEBT sqlCommand = "SELECT PD.* FROM PAYMENT_DEBT PD, DEBT D, PURCHASE_HEADER PH WHERE PH.PURCHASE_PAID = 1 AND D.PURCHASE_INVOICE = PH.PURCHASE_INVOICE AND PD.DEBT_ID = D.DEBT_ID AND D.DEBT_PAID = 1"; writeTableContentToInsertStatement("PAYMENT_DEBT", sw, DAccess, false, false, false, sqlCommand); sw.Close(); }
private bool sendDataToCabangMultipleFiles(int branchID, string ipServerBranch = "") { Data_Access DS_BRANCH = new Data_Access(); bool result = false; // CONNECT TO BRANCH if (DS_BRANCH.Branch_mySQLConnect(branchID, ipServerBranch)) { result = syncLocalDataToServerMultipleFiles(DS_BRANCH, Data_Access.BRANCH_SERVER); // CLOSE BRANCH CONNECTION DS_BRANCH.Branch_mySqlClose(); } return(result); }
private bool syncLocalDataToServerMultipleFiles(Data_Access localDS, int serverToConnect = 1) { // SEND DATA TO SERVER System.IO.StreamReader file;// = new System.IO.StreamReader(fileName); string sqlCommand = ""; MySqlException internalEX = null; bool result = false; localDS.beginTransaction(serverToConnect); try { for (int i = 0; i < fileToExecute.Count; i++) { file = new System.IO.StreamReader(fileToExecute[i]); while ((sqlCommand = file.ReadLine()) != null) { if (sqlCommand.Length > 0) { if (!localDS.executeNonQueryCommand(sqlCommand, ref internalEX)) { throw internalEX; } } } file.Close(); } localDS.commit(); result = true; } catch (Exception ex) { gUtil.saveSystemDebugLog(0, "[SYNC] FAILED TO SYNC LOCAL DATA TO SERVER [" + ex.Message + "]"); } return(result); }
private bool clearDataCabang(string tableName, int branchID, string ipServerBranch = "") { Data_Access DS_BRANCH = new Data_Access(); bool result = false; string sqlCommand = ""; MySqlException internalEX = null; // CONNECT TO BRANCH if (DS_BRANCH.Branch_mySQLConnect(branchID, ipServerBranch)) { DS_BRANCH.beginTransaction(Data_Access.BRANCH_SERVER); try { sqlCommand = "DELETE FROM " + tableName; if (!DS_BRANCH.executeNonQueryCommand(sqlCommand)) { throw internalEX; } DS_BRANCH.commit(); result = true; } catch (Exception ex) { gUtil.saveSystemDebugLog(0, "[SYNC CABANG] FAILED TO CLEAR DATA CABANG [" + ex.Message + "]"); } // CLOSE BRANCH CONNECTION DS_BRANCH.Branch_mySqlClose(); } else { gUtil.saveSystemDebugLog(0, "[SYNC CABANG] FAILED TO CONNECT TO CABANG"); } return(result); }
public bool syncDataForCloseShop() { bool result = false; Data_Access DS_SS = new Data_Access(); string localDate = ""; string fileName = ""; localDate = String.Format(culture, "{0:ddMMyyyy}", DateTime.Now); fileName = "EXPORT_LOCAL_DATA" + "_" + localDate + ".sql"; // EXPORT LOCAL DATA exportDataCloseShop(fileName); if (DS_SS.SS_mySQLConnect(true)) { gUtil.saveSystemDebugLog(0, "[SYNC] CONNECTION TO SERVER CREATED"); result = syncLocalDataToServer(DS_SS, fileName, Data_Access.SS_SERVER); try { File.Delete(fileName); } catch (Exception ex) { gUtil.saveSystemDebugLog(0, "[SYNC] FAILED TO DELETE EXPORT FILE [" + ex.Message + "]"); } } else { MessageBox.Show("KONEKSI KE PUSAT GAGAL"); gUtil.saveSystemDebugLog(0, "[SYNC] FAILED TO CONNECT TO SERVER"); result = false; } return(result); }
private bool syncToCentralHQ() { bool result = false; Data_Access DS_HQ = new Data_Access(); // CREATE CONNECTION TO CENTRAL HQ DATABASE SERVER gutil.saveSystemDebugLog(globalConstants.MENU_SINKRONISASI_INFORMASI, "TRY TO CREATE CONNECTION TO CENTRAL HQ"); if (DS_HQ.HQ_mySQLConnect(true)) { gutil.saveSystemDebugLog(globalConstants.MENU_SINKRONISASI_INFORMASI, "CONNECTION TO CENTRAL HQ CREATED"); // DUMP NECESSARY DATA TO LOCAL COPY exportData(syncFileName, DS_HQ, true); gutil.saveSystemDebugLog(globalConstants.MENU_SINKRONISASI_INFORMASI, "CENTRAL HQ DATA EXPORTED"); // CLOSE CONNECTION TO CENTRAL HQ DATABASE SERVER DS_HQ.mySqlClose(); gutil.saveSystemDebugLog(globalConstants.MENU_SINKRONISASI_INFORMASI, "CLOSE CONNECTION TO CENTRAL HQ"); // INSERT TO LOCAL DATA gutil.saveSystemDebugLog(globalConstants.MENU_SINKRONISASI_INFORMASI, "SYNC LOCAL INFORMATION WITH DATA FROM CENTRAL HQ [" + syncFileName + "]"); syncInformation(syncFileName); gutil.saveSystemDebugLog(globalConstants.MENU_SINKRONISASI_INFORMASI, "SYNC LOCAL INFORMATION FINISHED"); result = true; } else { MessageBox.Show("KONEKSI KE PUSAT GAGAL"); gutil.saveSystemDebugLog(globalConstants.MENU_SINKRONISASI_INFORMASI, "FAILED TO CONNECT TO CENTRAL HQ"); result = false; } return(result); }
private void writeTableContentToInsertStatement(string tableName, StreamWriter sw, Data_Access DAccess, bool isHQConnection = false, bool skipFirstField = false, bool skipAddBranchID = false, string sqlParam = "", string customTableName = "") { string sqlCommand = ""; MySqlDataReader rdr; string insertStatement = ""; string valueStatement = ""; int rdrFieldIndex = 0; int startIndex = 0; DateTime tempDateTime; string dateTimeValue; object DBValue = null; int branchID = 0; string namaCabang = ""; branchID = gUtil.loadbranchID(2, out namaCabang); if (sqlParam.Length <= 0) sqlCommand = "SELECT * FROM " + tableName; else sqlCommand = sqlParam; if (skipFirstField) startIndex = 1; sw.WriteLine(""); using (rdr = DAccess.getData(sqlCommand, isHQConnection)) { if (rdr.HasRows) { while (rdr.Read()) { if (customTableName.Length > 0) insertStatement = "INSERT INTO " + customTableName + "("; else insertStatement = "INSERT INTO " + tableName + "("; valueStatement = ""; for (rdrFieldIndex = startIndex; rdrFieldIndex < rdr.FieldCount; rdrFieldIndex++) { DBValue = rdr.GetValue(rdrFieldIndex); if (DBValue.ToString().Length > 0) { insertStatement = insertStatement + rdr.GetName(rdrFieldIndex) + ", "; if (rdr.GetDataTypeName(rdrFieldIndex) == "DATE") { tempDateTime = rdr.GetDateTime(rdrFieldIndex); dateTimeValue = String.Format(culture, "{0:dd-MM-yyyy}", tempDateTime); valueStatement = valueStatement + "STR_TO_DATE('" + dateTimeValue + "', '%d-%m-%Y'), "; } else if (rdr.GetDataTypeName(rdrFieldIndex) == "DATETIME") { tempDateTime = rdr.GetDateTime(rdrFieldIndex); dateTimeValue = gUtil.getCustomStringFormatDate(tempDateTime); valueStatement = valueStatement + "STR_TO_DATE('" + dateTimeValue + "', '%d-%m-%Y %H:%i'), "; } else valueStatement = valueStatement + "'" + Convert.ToString(rdr.GetValue(rdrFieldIndex)) + "', "; } } if (!skipAddBranchID) { insertStatement = insertStatement + "BRANCH_ID) VALUES("; valueStatement = valueStatement + branchID + ");"; } else { insertStatement = insertStatement.Substring(0, insertStatement.Length - 2); insertStatement = insertStatement + ") VALUES("; valueStatement = valueStatement.Substring(0, valueStatement.Length - 2); valueStatement = valueStatement + ");"; } insertStatement = insertStatement + valueStatement; sw.WriteLine(insertStatement); } } rdr.Close(); } sw.WriteLine(""); }
private string createUpdateQueryDataCabang(int branchID, string tableName, string PKField, List <string> fieldToBackup, string ipServerBranch = "") { Data_Access DS_BRANCH = new Data_Access(); //bool result = false; string sqlCommand = ""; MySqlDataReader rdr; string fieldName; object DBValue = null; int rdrFieldIndex = 0; int startIndex = 0; StreamWriter sw = null; string fileName = ""; string commandStatement = ""; string valueStatement = ""; string fieldValueForPK = ""; fileName = "EXPORT_" + branchID + "_DATA_" + tableName + ".sql"; if (!File.Exists(fileName)) { sw = File.CreateText(fileName); } else { File.Delete(fileName); sw = File.CreateText(fileName); } // CONNECT TO BRANCH if (DS_BRANCH.Branch_mySQLConnect(branchID, ipServerBranch)) { sqlCommand = "SELECT * FROM " + tableName; using (rdr = DS_BRANCH.getData(sqlCommand, false, true)) { if (rdr.HasRows) { while (rdr.Read()) { commandStatement = "UPDATE " + tableName + " SET "; valueStatement = ""; for (rdrFieldIndex = startIndex; rdrFieldIndex < rdr.FieldCount; rdrFieldIndex++) { DBValue = rdr.GetValue(rdrFieldIndex); if (DBValue.ToString().Length > 0) { fieldName = rdr.GetName(rdrFieldIndex); if (!fieldToSkip.Contains(fieldName) && fieldName != PKField) { continue; } if (fieldName != PKField) { valueStatement = valueStatement + fieldName + " = " + "'" + Convert.ToString(rdr.GetValue(rdrFieldIndex)) + "', "; } else { fieldValueForPK = Convert.ToString(rdr.GetValue(rdrFieldIndex)); } } } valueStatement = valueStatement.Substring(0, valueStatement.Length - 2); commandStatement = commandStatement + valueStatement; commandStatement = commandStatement + " WHERE " + PKField + " = '" + fieldValueForPK + "';"; sw.WriteLine(commandStatement); } } } rdr.Close(); // CLOSE BRANCH CONNECTION DS_BRANCH.Branch_mySqlClose(); //result = true; } else { gUtil.saveSystemDebugLog(0, "[SYNC CABANG] FAILED TO CONNECT TO CABANG"); } sw.Close(); return(fileName); }
private void writeTableContentToInsertStatement(string tableName, StreamWriter sw, Data_Access DAccess, bool skipAddBranchID = false, string sqlParam = "", string customTableName = "", string fieldForPK = "", string fieldValueForPK = "", bool forcedInsert = false) { string sqlCommand = ""; MySqlDataReader rdr; string valueStatement = ""; int rdrFieldIndex = 0; int startIndex = 0; DateTime tempDateTime; string dateTimeValue; object DBValue = null; int branchID = 0; string namaCabang = ""; int editFlag = 1; string commandStatement = ""; string fieldName = ""; branchID = gUtil.loadbranchID(2, out namaCabang); if (sqlParam.Length <= 0) // EMPTY SQL PARAM MEANS, READ FROM EDIT FLAG { if (forcedInsert == false) { sqlCommand = "SELECT * FROM " + tableName + " WHERE EDITED <> 0"; } else { sqlCommand = "SELECT * FROM " + tableName + " WHERE 1 = 1"; } if (fieldValueForPK.Length > 0) { sqlCommand = sqlCommand + " AND " + fieldForPK + " = '" + fieldValueForPK + "'"; } } else { sqlCommand = sqlParam; } sw.WriteLine(""); using (rdr = DAccess.getData(sqlCommand)) { if (rdr.HasRows) { while (rdr.Read()) { if (forcedInsert == false) { if (sqlParam.Length <= 0) { editFlag = rdr.GetInt32("EDITED"); } } if (editFlag == 1) { commandStatement = "INSERT INTO " + tableName + "("; } else { commandStatement = "UPDATE " + tableName + " SET "; } valueStatement = ""; for (rdrFieldIndex = startIndex; rdrFieldIndex < rdr.FieldCount; rdrFieldIndex++) { DBValue = rdr.GetValue(rdrFieldIndex); if (DBValue.ToString().Length > 0) { fieldName = rdr.GetName(rdrFieldIndex); if (editFlag == 2 && fieldName == fieldForPK) { continue; } if (fieldToSkip.Contains(fieldName)) { continue; } if (editFlag == 1) // INSERT STATEMENT { commandStatement = commandStatement + fieldName + ", "; } else // UPDATE STATEMENT { valueStatement = valueStatement + fieldName + " = "; } if (rdr.GetDataTypeName(rdrFieldIndex) == "DATE") { tempDateTime = rdr.GetDateTime(rdrFieldIndex); dateTimeValue = String.Format(culture, "{0:dd-MM-yyyy}", tempDateTime); valueStatement = valueStatement + "STR_TO_DATE('" + dateTimeValue + "', '%d-%m-%Y'), "; } else if (rdr.GetDataTypeName(rdrFieldIndex) == "DATETIME") { tempDateTime = rdr.GetDateTime(rdrFieldIndex); dateTimeValue = gUtil.getCustomStringFormatDate(tempDateTime); valueStatement = valueStatement + "STR_TO_DATE('" + dateTimeValue + "', '%d-%m-%Y %H:%i'), "; } else { valueStatement = valueStatement + "'" + Convert.ToString(rdr.GetValue(rdrFieldIndex)) + "', "; } } } if (!skipAddBranchID) { if (editFlag == 1) { commandStatement = commandStatement + "BRANCH_ID) VALUES("; valueStatement = valueStatement + branchID + ");"; } else { valueStatement = valueStatement + "BRANCH_ID = " + branchID; } } else { if (editFlag == 1) { commandStatement = commandStatement.Substring(0, commandStatement.Length - 2); commandStatement = commandStatement + ") VALUES("; valueStatement = valueStatement.Substring(0, valueStatement.Length - 2); valueStatement = valueStatement + ");"; } else { valueStatement = valueStatement.Substring(0, valueStatement.Length - 2); } } commandStatement = commandStatement + valueStatement; if (editFlag == 2 && fieldForPK.Length > 0 && fieldValueForPK.Length > 0) { commandStatement = commandStatement + " WHERE " + fieldForPK + " = '" + fieldValueForPK + "';"; } //else // commandStatement = commandStatement + ";"; sw.WriteLine(commandStatement); } } rdr.Close(); } sw.WriteLine(""); }
private void exportData(string fileName, Data_Access DAccess, bool isHQConnection = false) { //string localDate = ""; //string strCmdText = ""; //string ipServer; //System.Diagnostics.Process proc = new System.Diagnostics.Process(); MySqlDataReader rdr; string sqlCommand = ""; string insertStatement = ""; StreamWriter sw = null; // EXPORT MASTER PRODUCT DATA string strCmdText = "USE `sys_pos`; " + "\n" + "DROP TABLE IF EXISTS `temp_master_product`;" + "\n" + "\n" + "CREATE TABLE `temp_master_product` (" + "\n" + "`ID` int(10) unsigned NOT NULL AUTO_INCREMENT," + "\n" + "`PRODUCT_ID` varchar(50) DEFAULT NULL," + "\n" + "`PRODUCT_BARCODE` varchar(15) DEFAULT NULL," + "\n" + "`PRODUCT_NAME` varchar(50) DEFAULT NULL," + "\n" + "`PRODUCT_DESCRIPTION` varchar(100) DEFAULT NULL," + "\n" + "`PRODUCT_BASE_PRICE` double DEFAULT NULL," + "\n" + "`PRODUCT_RETAIL_PRICE` double DEFAULT NULL," + "\n" + "`PRODUCT_BULK_PRICE` double DEFAULT NULL," + "\n" + "`PRODUCT_WHOLESALE_PRICE` double DEFAULT NULL," + "\n" + "`UNIT_ID` smallint(5) unsigned DEFAULT '0'," + "\n" + "`PRODUCT_IS_SERVICE` tinyint(3) unsigned DEFAULT NULL," + "\n" + "PRIMARY KEY(`ID`)," + "\n" + "UNIQUE KEY `PRODUCT_ID_UNIQUE` (`PRODUCT_ID`)" + "\n" + ") ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8;" + "\n" + "\n" + "DROP TABLE IF EXISTS `temp_product_category`;" + "\n" + "\n" + "CREATE TABLE `temp_product_category` (" + "\n" + "`PRODUCT_ID` varchar(50) NOT NULL," + "\n" + "`CATEGORY_ID` tinyint(3) unsigned NOT NULL," + "\n" + "PRIMARY KEY (`PRODUCT_ID`,`CATEGORY_ID`)" + "\n" + ") ENGINE = InnoDB DEFAULT CHARSET = utf8;" + "\n"; //localDate = String.Format(culture, "{0:ddMMyyyy}", DateTime.Now); //fileName = "SYNCINFO_PRODUCT_" + localDate + ".sql"; sqlCommand = "SELECT PRODUCT_ID, IFNULL(PRODUCT_BARCODE, '') AS PRODUCT_BARCODE, IFNULL(PRODUCT_NAME, '') AS PRODUCT_NAME, IFNULL(PRODUCT_DESCRIPTION, '') AS PRODUCT_DESCRIPTION, PRODUCT_BASE_PRICE, PRODUCT_RETAIL_PRICE, PRODUCT_BULK_PRICE, PRODUCT_WHOLESALE_PRICE, UNIT_ID, PRODUCT_IS_SERVICE FROM MASTER_PRODUCT WHERE PRODUCT_ACTIVE = 1"; using (rdr = DAccess.getData(sqlCommand, isHQConnection)) { if (rdr.HasRows) { if (!File.Exists(fileName)) { sw = File.CreateText(fileName); } else { File.Delete(fileName); sw = File.CreateText(fileName); } sw.WriteLine(strCmdText); while (rdr.Read()) { insertStatement = "INSERT INTO TEMP_MASTER_PRODUCT (PRODUCT_ID, PRODUCT_BARCODE, PRODUCT_NAME, PRODUCT_DESCRIPTION, PRODUCT_BASE_PRICE, PRODUCT_RETAIL_PRICE, PRODUCT_BULK_PRICE, PRODUCT_WHOLESALE_PRICE, UNIT_ID, PRODUCT_IS_SERVICE) VALUES (" + "'" + MySqlHelper.EscapeString(rdr.GetString("PRODUCT_ID")) + "', '" + MySqlHelper.EscapeString(rdr.GetString("PRODUCT_BARCODE")) + "', '" + MySqlHelper.EscapeString(rdr.GetString("PRODUCT_NAME")) + "', '" + MySqlHelper.EscapeString(rdr.GetString("PRODUCT_DESCRIPTION")) + "', " + rdr.GetString("PRODUCT_BASE_PRICE") + ", " + rdr.GetString("PRODUCT_RETAIL_PRICE") + ", " + rdr.GetString("PRODUCT_BULK_PRICE") + ", " + rdr.GetString("PRODUCT_WHOLESALE_PRICE") + ", " + rdr.GetString("UNIT_ID") + ", " + rdr.GetString("PRODUCT_IS_SERVICE") + ");"; sw.WriteLine(insertStatement); } } rdr.Close(); } sw.WriteLine(""); // EXPORT MASTER KATEGORI DATA sw.WriteLine(""); sw.WriteLine("DELETE FROM MASTER_CATEGORY;"); sqlCommand = "SELECT CATEGORY_ID, CATEGORY_NAME, IFNULL(CATEGORY_DESCRIPTION, '') AS CATEGORY_DESCRIPTION FROM MASTER_CATEGORY WHERE CATEGORY_ACTIVE = 1"; using (rdr = DAccess.getData(sqlCommand, isHQConnection)) { if (rdr.HasRows) { while (rdr.Read()) { insertStatement = "INSERT INTO MASTER_CATEGORY (CATEGORY_ID, CATEGORY_NAME, CATEGORY_DESCRIPTION, CATEGORY_ACTIVE) VALUES (" + rdr.GetString("CATEGORY_ID") + ", '" + MySqlHelper.EscapeString(rdr.GetString("CATEGORY_NAME")) + "', '" + MySqlHelper.EscapeString(rdr.GetString("CATEGORY_DESCRIPTION")) + "', 1);"; sw.WriteLine(insertStatement); } } rdr.Close(); } sw.WriteLine(""); // EXPORT MASTER UNIT DATA sw.WriteLine(""); sw.WriteLine("DELETE FROM MASTER_UNIT;"); sqlCommand = "SELECT UNIT_ID, UNIT_NAME, IFNULL(UNIT_DESCRIPTION, '') AS UNIT_DESCRIPTION FROM MASTER_UNIT WHERE UNIT_ACTIVE = 1"; using (rdr = DAccess.getData(sqlCommand, isHQConnection)) { if (rdr.HasRows) { while (rdr.Read()) { insertStatement = "INSERT INTO MASTER_UNIT (UNIT_ID, UNIT_NAME, UNIT_DESCRIPTION, UNIT_ACTIVE) VALUES (" + rdr.GetString("UNIT_ID") + ", '" + MySqlHelper.EscapeString(rdr.GetString("UNIT_NAME")) + "', '" + MySqlHelper.EscapeString(rdr.GetString("UNIT_DESCRIPTION")) + "', 1);"; sw.WriteLine(insertStatement); } } rdr.Close(); } sw.WriteLine(""); // EXPORT MASTER UNIT KONVERSI DATA sw.WriteLine(""); sw.WriteLine("DELETE FROM UNIT_CONVERT;"); sqlCommand = "SELECT CONVERT_UNIT_ID_1, CONVERT_UNIT_ID_2, CONVERT_MULTIPLIER FROM UNIT_CONVERT"; using (rdr = DAccess.getData(sqlCommand, isHQConnection)) { if (rdr.HasRows) { while (rdr.Read()) { insertStatement = "INSERT INTO UNIT_CONVERT (CONVERT_UNIT_ID_1, CONVERT_UNIT_ID_2, CONVERT_MULTIPLIER) VALUES (" + rdr.GetString("CONVERT_UNIT_ID_1") + ", " + rdr.GetString("CONVERT_UNIT_ID_2") + ", " + rdr.GetString("CONVERT_MULTIPLIER") + ");"; sw.WriteLine(insertStatement); } } rdr.Close(); } sw.WriteLine(""); // EXPORT PRODUCT CATEGORY DATA sw.WriteLine(""); sqlCommand = "SELECT PRODUCT_ID, CATEGORY_ID FROM PRODUCT_CATEGORY"; using (rdr = DAccess.getData(sqlCommand, isHQConnection)) { if (rdr.HasRows) { while (rdr.Read()) { insertStatement = "INSERT INTO TEMP_PRODUCT_CATEGORY (PRODUCT_ID, CATEGORY_ID) VALUES (" + "'" + rdr.GetString("PRODUCT_ID") + "', " + rdr.GetString("CATEGORY_ID") + ");"; sw.WriteLine(insertStatement); } } rdr.Close(); } sw.WriteLine(""); sw.Close(); //ipServer = DS.getIPServer(); ////strCmdText = "/C mysqldump -h " + ipServer + " -u SYS_POS_ADMIN -ppass123 sys_pos MASTER_PRODUCT > \"" + fileName + "\""; //proc.StartInfo.FileName = "CMD.exe"; //proc.StartInfo.Arguments = "/C " + "mysqldump -h " + ipServer + " -u SYS_POS_ADMIN -ppass123 sys_pos > \"" + fileName + "\""; //proc.Exited += new EventHandler(ProcessExited); //proc.EnableRaisingEvents = true; //proc.Start(); //System.Diagnostics.Process.Start("CMD.exe", strCmdText); }