private void loadCompanyAndBranchList() { try { string strMainDB = System.Configuration.ConfigurationManager.AppSettings["MainDB"].ToString(); string strInterface = System.Configuration.ConfigurationManager.AppSettings["InterDB"].ToString(); sQuery = " Select 'ALL' As 'Company' "; sQuery += " Union All "; sQuery += " Select T1.U_COMPANY As 'Company' From "; sQuery += " [@Z_INBOUNDMAPPING] T1 Where ISNULL(T1.U_COMPANY,'') <> '' "; //sQuery += " Where T0.U_SHOPID = '" + dgv_S_OINV.Rows[i].Cells["ShopID"].Value.ToString().Trim() + "'"; oCompanyDT = Armada_Sync.Singleton.objSqlDataAccess.ExecuteReader(sQuery, strMainDB); sQuery = " Select T1.U_COMPANY As 'Company' ,T0.U_SHOPID As 'Shop' From "; sQuery += " [@Z_INBOUNDMAPPINGC] T0 JOIN [@Z_INBOUNDMAPPING] T1 On T0.Code = T1.Code "; oShopDT = Armada_Sync.Singleton.objSqlDataAccess.ExecuteReader(sQuery, strMainDB); sQuery = " SELECT DISTINCT Shop As 'Shop' "; sQuery += " FROM RETN T0 "; sQuery += " Where ISNULL([Status],'') = '' "; oShopDT_O = Armada_Sync.Singleton.objSqlDataAccess.ExecuteReader(sQuery, strInterface); cmbCompany.DataSource = oCompanyDT; cmbCompany.DisplayMember = "Company"; cmbCompany.ValueMember = "Company"; cmbCompany.SelectedIndex = 0; filterShops(cmbCompany.SelectedValue.ToString()); } catch (Exception ex) { TransLog.traceService(" Error : " + ex.Message); } }
private void loadLocationAndLocationList() { try { string strInterface = System.Configuration.ConfigurationManager.AppSettings["InterDB"].ToString(); sQuery = " Select 'ALL' As 'FLocation' "; sQuery += " Union All "; sQuery += " Select Distinct FrmLoc As 'FLocation' From INTR Where ISNULL(Status,'') <> 'Success' "; oCompanyDT = Armada_Sync.Singleton.objSqlDataAccess.ExecuteReader(sQuery, strInterface); cmbFLocation.DataSource = oCompanyDT; cmbFLocation.DisplayMember = "FLocation"; cmbFLocation.ValueMember = "FLocation"; cmbFLocation.SelectedIndex = 0; sQuery = " Select Distinct ToLoc As 'TLocation' From INTR "; sQuery += " Where ISNULL(Status,'') <> 'Success' "; //sQuery += " And FrmLoc = '" + cmbFLocation.SelectedValue.ToString() + "'"; oLocationDT = Armada_Sync.Singleton.objSqlDataAccess.ExecuteReader(sQuery, strInterface); chkLocationID.Items.Clear(); foreach (DataRow dr in oLocationDT.Rows) { chkLocationID.Items.Add(dr["TLocation"], false); } chkLocationID.DisplayMember = "TLocation"; chkLocationID.ValueMember = "TLocation"; //filterTLocations(cmbFLocation.SelectedValue.ToString()); } catch (Exception ex) { TransLog.traceService(" Error : " + ex.Message); } }
private void btnSync_Click(object sender, EventArgs e) { try { btnFilter.Enabled = false; toolStripProgressBar1.Maximum = dgv_S_OCRD.RowCount; m_oWorker.RunWorkerAsync(); //string[] strValues = new string[4]; //Hashtable htCCDet = new Hashtable(); //string strInterface = System.Configuration.ConfigurationManager.AppSettings["InterDB"].ToString(); //string strMainDB = System.Configuration.ConfigurationManager.AppSettings["MainDB"].ToString(); //oDtTransLog = Armada_Sync.Singleton.objSqlDataAccess.ExecuteReader(TRANSACTIONLOG, strInterface); //if (oDtTransLog != null && oDtTransLog.Rows.Count > 0) //{ // foreach (DataRow dr in oDtTransLog.Rows) // { // try // { // foreach (SAPbobsCOM.Company item in TransLog.objCompany) // { // TransLog.traceService(" Transaction Type : " + dr["Scenario"].ToString()); // TransLog.traceService(" Transaction Key : " + dr["Key"].ToString()); // TransLog.traceService("Company DB : " + item.CompanyDB); // if (item.Connected) // { // string strCountry = item.GetCompanyService().GetAdminInfo().Country; // if (dr["Country"].ToString() == strCountry) // { // if (strMainDB != item.CompanyDB) // { // Singleton.obj_S_OCRD.Sync((dr["Key"].ToString()), TransType.A, item, strInterface, "", strValues, htCCDet); // } // } // else // { // TransLog.traceService(" Error : Company Not Connected."); // } // } // } // } // catch (Exception ex) // { // TransLog.traceService(" Error : " + ex.Message); // } // } //} //MessageBox.Show("Manual Sync Completed..."); } catch (Exception ex) { TransLog.traceService("Error Message : " + ex.Message); TransLog.traceService(" Error Source : " + ex.Source); MessageBox.Show(ex.Message.ToString()); } }
private void btnFilter_Click(object sender, EventArgs e) { try { LoadAll(); } catch (Exception ex) { TransLog.traceService("Error Message : " + ex.Message); } }
private void btnSync_Click(object sender, EventArgs e) { try { string[] strValues = new string[4]; Hashtable htCCDet = new Hashtable(); string strInterface = System.Configuration.ConfigurationManager.AppSettings["InterDB"].ToString(); string strMainDB = System.Configuration.ConfigurationManager.AppSettings["MainDB"].ToString(); oDtTransLog = Armada_Sync.Singleton.objSqlDataAccess.ExecuteReader(TRANSACTIONLOG, strInterface); if (oDtTransLog != null && oDtTransLog.Rows.Count > 0) { foreach (DataRow dr in oDtTransLog.Rows) { try { foreach (SAPbobsCOM.Company item in TransLog.objCompany) { TransLog.traceService(" Transaction Type : " + dr["Scenario"].ToString()); TransLog.traceService(" Transaction Key : " + dr["Key"].ToString()); TransLog.traceService("Company DB : " + item.CompanyDB); if (item.Connected) { string strCountry = item.GetCompanyService().GetAdminInfo().Country; if (dr["Country"].ToString() == strCountry) { if (strMainDB != item.CompanyDB) { Singleton.obj_S_OCRD.Sync((dr["Key"].ToString()), TransType.A, item, strInterface, "", strValues, htCCDet); } } else { TransLog.traceService(" Error : Company Not Connected."); } } } } catch (Exception ex) { TransLog.traceService(" Error : " + ex.Message); } } } MessageBox.Show("Manual Sync Completed..."); LoadAll(); } catch (Exception ex) { TransLog.traceService("Error Message : " + ex.Message); TransLog.traceService(" Error Source : " + ex.Source); MessageBox.Show(ex.Message.ToString()); } }
private void btnSync_Click(object sender, EventArgs e) { try { btnFilter.Enabled = false; m_oWorker.RunWorkerAsync(); } catch (Exception ex) { TransLog.traceService("Error Message : " + ex.Message); TransLog.traceService(" Error Source : " + ex.Source); } }
private void S_OINV_Load(object sender, EventArgs e) { try { UXUTIL.clsUtilities.setAllControlsThemes(this); this.WindowState = FormWindowState.Maximized; LoadAll(); } catch (Exception ex) { TransLog.traceService(" Error : " + ex.Message); } }
private void btnImport_Click(object sender, EventArgs e) { if (txtFilePath.Text == string.Empty || txtFilePath.Text == "") { MessageBox.Show("Please select a file"); } else { string strProvider = ConfigurationManager.AppSettings["oledbProvider"].ToString(); bool hasHeaders = true; String connString = String.Format(strProvider, txtFilePath.Text, hasHeaders ? "Yes" : "No"); OleDbConnection oledbConn = new OleDbConnection(connString); try { // Open connection oledbConn.Open(); // Create OleDbCommand object and select data from worksheet Sheet1 OleDbCommand cmd = new OleDbCommand("SELECT * FROM " + ConfigurationManager.AppSettings["Sheet"].ToString(), oledbConn); // Create new OleDbDataAdapter OleDbDataAdapter oleda = new OleDbDataAdapter(); oleda.SelectCommand = cmd; // Create a DataSet which will hold the data extracted from the worksheet. oDS = new DataSet(); // Fill the DataSet from the data extracted from the worksheet. oleda.Fill(oDS, "OITM"); // Bind the data to the GridView dataGridView1.DataSource = oDS.Tables[0].DefaultView; MessageBox.Show("Data Imported Sucessfully..."); //txtFilePath.Text = string.Empty; } catch (Exception ex) { TransLog.traceService(" Error : " + ex.Message); } finally { // Close connection oledbConn.Close(); } } }
void m_oWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { try { StatusLabel.Text = "Sync Process Completed..."; btnFilter.Enabled = true; LoadAll(); } catch (Exception ex) { TransLog.traceService(ex.StackTrace.ToString()); TransLog.traceService(ex.Message.ToString()); } }
private void btnSelectAll_Click(object sender, EventArgs e) { try { for (int index = 0; index <= chkShopID.Items.Count - 1; index++) { chkShopID.SetItemChecked(index, true); } } catch (Exception ex) { TransLog.traceService(" Error : " + ex.Message); } }
private void LoadAll() { try { string strInterface = System.Configuration.ConfigurationManager.AppSettings["InterDB"].ToString(); DataTable oDS_M_S_OINV = null; string str_M_S_OINV = "Exec Armada_Service_M_S_OINV_s"; oDS_M_S_OINV = Armada_Sync.Singleton.objSqlDataAccess.ExecuteReader(str_M_S_OINV, strInterface); dgv_S_OINV.DataSource = oDS_M_S_OINV; } catch (Exception ex) { TransLog.traceService(" Error : " + ex.Message); } }
private void filterShops(string strCompany) { try { //bool Checked = false; DataTable oFilterCompany = null; DataView dv = new DataView(); dv = oShopDT.DefaultView; DataTable dt = dv.Table; if (strCompany != "ALL") { dt.DefaultView.RowFilter = "Company = '" + strCompany + "'"; } else { dt.DefaultView.RowFilter = " 1 = 1"; } //chkShopID.Items.Clear(); //foreach (DataRow dr in dt.DefaultView.ToTable().Rows) //{ // chkShopID.Items.Add(dr["Shop"], false); //} oFilterCompany = dt.DefaultView.ToTable(); var query = from shop in oFilterCompany.AsEnumerable() join shop_o in oShopDT_O.AsEnumerable() on shop.Field <string>("Shop") equals shop_o.Field <string>("Shop") select new { shop = shop_o.Field <string>("Shop") }; chkShopID.Items.Clear(); foreach (var shop_o in query) { chkShopID.Items.Add(shop_o.shop, false); } chkShopID.DisplayMember = "Shop"; chkShopID.ValueMember = "Shop"; } catch (Exception ex) { TransLog.traceService(" Error : " + ex.Message); } }
private void S_OCRD_Load(object sender, EventArgs e) { try { UXUTIL.clsUtilities.setAllControlsThemes(this); this.WindowState = FormWindowState.Maximized; loadCountry(); //LoadAll(); //loadError(); //S_OCRD.CheckForIllegalCrossThreadCalls = true; } catch (Exception ex) { TransLog.traceService(" Error : " + ex.Message); } }
private void loadCountry() { try { string strInterface = System.Configuration.ConfigurationManager.AppSettings["InterDB"].ToString(); string str_Qry = " Select Distinct Country From Customers Where Status Is Null "; oDtCountry = Armada_Sync.Singleton.objSqlDataAccess.ExecuteReader(str_Qry, strInterface); CmbCountry.DataSource = oDtCountry; CmbCountry.DisplayMember = "Country"; CmbCountry.ValueMember = "Country"; CmbCountry.SelectedIndex = 0; } catch (Exception ex) { TransLog.traceService(" Error : " + ex.Message); } }
private void LoadAll() { try { string strInterface = System.Configuration.ConfigurationManager.AppSettings["InterDB"].ToString(); DataTable oDS_OCRD = null; string strCountry = CmbCountry.SelectedValue.ToString(); string str_M_S_OCRD = "Exec [Armada_Service_M_S_OCRD_s] '" + strCountry + "'"; oDS_OCRD = Armada_Sync.Singleton.objSqlDataAccess.ExecuteReader(str_M_S_OCRD, strInterface); dgv_S_OCRD.DataSource = oDS_OCRD; loadError(); } catch (Exception ex) { TransLog.traceService(" Error : " + ex.Message); } }
private void LoadAll() { try { string strInterface = System.Configuration.ConfigurationManager.AppSettings["InterDB"].ToString(); DataTable oDS_M_S_OINV = null; DateTime oFDate = Fromdate.Value; DateTime oTDate = ToDate.Value; LoadShopXML(); string str_M_S_OINV = "Exec Armada_Service_M_S_OINV_s '" + oFDate.ToString("yyyyMMdd") + "','" + oTDate.ToString("yyyyMMdd") + "','" + strShopXML + "'"; oDS_M_S_OINV = Armada_Sync.Singleton.objSqlDataAccess.ExecuteReader(str_M_S_OINV, strInterface); dgv_S_OINV.DataSource = oDS_M_S_OINV; loadError(); } catch (Exception ex) { TransLog.traceService(" Error : " + ex.Message); } }
private void LoadShopXML() { try { int arrcnt = 0; string Shop = null; string Code = null; string[] ShopArr = new string[chkShopID.CheckedItems.Count]; for (arrcnt = 0; arrcnt <= chkShopID.CheckedItems.Count - 1; arrcnt++) { ShopArr[arrcnt] = chkShopID.CheckedItems[arrcnt].ToString(); } Shop = "Shop"; Code = "ShopID"; strShopXML = ShopStringArrayToXML(ShopArr, Shop, Code); } catch (Exception ex) { TransLog.traceService(" Error : " + ex.Message); } }
private String ShopStringArrayToXML(String[] Array, String Element, String Attribute) { XElement identity = new XElement(Element); try { for (int i = 0; i <= Array.Length - 1; i++) { if (Array[i] != null) { XElement elm = new XElement(Attribute, Array[i].Trim()); identity.Add(elm); } } } catch (Exception ex) { TransLog.traceService(" Error : " + ex.Message); } return(identity.ToString()); }
private void loadError() { try { for (int i = 0; i < dgv_S_OCRD.RowCount; i++) { if (dgv_S_OCRD.Rows[i].Cells[1].Value.ToString() == "-1") { Image image = Armada_App.Properties.Resources.Create1; dgv_S_OCRD.Rows[i].Cells["Image"].Value = image; } else { Image image = Armada_App.Properties.Resources.Red_mark; dgv_S_OCRD.Rows[i].Cells["Image"].Value = image; } } } catch (Exception ex) { TransLog.traceService(" Error : " + ex.Message); } }
private void S_OITM_Load(object sender, EventArgs e) { try { UXUTIL.clsUtilities.setAllControlsThemes(this); this.WindowState = FormWindowState.Maximized; //this.CheckForIllegalCrossThreadCalls = false; oDtCompany = new DataTable(); oDtCompany.Columns.Add("Company", typeof(string)); oDtCompany.Columns.Add("Company Name", typeof(string)); string strMaiDB = System.Configuration.ConfigurationManager.AppSettings["MainDB"].ToString(); oCompany = (SAPbobsCOM.Company)TransLog.GetCompany(strMaiDB); SAPbobsCOM.Recordset oRecordSet; oRecordSet = oCompany.GetCompanyList(); DataRow oDr; while (!oRecordSet.EoF) { oDr = oDtCompany.NewRow(); oDr["Company"] = oRecordSet.Fields.Item(0).Value; oDr["Company Name"] = oRecordSet.Fields.Item(1).Value; oDtCompany.Rows.Add(oDr); oRecordSet.MoveNext(); } BindingSource bs = new BindingSource(); bs.DataSource = oDtCompany; comboBox1.DataSource = oDtCompany; comboBox1.DisplayMember = "Company Name"; comboBox1.ValueMember = "Company"; comboBox1.SelectedIndex = 0; System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = false; } catch (Exception ex) { TransLog.traceService(" Error : " + ex.Message); } }
void m_oWorker_DoWork(object sender, DoWorkEventArgs e) { try { string[] strValues = new string[4]; Hashtable htCCDet = new Hashtable(); string strInterface = System.Configuration.ConfigurationManager.AppSettings["InterDB"].ToString(); string strMainDB = System.Configuration.ConfigurationManager.AppSettings["MainDB"].ToString(); for (int i = 0; i < dgv_S_OCRD.RowCount; i++) { try { //dgv_S_OCRD.FirstDisplayedScrollingRowIndex = i; //m_oWorker.ReportProgress(i); bool blnSync = false; foreach (SAPbobsCOM.Company item in TransLog.objCompany) { TransLog.traceService(" Transaction Type : " + dgv_S_OCRD.Rows[i].Cells["Scenario"].Value.ToString().Trim()); TransLog.traceService(" Transaction Key : " + dgv_S_OCRD.Rows[i].Cells["Source_Key"].Value.ToString().Trim()); TransLog.traceService("Company DB : " + item.CompanyDB); if (item.Connected) { string strCountry = item.GetCompanyService().GetAdminInfo().Country; if (dgv_S_OCRD.Rows[i].Cells["Country"].Value.ToString() == strCountry) { if (strMainDB != item.CompanyDB) { Image image = Armada_App.Properties.Resources.Sync1; dgv_S_OCRD.Rows[i].Cells["Image"].Value = image; Singleton.obj_S_OCRD.Sync((dgv_S_OCRD.Rows[i].Cells["Source_Key"].Value.ToString().Trim()), TransType.A, item, strInterface, "", strValues, htCCDet); string strQuery = "Select Status,Remarks From dbo.Z_OTXN Where Scenario = '" + dgv_S_OCRD.Rows[i].Cells["Scenario"].Value.ToString().Trim() + "' "; strQuery += " And S_DocNo = '" + dgv_S_OCRD.Rows[i].Cells["Source_Key"].Value.ToString().Trim() + "' "; DataTable oStatus = Armada_Sync.Singleton.objSqlDataAccess.ExecuteReader(strQuery, strInterface); if (oStatus != null && oStatus.Rows.Count > 0) { if (oStatus.Rows[0][0].ToString() == "1") { blnSync = true; dgv_S_OCRD.Rows[i].Cells["Remarks"].Value = string.Empty; } else { blnSync = false; dgv_S_OCRD.Rows[i].Cells["Remarks"].Value = oStatus.Rows[0][1].ToString(); } } else { blnSync = false; } } } if (blnSync) { Image image = Armada_App.Properties.Resources.Yes1; dgv_S_OCRD.Rows[i].Cells["Image"].Value = image; //System.Threading.Thread.Sleep(100); } else { Image image = Armada_App.Properties.Resources.Error1; dgv_S_OCRD.Rows[i].Cells["Image"].Value = image; //System.Threading.Thread.Sleep(100); } } else { TransLog.traceService(" Error : Company Not Connected."); //Image image = Armada_App.Properties.Resources.Error1; //dgv_S_OCRD.Rows[i].Cells["Image"].Value = image; //System.Threading.Thread.Sleep(100); } //toolStripProgressBar1.Value = i; } //toolStripProgressBar1.Value = 0; } catch (Exception ex) { TransLog.traceService(ex.StackTrace.ToString()); TransLog.traceService(ex.Message.ToString()); } } m_oWorker.CancelAsync(); } catch (Exception ex) { TransLog.traceService(ex.StackTrace.ToString()); TransLog.traceService(ex.Message.ToString()); } finally { toolStripProgressBar1.Value = 0; } }
private void btnSync_Click(object sender, EventArgs e) { try { //thread = new System.Threading.Thread(import_Products); //thread.Start(); //if (!thread.IsAlive) //{ // thread.Abort(); //} //int i = 1; int intThreadRecords = oDS.Tables[0].Rows.Count / 100; //int acount = 0; Hashtable aListHash = new Hashtable(); aList_C = new ArrayList(intThreadRecords); for (int intRow = 0; intRow < oDS.Tables[0].Rows.Count; intRow++) { //acount += 1; if (!aListHash.Contains(oDS.Tables[0].Rows[intRow]["ItemCode"])) { aListHash.Add(oDS.Tables[0].Rows[intRow]["ItemCode"], oDS.Tables[0].Rows[intRow]); } if (aListHash.Count == intThreadRecords) { aList_C.Add(aListHash); } else if (oDS.Tables[0].Rows.Count - 1 == intRow) { aList_C.Add(aListHash); } if (aListHash.Count == intThreadRecords) { aListHash = new Hashtable(); } } string strMaiDB = comboBox1.SelectedValue.ToString(); //System.Threading.Thread[] ThreadCollections = new System.Threading.Thread[aList_C.Count + 1]; for (int index = 0; index <= aList_C.Count - 1; index++) { Hashtable oHT = (Hashtable)aList_C[index]; Multitask oMultiTask = new Multitask(strMaiDB, this, oDS, oHT); thread = new Thread(oMultiTask.import_Products); thread.Priority = ThreadPriority.Highest; thread.IsBackground = true; thread.ApartmentState = System.Threading.ApartmentState.STA; thread.Start(); //ThreadCollections[index) = thread; } } catch (Exception ex) { TransLog.traceService(" Error : " + ex.Message); } }
public void import_Products() { try { System.Reflection.Assembly oItem_R = System.Reflection.Assembly.LoadFrom(Application.StartupPath + "\\Interop.SAPbobsCOM.dll"); string strMaiDB = strCompany_S.ToString();//System.Configuration.ConfigurationManager.AppSettings["MainDB"].ToString(); oCompany = (SAPbobsCOM.Company)TransLog.GetCompany(strMaiDB); SAPbobsCOM.Items oItem = (SAPbobsCOM.Items)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oItems); foreach (DictionaryEntry entry in oHT_S) { DataRow row = (DataRow)entry.Value; try { bool blnItemExist = false; string strItemCode = row["ItemCode"].ToString(); TransLog.traceService(" Product : " + strItemCode); //Thread.Sleep(100); //oForm_S.label1.Text = "Creation Item No : " + " - :" + strItemCode; //Application.DoEvents(); //oForm_S.Invoke((MethodInvoker)delegate //{ // oForm_S.label1.Text = strItemCode; // runs on UI thread //}); //oForm_S.label1.Invoke(new Action(() => Control.text = "")); if (oItem.GetByKey(row["ItemCode"].ToString())) { blnItemExist = true; } foreach (DataColumn column in oDS_S.Tables[0].Columns) { string DESTF = column.ColumnName; if (!DESTF.StartsWith("U_")) { try { if (DESTF != "ItemsGroupCode") { oItem_R.GetType("SAPbobsCOM.IItems").GetProperty(DESTF).SetValue(oItem, row[DESTF].ToString(), null); } else { oItem_R.GetType("SAPbobsCOM.IItems").GetProperty(DESTF).SetValue(oItem, Convert.ToInt32(row[DESTF].ToString()), null); } } catch (Exception ex) { TransLog.traceService(" Error : " + ex.Message + "--> Field : " + DESTF); } } else { oItem.UserFields.Fields.Item(DESTF).Value = row[column.ColumnName.ToString()].ToString(); } } int intStatus = 0; if (!blnItemExist) { intStatus = oItem.Add(); if (intStatus != 0) { TransLog.traceService(" Error : " + oCompany.GetLastErrorDescription()); } else { TransLog.traceService(" Success "); } } else { intStatus = oItem.Update(); if (intStatus != 0) { TransLog.traceService(" Error : " + oCompany.GetLastErrorDescription()); } else { TransLog.traceService(" Success "); } } } catch (Exception ex) { TransLog.traceService(" Error : " + ex.Message); } } } catch (Exception ex) { TransLog.traceService(" Error : " + ex.Message); } }
private void btnSync_Click(object sender, EventArgs e) { try { string strInterface = System.Configuration.ConfigurationManager.AppSettings["InterDB"].ToString(); string strMainDB = System.Configuration.ConfigurationManager.AppSettings["MainDB"].ToString(); oDtTransLog = Armada_Sync.Singleton.objSqlDataAccess.ExecuteReader(TRANSACTIONLOG, strInterface); if (oDtTransLog != null && oDtTransLog.Rows.Count > 0) { foreach (DataRow dr in oDtTransLog.Rows) { try { string[] strValues = new string[4]; sQuery = " Select T1.U_COMPANY,T0.U_WAREHOUSE From "; sQuery += " [@Z_INBOUNDMAPPINGC] T0 JOIN [@Z_INBOUNDMAPPING] T1 On T0.Code = T1.Code "; sQuery += " Where T0.U_SHOPID = '" + dr["ShopID"].ToString() + "'"; oCompDT = Armada_Sync.Singleton.objSqlDataAccess.ExecuteReader(sQuery, strMainDB); if (oCompDT != null) { if (oCompDT.Rows.Count > 0) { strCompany = oCompDT.Rows[0][0].ToString(); strWareHouse = oCompDT.Rows[0][1].ToString(); oGetCompany = TransLog.GetCompany(strCompany); } } sQuery = " Select T1.U_COMPANY,T0.U_WAREHOUSE,T0.U_PRICELIST From "; sQuery += " [@Z_INBOUNDMAPPINGC] T0 JOIN [@Z_INBOUNDMAPPING] T1 On T0.Code = T1.Code "; sQuery += " Where T0.U_SHOPID = '" + dr["ShopID_T"].ToString() + "'"; oCompDT = Armada_Sync.Singleton.objSqlDataAccess.ExecuteReader(sQuery, strMainDB); if (oCompDT != null) { if (oCompDT.Rows.Count > 0) { strCompany_T = oCompDT.Rows[0][0].ToString(); strWareHouse_T = oCompDT.Rows[0][1].ToString(); oGetCompany_T = TransLog.GetCompany(strCompany_T); strValues[0] = oCompDT.Rows[0][2].ToString(); } } TransLog.traceService(" Transaction Type : " + dr["Scenario"].ToString()); TransLog.traceService(" Transaction Key : " + dr["Key"].ToString()); if (oGetCompany != null && oGetCompany_T != null) { TransLog.traceService("From Company DB : " + oGetCompany.CompanyDB); TransLog.traceService("To Company DB : " + oGetCompany_T.CompanyDB); if (oGetCompany.Connected && oGetCompany_T.Connected) { Singleton.obj_S_OWTR.Sync((dr["Key"].ToString()), TransType.A, oGetCompany, oGetCompany_T, strInterface, strWareHouse, strWareHouse_T, strValues); } else { TransLog.traceService(" Error : Either One of the Company Not Connected."); } } else { TransLog.traceService(" Error : Either One of the Company Not Found."); } } catch (Exception ex) { TransLog.traceService(" Error : " + ex.Message); } } } MessageBox.Show("Manual Sync Completed..."); LoadAll(); } catch (Exception ex) { TransLog.traceService("Error Message : " + ex.Message); TransLog.traceService(" Error Source : " + ex.Source); MessageBox.Show(ex.Message.ToString()); } }
private void btnSync_Click(object sender, EventArgs e) { try { string strInterface = System.Configuration.ConfigurationManager.AppSettings["InterDB"].ToString(); string strMainDB = System.Configuration.ConfigurationManager.AppSettings["MainDB"].ToString(); oDtTransLog = Armada_Sync.Singleton.objSqlDataAccess.ExecuteReader(TRANSACTIONLOG, strInterface); if (oDtTransLog != null && oDtTransLog.Rows.Count > 0) { foreach (DataRow dr in oDtTransLog.Rows) { try { Hashtable htCCDet = new Hashtable(); string[] strValues = new string[4]; sQuery = " Select T1.U_COMPANY,T0.U_WAREHOUSE From "; sQuery += " [@Z_INBOUNDMAPPINGC] T0 JOIN [@Z_INBOUNDMAPPING] T1 On T0.Code = T1.Code "; sQuery += " Where T0.U_SHOPID = '" + dr["ShopID"].ToString() + "'"; oCompDT = Armada_Sync.Singleton.objSqlDataAccess.ExecuteReader(sQuery, strMainDB); if (oCompDT != null) { if (oCompDT.Rows.Count > 0) { strCompany = oCompDT.Rows[0]["U_COMPANY"].ToString(); strWareHouse = oCompDT.Rows[0]["U_WAREHOUSE"].ToString(); oGetCompany = TransLog.GetCompany(strCompany); sQuery = " Select T0.U_SCREDITCARD,T0.U_CREDITCARD,T0.U_CARDNUMBER,T0.U_CARDVALID,T0.U_PAYMENTMETHOD From "; sQuery += " [@Z_INBOUNDMAPPINGC1] T0 JOIN [@Z_INBOUNDMAPPING] T1 On T0.Code = T1.Code "; sQuery += " Where T1.U_COMPANY = '" + strCompany + "'"; oCCDT = Armada_Sync.Singleton.objSqlDataAccess.ExecuteReader(sQuery, strMainDB); if (oCCDT != null) { if (oCCDT.Rows.Count > 0) { foreach (DataRow dr1 in oCCDT.Rows) { htCCDet.Add(dr1["U_SCREDITCARD"], dr1); } } } } } TransLog.traceService(" Transaction Type : " + dr["Scenario"].ToString()); TransLog.traceService(" Transaction Key : " + dr["Key"].ToString()); if (oGetCompany != null) { TransLog.traceService("Company DB : " + oGetCompany.CompanyDB); if (oGetCompany.Connected) { Singleton.obj_S_OINV.Sync((dr["Key"].ToString()), TransType.A, oGetCompany, strInterface, strWareHouse, strValues, htCCDet); } else { TransLog.traceService(" Error : Company Not Connected."); } } else { TransLog.traceService(" Error : Company Not Found."); } } catch (Exception ex) { TransLog.traceService(" Error : " + ex.Message); } } } MessageBox.Show("Manual Sync Completed..."); LoadAll(); } catch (Exception ex) { TransLog.traceService("Error Message : " + ex.Message); TransLog.traceService(" Error Source : " + ex.Source); MessageBox.Show(ex.Message.ToString()); } }
void m_oWorker_DoWork(object sender, DoWorkEventArgs e) { try { string strInterface = System.Configuration.ConfigurationManager.AppSettings["InterDB"].ToString(); string strMainDB = System.Configuration.ConfigurationManager.AppSettings["MainDB"].ToString(); int intCount = 0; int intCompleted = dgv_S_OWTR.RowCount; for (int i = 0; i < dgv_S_OWTR.RowCount; i++) { intCount += 1; if (intCount == (intCompleted / 10)) { toolStripProgressBar1.PerformStep(); intCount = 0; } try { bool blnSync = false; string[] strValues = new string[4]; sQuery = " Select T1.U_COMPANY,T0.U_WAREHOUSE,T0.U_GIACCT From "; sQuery += " [@Z_INBOUNDMAPPINGC] T0 JOIN [@Z_INBOUNDMAPPING] T1 On T0.Code = T1.Code "; sQuery += " Where T0.U_LOCATION = '" + dgv_S_OWTR.Rows[i].Cells["ShopID"].Value.ToString().Trim() + "'"; oCompDT = Armada_Sync.Singleton.objSqlDataAccess.ExecuteReader(sQuery, strMainDB); if (oCompDT != null) { if (oCompDT.Rows.Count > 0) { strCompany = oCompDT.Rows[0][0].ToString(); strWareHouse = oCompDT.Rows[0][1].ToString(); strValues[1] = oCompDT.Rows[0]["U_GIACCT"].ToString(); oGetCompany = TransLog.GetCompany(strCompany); } } sQuery = " Select T1.U_COMPANY,T0.U_WAREHOUSE,T0.U_PRICELIST,T0.U_GRACCT From "; sQuery += " [@Z_INBOUNDMAPPINGC] T0 JOIN [@Z_INBOUNDMAPPING] T1 On T0.Code = T1.Code "; sQuery += " Where T0.U_LOCATION = '" + dgv_S_OWTR.Rows[i].Cells["ToShop"].Value.ToString().Trim() + "'"; oCompDT = Armada_Sync.Singleton.objSqlDataAccess.ExecuteReader(sQuery, strMainDB); if (oCompDT != null) { if (oCompDT.Rows.Count > 0) { strCompany_T = oCompDT.Rows[0][0].ToString(); strWareHouse_T = oCompDT.Rows[0][1].ToString(); oGetCompany_T = TransLog.GetCompany(strCompany_T); strValues[0] = oCompDT.Rows[0]["U_PRICELIST"].ToString(); strValues[2] = oCompDT.Rows[0]["U_GRACCT"].ToString(); } } TransLog.traceService(" Transaction Type : " + dgv_S_OWTR.Rows[i].Cells["Scenario"].Value.ToString().Trim()); TransLog.traceService(" Transaction Key : " + dgv_S_OWTR.Rows[i].Cells["Source_Key"].Value.ToString().Trim()); if (oGetCompany != null && oGetCompany_T != null) { TransLog.traceService("Source Company DB : " + oGetCompany.CompanyDB); TransLog.traceService("Destination Company DB : " + oGetCompany_T.CompanyDB); if (oGetCompany.Connected && oGetCompany_T.Connected) { if (oGetCompany.CompanyDB != oGetCompany_T.CompanyDB) { //Overriding the Good Issue Account if transaction happening from Main Company if (oGetCompany.CompanyDB == strMainDB) { sQuery = " Select T0.U_GIACCT From "; sQuery += " [@Z_INBOUNDMAPPINGC2] T0 JOIN [@Z_INBOUNDMAPPING] T1 On T0.Code = T1.Code "; sQuery += " Where T1.U_COMPANY = '" + strMainDB + "'"; sQuery += " And T0.U_COMPANY = '" + oGetCompany_T.CompanyDB + "'"; DataTable oCompDT1 = Armada_Sync.Singleton.objSqlDataAccess.ExecuteReader(sQuery, strMainDB); if (oCompDT1 != null) { if (oCompDT1.Rows.Count > 0) { strValues[1] = oCompDT1.Rows[0]["U_GIACCT"].ToString(); } } } //Overriding the Good Recipt Account if transaction happening from Main Company if (oGetCompany_T.CompanyDB == strMainDB) { sQuery = " Select T0.U_GRACCT From "; sQuery += " [@Z_INBOUNDMAPPINGC2] T0 JOIN [@Z_INBOUNDMAPPING] T1 On T0.Code = T1.Code "; sQuery += " Where T1.U_COMPANY = '" + strMainDB + "'"; sQuery += " And T0.U_COMPANY = '" + oGetCompany.CompanyDB + "'"; DataTable oCompDT1 = Armada_Sync.Singleton.objSqlDataAccess.ExecuteReader(sQuery, strMainDB); if (oCompDT1 != null) { if (oCompDT1.Rows.Count > 0) { strValues[2] = oCompDT1.Rows[0]["U_GRACCT"].ToString(); } } } } Singleton.obj_S_OWTR.Sync((dgv_S_OWTR.Rows[i].Cells["Source_Key"].Value.ToString().Trim()), TransType.A, oGetCompany, oGetCompany_T, strInterface, strWareHouse, strWareHouse_T, strValues); string strQuery = "Select Status,Remarks From dbo.Z_OTXN Where Scenario = '" + dgv_S_OWTR.Rows[i].Cells["Scenario"].Value.ToString().Trim() + "' "; strQuery += " And S_DocNo = '" + dgv_S_OWTR.Rows[i].Cells["Source_Key"].Value.ToString().Trim() + "' "; DataTable oStatus = Armada_Sync.Singleton.objSqlDataAccess.ExecuteReader(strQuery, strInterface); if (oStatus != null && oStatus.Rows.Count > 0) { if (oStatus.Rows[0][0].ToString() == "1") { blnSync = true; dgv_S_OWTR.Rows[i].Cells["Remarks"].Value = string.Empty; } else { blnSync = false; dgv_S_OWTR.Rows[i].Cells["Remarks"].Value = oStatus.Rows[0][1].ToString(); } } else { blnSync = false; } } else { TransLog.traceService(" Error : Company Not Connected."); } } else { TransLog.traceService(" Error : Company Not Connected."); } if (blnSync) { Image image = Armada_App.Properties.Resources.Yes1; dgv_S_OWTR.Rows[i].Cells["Image"].Value = image; } else { Image image = Armada_App.Properties.Resources.Error1; dgv_S_OWTR.Rows[i].Cells["Image"].Value = image; } } catch (Exception ex) { TransLog.traceService(ex.StackTrace.ToString()); TransLog.traceService(ex.Message.ToString()); } } m_oWorker.CancelAsync(); } catch (Exception ex) { TransLog.traceService(ex.StackTrace.ToString()); TransLog.traceService(ex.Message.ToString()); } finally { toolStripProgressBar1.Value = 0; } }
void m_oWorker_DoWork(object sender, DoWorkEventArgs e) { try { string strInterface = System.Configuration.ConfigurationManager.AppSettings["InterDB"].ToString(); string strMainDB = System.Configuration.ConfigurationManager.AppSettings["MainDB"].ToString(); int intCount = 0; int intCompleted = dgv_S_OINV.RowCount; for (int i = 0; i < dgv_S_OINV.RowCount; i++) { intCount += 1; if (intCount == (intCompleted / 10)) { toolStripProgressBar1.PerformStep(); intCount = 0; } try { bool blnSync = false; Hashtable htCCDet = new Hashtable(); string[] strValues = new string[4]; sQuery = " Select T1.U_COMPANY,T0.U_WAREHOUSE,ISNULL(T0.U_COSTCEN,'') As U_COSTCEN From "; sQuery += " [@Z_INBOUNDMAPPINGC] T0 JOIN [@Z_INBOUNDMAPPING] T1 On T0.Code = T1.Code "; sQuery += " Where T0.U_SHOPID = '" + dgv_S_OINV.Rows[i].Cells["ShopID"].Value.ToString().Trim() + "'"; oCompDT = Armada_Sync.Singleton.objSqlDataAccess.ExecuteReader(sQuery, strMainDB); if (oCompDT != null) { if (oCompDT.Rows.Count > 0) { strCompany = oCompDT.Rows[0]["U_COMPANY"].ToString(); strWareHouse = oCompDT.Rows[0]["U_WAREHOUSE"].ToString(); strValues[0] = oCompDT.Rows[0]["U_COSTCEN"].ToString(); oGetCompany = TransLog.GetCompany(strCompany); sQuery = " Select T0.U_SCREDITCARD,T0.U_CREDITCARD,T0.U_CARDNUMBER,T0.U_CARDVALID,T0.U_PAYMENTMETHOD From "; sQuery += " [@Z_INBOUNDMAPPINGC1] T0 JOIN [@Z_INBOUNDMAPPING] T1 On T0.Code = T1.Code "; sQuery += " Where T1.U_COMPANY = '" + strCompany + "'"; oCCDT = Armada_Sync.Singleton.objSqlDataAccess.ExecuteReader(sQuery, strMainDB); if (oCCDT != null) { if (oCCDT.Rows.Count > 0) { foreach (DataRow dr1 in oCCDT.Rows) { htCCDet.Add(dr1["U_SCREDITCARD"], dr1); } } } } } TransLog.traceService(" Transaction Type : " + dgv_S_OINV.Rows[i].Cells["Scenario"].Value.ToString().Trim()); TransLog.traceService(" Transaction Key : " + dgv_S_OINV.Rows[i].Cells["Source_Key"].Value.ToString().Trim()); if (oGetCompany != null) { TransLog.traceService("Company DB : " + oGetCompany.CompanyDB); if (oGetCompany.Connected) { Singleton.obj_S_OINV.Sync((dgv_S_OINV.Rows[i].Cells["Source_Key"].Value.ToString().Trim()), TransType.A, oGetCompany, strInterface, strWareHouse, strValues, htCCDet); string strQuery = "Select Status,Remarks From dbo.Z_OTXN Where Scenario = '" + dgv_S_OINV.Rows[i].Cells["Scenario"].Value.ToString().Trim() + "' "; strQuery += " And S_DocNo = '" + dgv_S_OINV.Rows[i].Cells["Source_Key"].Value.ToString().Trim() + "' "; DataTable oStatus = Armada_Sync.Singleton.objSqlDataAccess.ExecuteReader(strQuery, strInterface); if (oStatus != null && oStatus.Rows.Count > 0) { if (oStatus.Rows[0][0].ToString() == "1") { blnSync = true; dgv_S_OINV.Rows[i].Cells["Remarks"].Value = string.Empty; } else { blnSync = false; dgv_S_OINV.Rows[i].Cells["Remarks"].Value = oStatus.Rows[0][1].ToString(); } } else { blnSync = false; } } else { TransLog.traceService(" Error : Company Not Connected."); } } else { TransLog.traceService(" Error : Company Not Found."); } if (blnSync) { Image image = Armada_App.Properties.Resources.Yes1; dgv_S_OINV.Rows[i].Cells["Image"].Value = image; } else { Image image = Armada_App.Properties.Resources.Error1; dgv_S_OINV.Rows[i].Cells["Image"].Value = image; } } catch (Exception ex) { TransLog.traceService(ex.StackTrace.ToString()); TransLog.traceService(ex.Message.ToString()); } } m_oWorker.CancelAsync(); } catch (Exception ex) { TransLog.traceService(ex.StackTrace.ToString()); TransLog.traceService(ex.Message.ToString()); } finally { toolStripProgressBar1.Value = 0; } }