public void SBO_Application_ItemEvent(string formUID, ref ItemEvent itemEvent, SAPbobsCOM.Company sbo_company, ref Application sbo_application, out bool bBubbleEvent, string sessionId) { bBubbleEvent = true; switch (itemEvent.FormTypeEx) { case pluginForm.FormType: case CommonForms.FormLotesCalidad.FormType: frmCalidad.ItemEventHandler(formUID, ref itemEvent, sbo_company, ref sbo_application, out bBubbleEvent, sessionId); break; } }
public void SBO_Application_UDOEvent(UDOEvent udoEventArgs, SAPbobsCOM.Company sbo_company, ref Application sbo_application, out bool bBubbleEvent) { bBubbleEvent = true; }
public void CreateUserTablesMD(SAPbobsCOM.Company sbo_company, ref Application sbo_application) { }
public SAPbobsCOM.Company ConnectToTargetCompany(SAPbobsCOM.Company oCompany, string sUserName, string sPassword, string sDBName, string sServer, string sLicServerName, string sDBUserName , string sDBPassword, string sErrDesc) { string sFuncName = string.Empty; //SAPbobsCOM.Company oCompany = new SAPbobsCOM.Company(); long lRetCode; try { sFuncName = "ConnectToTargetCompany()"; if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Starting Function ", sFuncName); if (oCompany != null) { if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Disconnecting the Company object - Company Name " + oCompany.CompanyName, sFuncName); oCompany.Disconnect(); } oCompany = new SAPbobsCOM.Company(); if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("After Initializing Company Connection ", sFuncName); oCompany.Server = sServer; oCompany.LicenseServer = sLicServerName; oCompany.DbUserName = sDBUserName; oCompany.DbPassword = sDBPassword; oCompany.language = SAPbobsCOM.BoSuppLangs.ln_English; oCompany.UseTrusted = false; oCompany.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2012; oCompany.CompanyDB = sDBName;// sDataBaseName; oCompany.UserName = sUserName; oCompany.Password = sPassword; if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Connecting the Database...", sFuncName); lRetCode = oCompany.Connect(); if (lRetCode != 0) { throw new ArgumentException(oCompany.GetLastErrorDescription()); } else { if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Company Connection Established", sFuncName); if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Completed With SUCCESS", sFuncName); return oCompany; } } catch (Exception Ex) { sErrDesc = Ex.Message.ToString(); if (p_iDebugMode == DEBUG_ON) oLog.WriteToErrorLogFile(sErrDesc, sFuncName); if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Completed With ERROR ", sFuncName); throw Ex; } }
public void Add(string strKey, SAPbobsCOM.Company oCompany_S, SAPbobsCOM.Company oCompany_D, string strLogger, string strFromWare, string strToWare, string[] strValues) { DataTable oHeader = null; DataTable oDetails = null; int intTStatus = 0; int intExitStatus = 0; int intEntryStatus = 0; SAPbobsCOM.StockTransfer oStockTransfer = (SAPbobsCOM.StockTransfer)oCompany_S.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oStockTransfer); SAPbobsCOM.Documents oInventoryExit = (SAPbobsCOM.Documents)oCompany_S.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInventoryGenExit); SAPbobsCOM.Documents oInventoryEntry = (SAPbobsCOM.Documents)oCompany_D.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInventoryGenEntry); try { string str_S_OWTR = "Exec Armada_Service_S_OWTR_s '" + strKey + "'"; oDataSet = Singleton.objSqlDataAccess.ExecuteDataSet(str_S_OWTR, strLogger); if (oDataSet == null && oDataSet.Tables.Count == 0) { return; } else { Singleton.traceService("Has Record"); oHeader = oDataSet.Tables[0]; oDetails = oDataSet.Tables[1]; if (oHeader != null && oHeader.Rows.Count > 0) { if (oCompany_S.CompanyDB == oCompany_D.CompanyDB) { Singleton.traceService("Same Company...So Transfer"); oStockTransfer.DocDate = Convert.ToDateTime(oHeader.Rows[0]["TrnDate"].ToString()); oStockTransfer.TaxDate = Convert.ToDateTime(oHeader.Rows[0]["TrnDate"].ToString()); oStockTransfer.FromWarehouse = strFromWare; oStockTransfer.Comments = oHeader.Rows[0]["Remarks"].ToString(); oStockTransfer.UserFields.Fields.Item("U_Z_TrnNum").Value = oHeader.Rows[0]["TrnNum"].ToString(); Singleton.traceService("Set Header"); Singleton.traceService(strFromWare); Singleton.traceService(strToWare); if (oDetails.Rows.Count > 0) { foreach (DataRow dr in oDetails.Rows) { oStockTransfer.Lines.ItemCode = dr["ItemCode"].ToString().Trim(); oStockTransfer.Lines.Quantity = Convert.ToDouble(dr["Qty"].ToString()); //oStockTransfer.Lines.FromWarehouseCode = strFromWare; oStockTransfer.Lines.WarehouseCode = strToWare; oStockTransfer.Lines.Add(); } Singleton.traceService("Set Details"); } Singleton.traceService("Adding"); intTStatus = oStockTransfer.Add(); Singleton.traceService(intTStatus.ToString()); if (intTStatus != 0) { Singleton.objSqlDataAccess.UpdateLog(strKey, TransScenerio.InventoryTransfer.ToString(), "0", "0", 0, oCompany_S.GetLastErrorCode().ToString(), oCompany_S.GetLastErrorDescription().Replace("'", ""), strLogger); } else { string strDkey; int intDocNum = 0; oCompany_S.GetNewObjectCode(out strDkey); if (oStockTransfer.GetByKey(Convert.ToInt32(strDkey))) { intDocNum = oStockTransfer.DocNum; } Singleton.objSqlDataAccess.UpdateLog(strKey, TransScenerio.InventoryTransfer.ToString(), strDkey, intDocNum.ToString(), 1, "", "Armada_Sync Completed Sucessfully", strLogger); } } else { //Singleton.traceService("Inventory Exit Started" + oCompany_S.CompanyDB.ToString()); //Singleton.traceService(strFromWare); //Singleton.traceService(strToWare); oInventoryExit.DocDate = Convert.ToDateTime(oHeader.Rows[0]["TrnDate"].ToString()); oInventoryExit.DocDueDate = Convert.ToDateTime(oHeader.Rows[0]["TrnDate"].ToString()); oInventoryExit.Comments = oHeader.Rows[0]["Remarks"].ToString(); oInventoryExit.UserFields.Fields.Item("U_Z_TrnNum").Value = oHeader.Rows[0]["TrnNum"].ToString(); //oInventoryExit.Reference2 = oHeader.Rows[0]["Ref2"].ToString(); //Singleton.traceService("Set Header"); if (oDetails.Rows.Count > 0) { foreach (DataRow dr in oDetails.Rows) { oInventoryExit.Lines.ItemCode = dr["ItemCode"].ToString(); oInventoryExit.Lines.ItemDescription = dr["ItemDsc"].ToString(); oInventoryExit.Lines.Quantity = Convert.ToDouble(dr["Qty"].ToString()); //oInventoryExit.Lines.ShipDate = Convert.ToDateTime(dr["ShipDate"].ToString()); //oInventoryExit.Lines.UnitPrice = 0; oInventoryExit.Lines.WarehouseCode = strFromWare; oInventoryExit.Lines.AccountCode = strValues[1]; oInventoryExit.Lines.Add(); } } //Singleton.traceService("Set Details"); oCompany_S.StartTransaction(); //Singleton.traceService("Adding"); intExitStatus = oInventoryExit.Add(); //Singleton.traceService("Added"); if (intExitStatus != 0) { //Singleton.traceService(intExitStatus.ToString()); Singleton.objSqlDataAccess.UpdateLog(strKey, TransScenerio.InventoryTransfer.ToString(), "0", "0", 0, intExitStatus.ToString(), oCompany_S.GetLastErrorDescription().Replace("'", ""), strLogger); if (oCompany_S.InTransaction) { oCompany_S.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack); } } else { string strDkey; int intDocNum = 0; oCompany_S.GetNewObjectCode(out strDkey); if (oInventoryExit.GetByKey(Convert.ToInt32(strDkey))) { intDocNum = oInventoryExit.DocNum; } //Singleton.traceService("Exit Success"); //Singleton.traceService(intDocNum.ToString()); //Singleton.traceService("Setting Entry Header"); oInventoryEntry.DocDate = Convert.ToDateTime(oHeader.Rows[0]["TrnDate"].ToString()); oInventoryEntry.DocDueDate = Convert.ToDateTime(oHeader.Rows[0]["TrnDate"].ToString()); oInventoryEntry.Comments = oHeader.Rows[0]["Remarks"].ToString(); //oInventoryEntry.PaymentGroupCode = Convert.ToInt16(strValues[0]); // oInventoryEntry.Reference2 = oHeader.Rows[0]["Ref2"].ToString(); oInventoryEntry.UserFields.Fields.Item("U_Z_TrnNum").Value = oHeader.Rows[0]["TrnNum"].ToString(); if (oDetails.Rows.Count > 0) { //Singleton.traceService("Setting Entry Detials"); foreach (DataRow dr in oDetails.Rows) { oInventoryEntry.Lines.ItemCode = dr["ItemCode"].ToString(); oInventoryEntry.Lines.ItemDescription = dr["ItemDsc"].ToString(); oInventoryEntry.Lines.Quantity = Convert.ToDouble(dr["Qty"].ToString()); // oInventoryEntry.Lines.ShipDate = Convert.ToDateTime(dr["ShipDate"].ToString()); oInventoryEntry.Lines.UnitPrice = Convert.ToDouble(dr["LCPrice"].ToString());; oInventoryEntry.Lines.WarehouseCode = strToWare; oInventoryEntry.Lines.AccountCode = strValues[2]; oInventoryEntry.Lines.Add(); } } oCompany_D.StartTransaction(); //Singleton.traceService("Adding Entry"); intEntryStatus = oInventoryEntry.Add(); if (intEntryStatus != 0) { //Singleton.traceService(intEntryStatus.ToString()); Singleton.objSqlDataAccess.UpdateLog(strKey, TransScenerio.InventoryTransfer.ToString(), "0", "0", 0, intEntryStatus.ToString(), oCompany_D.GetLastErrorDescription().Replace("'", ""), strLogger); if (oCompany_S.InTransaction) { oCompany_S.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack); } if (oCompany_D.InTransaction) { oCompany_D.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack); } } else { if (oCompany_S.InTransaction) { oCompany_S.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_Commit); } if (oCompany_D.InTransaction) { oCompany_D.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_Commit); } Singleton.objSqlDataAccess.UpdateLog(strKey, TransScenerio.InventoryTransfer.ToString(), strDkey, intDocNum.ToString(), 1, "", "Armada_Sync Completed Sucessfully", strLogger); } } } } } } catch (Exception ex) { if (oCompany_S.InTransaction) { oCompany_S.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack); } if (oCompany_D.InTransaction) { oCompany_D.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack); } //Singleton.objSqlDataAccess.UpdateLog(strKey, TransScenerio.InventoryTransfer.ToString(), "0", "0", 0, "0", ex.Message.ToString(), strLogger); throw ex; } finally { System.Runtime.InteropServices.Marshal.ReleaseComObject(oStockTransfer); System.Runtime.InteropServices.Marshal.ReleaseComObject(oInventoryExit); System.Runtime.InteropServices.Marshal.ReleaseComObject(oInventoryEntry); } }
public void SBO_Application_ServerInvokeCompletedEvent(ref B1iEvent B1iEvent, SAPbobsCOM.Company sbo_company, ref Application sbo_application, out bool bBubbleEvent) { bBubbleEvent = true; }
private int SetConnectionContext() { int setConnectionContextReturn = 0; string sCookie = null; string sConnectionContext = null; int lRetCode = 0; oCompany = new SAPbobsCOM.Company(); sCookie = oCompany.GetContextCookie(); sConnectionContext = SBO_Application.Company.GetConnectionContext(sCookie); if (oCompany.Connected == true) { oCompany.Disconnect(); } setConnectionContextReturn = oCompany.SetSboLoginContext(sConnectionContext); return setConnectionContextReturn; }
public string CloseCase(string sCaseNo, string sUserRole, string sStatus, string sKIV) { string sFuncName = "CloseCase"; string sSql = string.Empty; SAPbobsCOM.Recordset oRecSet; string sResult = string.Empty; double lRetCode = 0; try { if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Starting Function ", sFuncName); if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Connecting to target company ", sFuncName); oDICompany = oLogin.ConnectToTargetCompany(ConnectionString); if (sStatus == "CLOSED") { sSql = "EXEC AE_UPDATECASESTATUS '" + sCaseNo + "','" + sUserRole + "'"; oRecSet = oDICompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); oRecSet.DoQuery(sSql); if (oRecSet.RecordCount > 0) { sResult = oRecSet.Fields.Item("Result").Value; } } else { SAPbobsCOM.BusinessPartners oBP = (SAPbobsCOM.BusinessPartners)(oDICompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oBusinessPartners)); oBP.GetByKey(sCaseNo); if (sStatus.ToString() != strSelect.ToString()) { oBP.UserFields.Fields.Item("U_CASESTATUS").Value = sStatus.ToString(); } oBP.UserFields.Fields.Item("U_KIVSTATUS").Value = sKIV.ToString(); lRetCode = oBP.Update(); if (lRetCode == 0) { if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Case Header details Updated Successfully ", sFuncName); } sResult = "SUCCESS"; } if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Completed With SUCCESS ", sFuncName); return sResult; } catch (Exception Ex) { sErrDesc = Ex.Message.ToString(); oLog.WriteToErrorLogFile(sErrDesc, sFuncName); if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Completed With ERROR ", sFuncName); throw Ex; } }
//public DataSet SPA_ProcessCase_GetNextSection(string sCaseNo) //{ // DataSet oDataset = new DataSet(); // DataSet oDataset1 = new DataSet(); // string sFuncName = string.Empty; // string sProcName = string.Empty; // string sProcName1 = string.Empty; // DataView oDTView = new DataView(); // string sCanClose = string.Empty; // try // { // sFuncName = "SPA_ProcessCase_GetNextSection()"; // sProcName = "getNextSection"; // sProcName1 = "canCloseCurrentSection"; // if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Starting Function ", sFuncName); // if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Calling Run_StoredProcedure() " + sProcName1, sFuncName); // oDataset1 = SqlHelper.ExecuteDataSet(ConnectionString, CommandType.StoredProcedure, sProcName1, // Data.CreateParameter("@caseNo", sCaseNo)); // if (oDataset1 != null && oDataset1.Tables.Count > 0) // { // if (oDataset1.Tables[0].Rows.Count > 0) // { // sCanClose = oDataset1.Tables[0].Rows[0][0].ToString(); // } // } // if (sCanClose == "Y") // { // } // if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Calling Run_StoredProcedure() " + sProcName, sFuncName); // oDataset = SqlHelper.ExecuteDataSet(ConnectionString, CommandType.StoredProcedure, sProcName, // Data.CreateParameter("@caseNo", sCaseNo)); // if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Completed With SUCCESS ", sFuncName); // if (oDataset.Tables.Count > 0 && oDataset != null) // { // if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("There is a set of data from the SP :" + sProcName, sFuncName); // return oDataset; // } // else // { // if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("There is no data from the SP :" + sProcName, sFuncName); // return oDataset; // } // } // catch (Exception Ex) // { // sErrDesc = Ex.Message.ToString(); // oLog.WriteToErrorLogFile(sErrDesc, sFuncName); // if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Completed With ERROR ", sFuncName); // throw Ex; // } //} public DataSet SPA_ProcessCase_GetNextSection(string sCaseNo) { DataSet oDataset = new DataSet(); DataSet oDataset1 = new DataSet(); DataSet oDataset2 = new DataSet(); string sFuncName = string.Empty; string sProcName = string.Empty; string sProcName1 = string.Empty; DataView oDTView = new DataView(); string sCanClose = string.Empty; string sProcName2 = string.Empty; try { sFuncName = "SPA_ProcessCase_GetNextSection()"; sProcName = "getNextSection"; sProcName1 = "canCloseCurrentSection"; sProcName2 = "getOpenSection"; if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Starting Function ", sFuncName); if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Calling Run_StoredProcedure() " + sProcName1, sFuncName); oDataset1 = SqlHelper.ExecuteDataSet(ConnectionString, CommandType.StoredProcedure, sProcName1, Data.CreateParameter("@caseNo", sCaseNo)); if (oDataset1 != null && oDataset1.Tables.Count > 0) { if (oDataset1.Tables[0].Rows.Count > 0) { sCanClose = oDataset1.Tables[0].Rows[0][0].ToString(); } } if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Connecting to target company ", sFuncName); oDICompany = oLogin.ConnectToTargetCompany(ConnectionString); if (sCanClose == "Y") { SAPbobsCOM.Documents oSalesQuote; SAPbobsCOM.Recordset oRecSet; string sSql; int iSalQuoteEntry; int iItemLine; oSalesQuote = oDICompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oQuotations); oRecSet = oDICompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); oDICompany.StartTransaction(); sSql = "SELECT A.DocEntry,B.VisOrder FROM OQUT A WITH (NOLOCK) INNER JOIN QUT1 B WITH (NOLOCK) ON B.DocEntry = A.DocEntry WHERE CardCode = '" + sCaseNo + "' AND B.ItemCode <> '" + strItemCode + "' AND DocStatus = 'O'"; oRecSet.DoQuery(sSql); if (oRecSet.RecordCount > 0) { while (!oRecSet.EoF) { iSalQuoteEntry = Convert.ToInt16(oRecSet.Fields.Item("DocEntry").Value); iItemLine = Convert.ToInt16(oRecSet.Fields.Item("VisOrder").Value); if (oSalesQuote.GetByKey(Convert.ToInt16(iSalQuoteEntry))) { oSalesQuote.Lines.SetCurrentLine(Convert.ToInt16(iItemLine)); oSalesQuote.Lines.LineStatus = SAPbobsCOM.BoStatus.bost_Close; if (oSalesQuote.Update() != 0) { if (oDICompany.InTransaction == true) { oDICompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack); } else { oDICompany.StartTransaction(); oDICompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack); } sErrDesc = oDICompany.GetLastErrorDescription(); throw new ArgumentException(sErrDesc); } } oRecSet.MoveNext(); } } oDICompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_Commit); if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Calling Run_StoredProcedure() " + sProcName, sFuncName); oDataset = SqlHelper.ExecuteDataSet(ConnectionString, CommandType.StoredProcedure, sProcName, Data.CreateParameter("@caseNo", sCaseNo)); if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Completed With SUCCESS ", sFuncName); if (oDataset.Tables.Count > 0 && oDataset != null) { if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("There is a set of data from the SP :" + sProcName, sFuncName); if (CreateSalesQuote(oDataset.Tables[0], oDICompany) == "SUCCESS") { if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Calling Run_StoredProcedure() " + sProcName2, sFuncName); oDataset2 = SqlHelper.ExecuteDataSet(ConnectionString, CommandType.StoredProcedure, sProcName2, Data.CreateParameter("@caseNo", sCaseNo)); } oDataset = oDataset2; } } else { if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("There is no data from the SP :" + sProcName, sFuncName); } return oDataset; } catch (Exception Ex) { sErrDesc = Ex.Message.ToString(); oLog.WriteToErrorLogFile(sErrDesc, sFuncName); if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Completed With ERROR ", sFuncName); throw Ex; } }
private static void Main(string[] args) { string AddOn = AppDomain.CurrentDomain.FriendlyName.Replace(".exe", ""); string User = Environment.UserName + "." + Environment.UserDomainName; string PId = System.Diagnostics.Process.GetCurrentProcess().Id.ToString(); string Path = $"C:\\ProgramData\\SAP\\SAP Business One\\Log\\{AddOn}\\{User}"; LogFile = $"{Path}\\Addon.{DateTime.Now.ToString("yyyyMMdd_HH.mm.ss")}.pid{PId}.log.csv"; try { if (!Directory.Exists(Path)) { Directory.CreateDirectory(Path); } System.Threading.Tasks.Task.Run(() => CommonFunctions.DeleteOldLogFiles(Path)); SAPbouiCOM.Framework.Application oApp = null; if (args.Length < 1) { oApp = new SAPbouiCOM.Framework.Application(); } else { oApp = new SAPbouiCOM.Framework.Application(args[0]); } sbo_application = SAPbouiCOM.Framework.Application.SBO_Application; sbo_company = (SAPbobsCOM.Company)sbo_application.Company.GetDICompany(); oNumberFormatInfo.NumberDecimalSeparator = sbo_company.GetCompanyService().GetAdminInfo().DecimalSeparator; oNumberFormatInfo.NumberGroupSeparator = sbo_company.GetCompanyService().GetAdminInfo().ThousandsSeparator; RemoveMenus(); AddMenuItems(); sbo_application.MenuEvent += new SAPbouiCOM._IApplicationEvents_MenuEventEventHandler(SBO_Application_MenuEvent); sbo_application.AppEvent += new SAPbouiCOM._IApplicationEvents_AppEventEventHandler(SBO_Application_AppEvent); sbo_application.ItemEvent += new SAPbouiCOM._IApplicationEvents_ItemEventEventHandler(SBO_Application_ItemEvent); sbo_application.FormDataEvent += new SAPbouiCOM._IApplicationEvents_FormDataEventEventHandler(SBO_Application_FormDataEvent); sbo_application.ReportDataEvent += new SAPbouiCOM._IApplicationEvents_ReportDataEventEventHandler(SBO_Application_ReportDataEvent); sbo_application.PrintEvent += new SAPbouiCOM._IApplicationEvents_PrintEventEventHandler(SBO_Application_PrintEvent); sbo_application.RightClickEvent += new SAPbouiCOM._IApplicationEvents_RightClickEventEventHandler(SBO_Application_RightClickEvent); sbo_application.ProgressBarEvent += new SAPbouiCOM._IApplicationEvents_ProgressBarEventEventHandler(SBO_Application_ProgressBarEvent); sbo_application.StatusBar.SetText(string.Format("Revisando la estructura de la base de datos"), SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning); //System.Threading.Tasks.Task.Run(() => LoadUserTablesMDToXmlFile(AddonNamespace)); //System.Threading.Tasks.Task.Run(() => LoadUserFieldMDToXmlFile(AddonNamespace)); //System.Threading.Tasks.Task.Run(() => LoadUserObjectsMDToXmlFile(AddonNamespace)); //try { LoadUserTablesMDFromXmlFile(UserTablesFile); } catch (Exception e) { sbo_application.StatusBar.SetText(e.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning); } //try { LoadUserFieldMDFromXmlFile(UserFieldsFile); } catch (Exception e) { sbo_application.StatusBar.SetText(e.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning); } //try { LoadUserObjectMDFromXmlFile(UserObjectsFile); } catch (Exception e) { sbo_application.StatusBar.SetText(e.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning); } sbo_application.StatusBar.SetText(string.Format("Revision completada"), SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success); sbo_application.StatusBar.SetText($"Addon {AddOnName} conectado", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success); #if DEBUG sbo_application.StatusBar.SetText(string.Format("{0} = {1}", DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"), "Conectando al SL"), SAPbouiCOM.BoMessageTime.bmt_Medium, SAPbouiCOM.BoStatusBarMessageType.smt_Warning); #endif try { sessionId = sbo_application.Company.GetServiceLayerConnectionContext(ServiceLayer.Address); } catch { ShowInputDialog(ref UsrPass); if (string.IsNullOrEmpty(UsrPass)) { sbo_application.MessageBox("Debe ingresar su contraseña SAP, salga y vuelva a entrar"); Environment.Exit(0); } var log = new Login { CompanyDB = sbo_company.CompanyDB, UserName = sbo_company.UserName, Password = UsrPass }; sessionId = CommonFunctions.POST(ServiceLayer.Login, log, null, out System.Net.HttpStatusCode statusCode); if (statusCode != System.Net.HttpStatusCode.OK) { sbo_application.MessageBox("Clave incorrecta, salga y vuelva a entrar"); Environment.Exit(0); } } #if DEBUG sbo_application.StatusBar.SetText(string.Format("{0} = {1}", DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"), "SL conectado"), SAPbouiCOM.BoMessageTime.bmt_Medium, SAPbouiCOM.BoStatusBarMessageType.smt_Warning); #endif oApp.Run(); } catch (Exception ex) { CommonFunctions.LogFile(LogFile, ex.Message); MessageBox.Show(ex.Message); } }
public void setCompany(ref SAPbobsCOM.Company oCompany) { this.oCompany = oCompany; }
public ediciones() { oApp = (SAPbouiCOM.Application)Application.SBO_Application; oCompany = (SAPbobsCOM.Company)oApp.Company.GetDICompany(); }
//Methods public void Doit(ref int nErr, ref string sErr) { if (oCompany == null) { oCompany = new SAPbobsCOM.Company(); } if (!oCompany.Connected) { ConnectSBO(ref nErr, ref sErr); if (nErr != 0) { oLog.LogMsg(sErr, "F", "E"); return; } else { oLog.LogMsg("Connected to SAP", "F", "D"); } } //if (Llacolen_SBOService.Properties.Settings.Default.BatchMySQLType == "SQLServer") //{ // if (BDBatchSQLServer == null) // BDBatchSQLServer = new System.Data.SqlClient.SqlConnection(); // if ((BDBatchSQLServer.State == System.Data.ConnectionState.Closed) | (BDBatchSQLServer.State == System.Data.ConnectionState.Broken)) // { // ConnectBDBatchSQLServer(ref nErr, ref sErr); // if (nErr != 0) // { // oLog.LogMsg(sErr, "F", "E"); // return; // } // } //} //else //{ //if (BDBatchMySQL == null) // BDBatchMySQL = new MySqlConnection(); //if ((BDBatchMySQL.State == System.Data.ConnectionState.Closed) | (BDBatchMySQL.State == System.Data.ConnectionState.Broken)) //{ // ConnectBDBatchMySQL(ref nErr, ref sErr); // if (nErr != 0) // { // oLog.LogMsg(sErr, "F", "E"); // return; // } // else // { // oLog.LogMsg("Connected to MYSQL", "F", "D"); // } //} //} oRecordSet = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); LlacolenDocs SincDocs = new LlacolenDocs(); SincDocs.oCompany = oCompany; // SincDocs.oBDBatchMySQL = conexionMysql; SincDocs.oLog = FLog; SincDocs.oRecordSet = oRecordSet; SincDocs.InitVars(); conexionMysql = new ConexionMysql(); conexionMysql.oLog = FLog; oLog.LogMsg("------------------PROCESO 1-----------------------", "F", "E"); oLog.LogMsg("Bloqueo/desbloqueo de socios en base a pagos, iniciado.", "F", "E"); SincDocs.Sincronizar_PagosSAP_en_MySQL(); oLog.LogMsg("------------------PROCESO 2-----------------------", "F", "E"); oLog.LogMsg("Actualizar tickets e ingresar socios nuevos a punto, iniciado.", "F", "E"); SincDocs.ActualizarSocios_MySQL(); oLog.LogMsg("------------------PROCESO 3-----------------------", "F", "E"); oLog.LogMsg("Actualizar cupos desde punto, iniciado.", "F", "E"); SincDocs.ActualizarCuposBP_SBO(); oLog.LogMsg("Finaliza actualización.", "F", "E"); }
public void ConnectAllSapCompany() { try { SAPbobsCOM.Company oCompany = null; oCompanyht = new Hashtable(); string strMaiDB = System.Configuration.ConfigurationManager.AppSettings["MainDB"].ToString(); string DBServer = System.Configuration.ConfigurationManager.AppSettings["SAPServer"].ToString(); string ServerType = System.Configuration.ConfigurationManager.AppSettings["DbServerType"].ToString(); string DBUserName = System.Configuration.ConfigurationManager.AppSettings["DbUserName"].ToString(); string DBPwd = System.Configuration.ConfigurationManager.AppSettings["DbPassword"].ToString(); string LicenseServer = System.Configuration.ConfigurationManager.AppSettings["SAPlicense"].ToString(); sQuery = " SELECT U_COMPANY,U_SAPUSERNAME,U_SAPPASSWORD FROM [@Z_INBOUNDMAPPING] "; string ConnectionString = String.Format(System.Configuration.ConfigurationManager.AppSettings["Logger"].ToString(), strMaiDB); DataSet oDS = Singleton.objSqlDataAccess.ExecuteDataSet(sQuery, strMaiDB); if (oDS != null) { DataTable oDT_C = oDS.Tables[0]; int intCompany = oDT_C.Rows.Count; objCompany = new SAPbobsCOM.Company[intCompany]; int intCompCount = 0; foreach (DataRow dr_company in oDT_C.Rows) { //StatusLabel.Text = "Connecting SAP Business One Company : " + dr_company["U_COMPANY"].ToString(); oCompany = new SAPbobsCOM.Company(); oCompany.Server = DBServer; switch (ServerType) { case "2008": oCompany.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2008; break; case "2012": oCompany.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2012; break; default: break; } oCompany.DbUserName = DBUserName; oCompany.DbPassword = DBPwd; oCompany.CompanyDB = dr_company["U_COMPANY"].ToString(); oCompany.UserName = dr_company["U_SAPUSERNAME"].ToString(); oCompany.Password = dr_company["U_SAPPASSWORD"].ToString(); oCompany.UseTrusted = false; if (oCompany.Connect() != 0) { objCompany[intCompCount] = oCompany; oCompanyht.Add(dr_company["U_COMPANY"].ToString(), oCompany); traceService("Company : " + oCompany.CompanyDB); traceService("Error Code : " + oCompany.GetLastErrorDescription()); } else { objCompany[intCompCount] = oCompany; oCompanyht.Add(dr_company["U_COMPANY"].ToString(), oCompany); traceService("Company : " + oCompany.CompanyDB); traceService("Connected"); } intCompCount += 1; } } } catch (Exception ex) { traceService(ex.StackTrace.ToString()); traceService(ex.Message.ToString()); throw; } }
public void SBO_Application_PrintEvent(ref PrintEventInfo printeventInfo, SAPbobsCOM.Company sbo_company, ref Application sbo_application, out bool bBubbleEvent) { bBubbleEvent = true; }
public string SPA_ProcessCase_Save(DataTable dt) { string sFuncName = "SPA_ProcessCase_Save"; string sDocType = string.Empty; string sQuoteEntry = string.Empty; string sItemLine = string.Empty; string sUserRole = string.Empty; SAPbobsCOM.Documents oSalesQuote; string sRemarks = string.Empty; string sItemCode = string.Empty; string sVisOrder = string.Empty; string sResult = string.Empty; try { if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Starting Function ", sFuncName); if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Connecting to target company ", sFuncName); oDICompany = oLogin.ConnectToTargetCompany(ConnectionString); foreach (DataRow iRow in dt.Rows) { sDocType = Convert.ToString(iRow["TrnspName"]); sQuoteEntry = Convert.ToString(iRow["DocEntry"]); sItemLine = Convert.ToString(iRow["LineNum"]); sUserRole = Convert.ToString(iRow["ActionBy"]); sRemarks = Convert.ToString(iRow["Remarks"]); sItemCode = Convert.ToString(iRow["ItemCode"]); oSalesQuote = oDICompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oQuotations); if ((sDocType == "ADD-PO-D") || (sDocType == "ADD-PO") || (sDocType == "SDOC") || (sDocType == "TDOC") || (sDocType == "FWDOC") || (sDocType == "MANUAL-FIN") || (sDocType == "MANUAL-FIN-C") || (sDocType == "MANUAL-IC") || (sDocType == "FEES")) { //NEEDED SALES QUOT DOCENTRY,DOCNUM,ITEM LINENUM TO UPDATE REMARKS //NEEDED USER ROLE TO UPDATE if (oSalesQuote.GetByKey(Convert.ToInt16(sQuoteEntry))) { oSalesQuote.Lines.SetCurrentLine(Convert.ToInt16(sItemLine)); if (sUserRole == "MG") { oSalesQuote.Lines.UserFields.Fields.Item("U_MG_REMARKS").Value = sRemarks; oSalesQuote.Lines.UserFields.Fields.Item("U_PROCESS_LAST_UPDAT").Value = DateTime.Now.Date; } else if (sUserRole == "LA") { oSalesQuote.Lines.UserFields.Fields.Item("U_LA_REMARKS").Value = sRemarks; oSalesQuote.Lines.UserFields.Fields.Item("U_PROCESS_LAST_UPDAT").Value = DateTime.Now.Date; } else if (sUserRole == "PN") { oSalesQuote.Lines.UserFields.Fields.Item("U_PT_REMARKS").Value = sRemarks; oSalesQuote.Lines.UserFields.Fields.Item("U_PROCESS_LAST_UPDAT").Value = DateTime.Now.Date; } if (oSalesQuote.Update() != 0) { sErrDesc = oDICompany.GetLastErrorDescription(); throw new ArgumentException(sErrDesc); } else { sResult = "SUCCESS"; } } } } if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Completed With SUCCESS ", sFuncName); } catch (Exception ex) { sErrDesc = ex.Message.ToString(); oLog.WriteToErrorLogFile(sErrDesc, sFuncName); if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Completed With ERROR ", sFuncName); throw ex; } return sResult; }
public void SBO_Application_ReportDataEvent(ref ReportDataInfo reportDataInfo, SAPbobsCOM.Company sbo_company, ref Application sbo_application, out bool bBubbleEvent) { bBubbleEvent = true; }
public string SPA_ProcessCase_SaveOptionalItems(DataTable oDTSQData) { // This method is to create the sales Quotation line items for the Optional Items string sReturnResult = string.Empty; string sFuncName = string.Empty; SAPbobsCOM.Documents oSalesQuotation; int lRetCode; string sSql = string.Empty; SAPbobsCOM.Recordset oRecSet; try { sFuncName = "Add_SalesQuotation()"; if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Starting Function ", sFuncName); if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Connecting to target company ", sFuncName); oDICompany = oLogin.ConnectToTargetCompany(ConnectionString); oSalesQuotation = oDICompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oQuotations); DataRow iRow = oDTSQData.Rows[0]; sSql = "SELECT ItemCode FROM QUT1 WITH (NOLOCK) WHERE ItemCode = '" + iRow["ItemCode"].ToString() + "' and DocEntry in (select DocEntry from OQUT WITH (NOLOCK) where CardCode = '" + iRow["CaseNo"].ToString() + "')"; oRecSet = oDICompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); oRecSet.DoQuery(sSql); if (oRecSet.RecordCount > 0) { sReturnResult = "Sales Quotation line is already exists in the cardcode"; if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Sales Quotation line is already exists for this cardcode", sFuncName); } else { sSql = "select DocEntry from OQUT WITH (NOLOCK) where CardCode = '" + iRow["CaseNo"].ToString() + "'"; oRecSet = oDICompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); oRecSet.DoQuery(sSql); var docEntry = string.Empty; if (oRecSet.RecordCount > 0) { docEntry = Convert.ToString(oRecSet.Fields.Item("DocEntry").Value); } oSalesQuotation.GetByKey(Convert.ToInt32(docEntry)); //oSalesQuotation.CardCode = iRow["CaseNo"].ToString(); //oSalesQuotation.DocDate = DateTime.Now.Date; //oSalesQuotation.TaxDate = DateTime.Now.Date; //oSalesQuotation.DocDueDate = DateTime.Now.Date; double iCount = 0; int sumOfQty = 0; if (Convert.ToDouble(iRow["Qty"]) > 0) { sSql = "SELECT TOP 1 U_INT_CASE_SEQ [IntNo] FROM QUT1 WITH (NOLOCK) WHERE DocEntry in (select DocEntry from OQUT WITH (NOLOCK) where CardCode = '" + iRow["CaseNo"].ToString() + "') and LineStatus = 'O' and U_INT_CASE_SEQ <> 0"; oRecSet = oDICompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); oRecSet.DoQuery(sSql); int SeqNo = 0; if (oRecSet.RecordCount > 0) { SeqNo = Convert.ToInt32(oRecSet.Fields.Item("IntNo").Value); } oSalesQuotation.Lines.Add(); oSalesQuotation.Lines.ItemCode = Convert.ToString(iRow["ItemCode"]); oSalesQuotation.Lines.Quantity = Convert.ToInt32(iRow["Qty"]); oSalesQuotation.Lines.Price = Convert.ToDouble(iRow["Price"]); oSalesQuotation.Lines.UserFields.Fields.Item("U_STEP_CREATION_DT").Value = DateTime.Now.Date; oSalesQuotation.Lines.UserFields.Fields.Item("U_STATUS").Value = "PENDING"; oSalesQuotation.Lines.UserFields.Fields.Item("U_NEXT_ACTION_BY").Value = Convert.ToString(iRow["ACTIONBY"]); oSalesQuotation.Lines.UserFields.Fields.Item("U_INT_CASE_SEQ").Value = Convert.ToString(SeqNo); iCount = iCount + 1; sumOfQty = sumOfQty + Convert.ToInt32(iRow["Qty"]); } if (sumOfQty > 0) { lRetCode = oSalesQuotation.Update(); if (lRetCode != 0) { sErrDesc = oDICompany.GetLastErrorDescription(); sReturnResult = sErrDesc.ToString(); throw new ArgumentException(sErrDesc); } else { sReturnResult = "SUCCESS"; if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Completed With SUCCESS ", sFuncName); } } else { sReturnResult = ""; } } } catch (Exception Ex) { sErrDesc = Ex.Message.ToString(); oLog.WriteToErrorLogFile(sErrDesc, sFuncName); if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Completed With ERROR ", sFuncName); throw Ex; } return sReturnResult; }
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,T1.U_OUTACCT 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); strValues[0] = oCompDT.Rows[0][2].ToString(); } } 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_ORIN.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()); } }
public string SPA_ProcessCase_UpdateCaseTabDetails(string sTabId, DataTable dtHeader, DataTable dtDetails, DataTable dtPurchaser, DataTable dtVendor, DataTable dtProperty, DataTable dtLoanPrinciple, DataTable dtLoanSubsidary) { DataSet oDataset = new DataSet(); string sFuncName = string.Empty; string sProcName = string.Empty; DataView oDTView = new DataView(); string sResult = string.Empty; string sCardCode = string.Empty; string sDocEntry = string.Empty; double lRetCode; try { sFuncName = "SPA_ProcessCase_UpdateCaseTabDetails()"; if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Starting Function ", sFuncName); // Note : Based on the Header table TabId, need to Update the data's in SAP. if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Connecting to target company ", sFuncName); oDICompany = oLogin.ConnectToTargetCompany(ConnectionString); //DataRow drHeader = dtHeader.Rows[0]; sCardCode = dtHeader.Rows[0]["Case"].ToString(); SAPbobsCOM.BusinessPartners oBP = (SAPbobsCOM.BusinessPartners)(oDICompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oBusinessPartners)); if (sTabId == "2")// Update Purchaser tab details { DataRow dr = dtPurchaser.Rows[0]; oBP.GetByKey(sCardCode); oBP.UserFields.Fields.Item("U_SPADATE").Value = dr["PurSPADate"]; oBP.UserFields.Fields.Item("U_PRVTCAVEATENTRYDT").Value = dr["PurEntryOfPrivateCaveat"]; oBP.UserFields.Fields.Item("U_PRVTCAVEATWITHDWDT").Value = dr["PurWithOfPrivateCaveat"]; oBP.UserFields.Fields.Item("U_PURCH_RP_NAME1").Value = dr["PurFirstName"]; oBP.UserFields.Fields.Item("U_PURCH_RP_ID1").Value = dr["PurFirstID"]; oBP.UserFields.Fields.Item("U_PURCH_RP_TAX1").Value = dr["PurFirstTaxNo"]; oBP.UserFields.Fields.Item("U_PURCH_CONTACT1").Value = dr["PurFirstContactNo"]; if (dr["PurFirstName"].ToString() == string.Empty && dr["PurFirstType"].ToString() == strSelect.ToString()) { oBP.UserFields.Fields.Item("U_PURCH_IDTYPE1").Value = string.Empty; } else if (dr["PurFirstName"].ToString() == string.Empty && dr["PurFirstType"].ToString() != strSelect.ToString()) { oBP.UserFields.Fields.Item("U_PURCH_IDTYPE1").Value = string.Empty; } else if (dr["PurFirstName"].ToString() != string.Empty && dr["PurFirstType"].ToString() == strSelect.ToString()) { oBP.UserFields.Fields.Item("U_PURCH_IDTYPE1").Value = "INDIVIDUAL"; } else { oBP.UserFields.Fields.Item("U_PURCH_IDTYPE1").Value = dr["PurFirstType"].ToString(); } oBP.UserFields.Fields.Item("U_PURCH_RP_NAME2").Value = dr["PurSecName"]; oBP.UserFields.Fields.Item("U_PURCH_RP_ID2").Value = dr["PurSecID"]; oBP.UserFields.Fields.Item("U_PURCH_RP_TAX2").Value = dr["PurSecTaxNo"]; oBP.UserFields.Fields.Item("U_PURCH_CONTACT2").Value = dr["PurSecContactNo"]; if (dr["PurSecName"].ToString() == string.Empty && dr["PurSecType"].ToString() == strSelect.ToString()) { oBP.UserFields.Fields.Item("U_PURCH_IDTYPE2").Value = string.Empty; } else if (dr["PurSecName"].ToString() == string.Empty && dr["PurSecType"].ToString() != strSelect.ToString()) { oBP.UserFields.Fields.Item("U_PURCH_IDTYPE2").Value = string.Empty; } else if (dr["PurSecName"].ToString() != string.Empty && dr["PurSecType"].ToString() == strSelect.ToString()) { oBP.UserFields.Fields.Item("U_PURCH_IDTYPE2").Value = "INDIVIDUAL"; } else { oBP.UserFields.Fields.Item("U_PURCH_IDTYPE2").Value = dr["PurSecType"].ToString(); } oBP.UserFields.Fields.Item("U_PURCH_RP_NAME3").Value = dr["PurThirdName"]; oBP.UserFields.Fields.Item("U_PURCH_RP_ID3").Value = dr["PurThirdID"]; oBP.UserFields.Fields.Item("U_PURCH_RP_TAX3").Value = dr["PurThirdTaxNo"]; oBP.UserFields.Fields.Item("U_PURCH_CONTACT3").Value = dr["PurThirdContactNo"]; if (dr["PurThirdName"].ToString() == string.Empty && dr["PurThirdType"].ToString() == strSelect.ToString()) { oBP.UserFields.Fields.Item("U_PURCH_IDTYPE3").Value = string.Empty; } else if (dr["PurThirdName"].ToString() == string.Empty && dr["PurThirdType"].ToString() != strSelect.ToString()) { oBP.UserFields.Fields.Item("U_PURCH_IDTYPE3").Value = string.Empty; } else if (dr["PurThirdName"].ToString() != string.Empty && dr["PurThirdType"].ToString() == strSelect.ToString()) { oBP.UserFields.Fields.Item("U_PURCH_IDTYPE3").Value = "INDIVIDUAL"; } else { oBP.UserFields.Fields.Item("U_PURCH_IDTYPE3").Value = dr["PurThirdType"].ToString(); } oBP.UserFields.Fields.Item("U_PURCH_RP_NAME4").Value = dr["PurFourthName"]; oBP.UserFields.Fields.Item("U_PURCH_RP_ID4").Value = dr["PurFourthID"]; oBP.UserFields.Fields.Item("U_PURCH_RP_TAX4").Value = dr["PurFourthTaxNo"]; oBP.UserFields.Fields.Item("U_PURCH_CONTACT4").Value = dr["PurFourthContactNo"]; if (dr["PurFourthName"].ToString() == string.Empty && dr["PurFourthType"].ToString() == strSelect.ToString()) { oBP.UserFields.Fields.Item("U_PURCH_IDTYPE4").Value = string.Empty; } else if (dr["PurFourthName"].ToString() == string.Empty && dr["PurFourthType"].ToString() != strSelect.ToString()) { oBP.UserFields.Fields.Item("U_PURCH_IDTYPE4").Value = string.Empty; } else if (dr["PurFourthName"].ToString() != string.Empty && dr["PurFourthType"].ToString() == strSelect.ToString()) { oBP.UserFields.Fields.Item("U_PURCH_IDTYPE4").Value = "INDIVIDUAL"; } else { oBP.UserFields.Fields.Item("U_PURCH_IDTYPE4").Value = dr["PurFourthType"].ToString(); } lRetCode = oBP.Update(); if (lRetCode == 0) { if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Purchaser tab details Updated Successfully ", sFuncName); } sResult = "SUCCESS"; } else if (sTabId == "3")// Update Vendor tab details { DataRow dr = dtVendor.Rows[0]; oBP.GetByKey(sCardCode); oBP.UserFields.Fields.Item("U_REQ_DEV_CONSENT").Value = dr["VndrReqDevConsent"]; oBP.UserFields.Fields.Item("U_RECV_DEV_CONSENT").Value = dr["VndrReceiveDevConsent"]; oBP.UserFields.Fields.Item("U_VNDR_RP_NAME1").Value = dr["VndrFirstName"]; oBP.UserFields.Fields.Item("U_VNDR_RP_ID1").Value = dr["VndrFirstID"]; oBP.UserFields.Fields.Item("U_VNDR_RP_TAX1").Value = dr["VndrFirstTaxNo"]; oBP.UserFields.Fields.Item("U_VNDR_CONTACT1").Value = dr["VndrFirstContactNo"]; if (dr["VndrFirstName"].ToString() == string.Empty && dr["VndrFirstType"].ToString() == strSelect.ToString()) { oBP.UserFields.Fields.Item("U_VNDR_IDTYPE1").Value = string.Empty; } else if (dr["VndrFirstName"].ToString() == string.Empty && dr["VndrFirstType"].ToString() != strSelect.ToString()) { oBP.UserFields.Fields.Item("U_VNDR_IDTYPE1").Value = string.Empty; } else if (dr["VndrFirstName"].ToString() != string.Empty && dr["VndrFirstType"].ToString() == strSelect.ToString()) { oBP.UserFields.Fields.Item("U_VNDR_IDTYPE1").Value = "INDIVIDUAL"; } else { oBP.UserFields.Fields.Item("U_VNDR_IDTYPE1").Value = dr["VndrFirstType"].ToString(); } oBP.UserFields.Fields.Item("U_VNDR_RP_NAME2").Value = dr["VndrSecName"]; oBP.UserFields.Fields.Item("U_VNDR_RP_ID2").Value = dr["VndrSecID"]; oBP.UserFields.Fields.Item("U_VNDR_RP_TAX2").Value = dr["VndrSecTaxNo"]; oBP.UserFields.Fields.Item("U_VNDR_CONTACT2").Value = dr["VndrSecContactNo"]; if (dr["VndrSecName"].ToString() == string.Empty && dr["VndrSecType"].ToString() == strSelect.ToString()) { oBP.UserFields.Fields.Item("U_VNDR_IDTYPE2").Value = string.Empty; } else if (dr["VndrSecName"].ToString() == string.Empty && dr["VndrSecType"].ToString() != strSelect.ToString()) { oBP.UserFields.Fields.Item("U_VNDR_IDTYPE2").Value = string.Empty; } else if (dr["VndrSecName"].ToString() != string.Empty && dr["VndrSecType"].ToString() == strSelect.ToString()) { oBP.UserFields.Fields.Item("U_VNDR_IDTYPE2").Value = "INDIVIDUAL"; } else { oBP.UserFields.Fields.Item("U_VNDR_IDTYPE2").Value = dr["VndrSecType"].ToString(); } oBP.UserFields.Fields.Item("U_VNDR_RP_NAME3").Value = dr["VndrThirdName"]; oBP.UserFields.Fields.Item("U_VNDR_RP_ID3").Value = dr["VndrThirdID"]; oBP.UserFields.Fields.Item("U_VNDR_RP_TAX3").Value = dr["VndrThirdTaxNo"]; oBP.UserFields.Fields.Item("U_VNDR_CONTACT3").Value = dr["VndrThirdContactNo"]; if (dr["VndrThirdName"].ToString() == string.Empty && dr["VndrThirdType"].ToString() == strSelect.ToString()) { oBP.UserFields.Fields.Item("U_VNDR_IDTYPE3").Value = string.Empty; } else if (dr["VndrThirdName"].ToString() == string.Empty && dr["VndrThirdType"].ToString() != strSelect.ToString()) { oBP.UserFields.Fields.Item("U_VNDR_IDTYPE3").Value = string.Empty; } else if (dr["VndrThirdName"].ToString() != string.Empty && dr["VndrThirdType"].ToString() == strSelect.ToString()) { oBP.UserFields.Fields.Item("U_VNDR_IDTYPE3").Value = "INDIVIDUAL"; } else { oBP.UserFields.Fields.Item("U_VNDR_IDTYPE3").Value = dr["VndrThirdType"].ToString(); } oBP.UserFields.Fields.Item("U_VNDR_RP_NAME4").Value = dr["VndrFourthName"]; oBP.UserFields.Fields.Item("U_VNDR_RP_ID4").Value = dr["VndrFourthID"]; oBP.UserFields.Fields.Item("U_VNDR_RP_TAX4").Value = dr["VndrFourthTaxNo"]; oBP.UserFields.Fields.Item("U_VNDR_CONTACT4").Value = dr["VndrFourthContactNo"]; if (dr["VndrFourthName"].ToString() == string.Empty && dr["VndrFourthType"].ToString() == strSelect.ToString()) { oBP.UserFields.Fields.Item("U_VNDR_IDTYPE4").Value = string.Empty; } else if (dr["VndrFourthName"].ToString() == string.Empty && dr["VndrFourthType"].ToString() != strSelect.ToString()) { oBP.UserFields.Fields.Item("U_VNDR_IDTYPE4").Value = string.Empty; } else if (dr["VndrFourthName"].ToString() != string.Empty && dr["VndrFourthType"].ToString() == strSelect.ToString()) { oBP.UserFields.Fields.Item("U_VNDR_IDTYPE4").Value = "INDIVIDUAL"; } else { oBP.UserFields.Fields.Item("U_VNDR_IDTYPE4").Value = dr["VndrFourthType"].ToString(); } lRetCode = oBP.Update(); if (lRetCode == 0) { if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Vendor tab details Updated Successfully ", sFuncName); sResult = "SUCCESS"; } else { sResult = oDICompany.GetLastErrorDescription(); throw new ArgumentException(sResult); } } else if (sTabId == "4")// Update Property tab details { DataRow dr = dtProperty.Rows[0]; oBP.GetByKey(sCardCode); oBP.UserFields.Fields.Item("U_TITLETYPE").Value = dr["TitleType"]; oBP.UserFields.Fields.Item("U_LOTNO").Value = dr["LotNo"]; oBP.UserFields.Fields.Item("U_FORMERLY_KNOWN_AS").Value = dr["PreviouslyKnownAs"]; oBP.UserFields.Fields.Item("U_STATE").Value = dr["State"]; oBP.UserFields.Fields.Item("U_AREA").Value = dr["Area"]; oBP.UserFields.Fields.Item("U_BPM").Value = dr["BPM"]; oBP.UserFields.Fields.Item("U_LOTAREA").Value = dr["LotArea"]; oBP.UserFields.Fields.Item("U_DEVELOPER_CODE").Value = dr["Developer"]; oBP.UserFields.Fields.Item("ProjectCod").Value = dr["Project"]; oBP.UserFields.Fields.Item("U_ADV_DEV_LIC_NO").Value = dr["DevLicenseNo"]; oBP.UserFields.Fields.Item("U_DEV_SOL_NAME").Value = dr["DevSolicitor"]; oBP.UserFields.Fields.Item("U_DEV_SOL_LOC").Value = dr["DevSoliLoc"]; oBP.UserFields.Fields.Item("U_TITLESEARCH_DT").Value = dr["TitleSearchDate"]; oBP.UserFields.Fields.Item("U_SBM_CNST_TRNSF_DT").Value = dr["DSCTransfer"]; oBP.UserFields.Fields.Item("U_RCV_CNST_TRNSF_DT").Value = dr["DRCTransfer"]; oBP.UserFields.Fields.Item("U_14A_DT").Value = dr["FourteenADate"]; oBP.UserFields.Fields.Item("U_TITLE_RTN_LNDRG_DT").Value = dr["DRTLRegistry"]; //if (dr["PropertyCharged"].ToString() == "Y") //{ // oBP.set_Properties(13, SAPbobsCOM.BoYesNoEnum.tYES); //} //else //{ // oBP.set_Properties(13, SAPbobsCOM.BoYesNoEnum.tNO); //} //oBP.UserFields.Fields.Item("U_PROPERTY_ISCHARGED").Value = dr["PropertyCharged"]; if (dr["PropertyCharged"].ToString() == "true") { oBP.set_Properties(12, SAPbobsCOM.BoYesNoEnum.tYES); oBP.set_Properties(13, SAPbobsCOM.BoYesNoEnum.tNO); } else { oBP.set_Properties(12, SAPbobsCOM.BoYesNoEnum.tNO); oBP.set_Properties(13, SAPbobsCOM.BoYesNoEnum.tYES); } oBP.UserFields.Fields.Item("U_PROPERTY_ISCHARGED").Value = dr["PropertyCharged"].ToString() == "true" ? "Y" : "N"; oBP.UserFields.Fields.Item("U_CHRG_BANK_CODE").Value = dr["BankName"]; oBP.UserFields.Fields.Item("U_CHRG_BANK_BRANCH").Value = dr["Branch"]; oBP.UserFields.Fields.Item("U_CHRG_BANK_PA_NAME").Value = dr["PAName"]; oBP.UserFields.Fields.Item("U_CHRG_BANK_PRSNTNO").Value = dr["PresentationNo"]; oBP.UserFields.Fields.Item("U_EXISTING_CHRG_REF").Value = dr["ExistChargeRef"]; if (dr["ReceiptType"].ToString() != strSelect.ToString()) { oBP.UserFields.Fields.Item("U_RECEIPT_TYPE").Value = dr["ReceiptType"]; } oBP.UserFields.Fields.Item("U_RECEIPT_NO").Value = dr["ReceiptNo"]; oBP.UserFields.Fields.Item("U_RECEIPT_DT").Value = dr["ReceiptDate"]; oBP.UserFields.Fields.Item("U_PROPERTY_PURPRC").Value = dr["PurchasePrice"]; oBP.UserFields.Fields.Item("U_PROPERTY_ADJ_VALUE").Value = dr["AdjValue"]; oBP.UserFields.Fields.Item("U_VNDR_PRV_SPA_VALUE").Value = dr["VndrPrevSPAValue"]; oBP.UserFields.Fields.Item("U_PROPERTY_DEPOSIT").Value = dr["Deposit"]; oBP.UserFields.Fields.Item("U_PROPERTY_BALPURPRC").Value = dr["BalPurPrice"]; oBP.UserFields.Fields.Item("U_PROPERTY_LOAN_AMT").Value = dr["LoanAmount"]; oBP.UserFields.Fields.Item("U_PROPERTY_LOAN_CASE").Value = dr["LoanCaseNo"]; oBP.UserFields.Fields.Item("U_DIFFERENTIAL_SUM").Value = dr["DiffSum"]; oBP.UserFields.Fields.Item("U_REDEMPTION_AMT").Value = dr["RedAmt"]; oBP.UserFields.Fields.Item("U_REDEMPTION_DT").Value = dr["RedDate"]; oBP.UserFields.Fields.Item("U_DEFICIT_REDEMPTSUM").Value = dr["DefRdmptSum"]; if (dr["QryGroup14"].ToString() == "Y") { oBP.set_Properties(14, SAPbobsCOM.BoYesNoEnum.tYES); } else { oBP.set_Properties(14, SAPbobsCOM.BoYesNoEnum.tNO); } if (dr["QryGroup15"].ToString() == "Y") { oBP.set_Properties(15, SAPbobsCOM.BoYesNoEnum.tYES); } else { oBP.set_Properties(15, SAPbobsCOM.BoYesNoEnum.tNO); } if (dr["QryGroup16"].ToString() == "Y") { oBP.set_Properties(16, SAPbobsCOM.BoYesNoEnum.tYES); } else { oBP.set_Properties(16, SAPbobsCOM.BoYesNoEnum.tNO); } lRetCode = oBP.Update(); if (lRetCode == 0) { if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Property tab details Updated Successfully ", sFuncName); sResult = "SUCCESS"; } else { sResult = oDICompany.GetLastErrorDescription(); throw new ArgumentException(sResult); } // Write a Query to update in the [@AE-PROPERTY] TABLE SqlConnection con = new SqlConnection(ConnectionString); SqlCommand command = con.CreateCommand(); string[] TimeSplit = DateTime.Now.TimeOfDay.ToString().Split(':'); string sCharged = string.Empty; string sFree = string.Empty; if (dr["PropertyCharged"].ToString() == "true") { sCharged = "Y"; sFree = "N"; } else { sCharged = "N"; sFree = "Y"; } //Updating the Informations command.CommandText = "UPDATE [@AE_PROPERTY] SET U_LOTNO = '" + dr["LotNo"] + "'," + "U_FORMERLY_KNOWN_AS = '" + dr["PreviouslyKnownAs"] + "'," + "U_BPM = '" + dr["BPM"] + "'," + "U_STATE = '" + dr["State"] + "'," + "U_AREA = '" + dr["Area"] + "'," + "U_LOTAREA = '" + dr["LotArea"] + "'," + "UpdateDate = '" + DateTime.Now.Date + "'," + "Updatetime = '" + TimeSplit[0] + TimeSplit[1] + "'," + "U_DEVLICNO = '" + dr["DevLicenseNo"] + "'," + "U_DVLPR_LOC = '" + dr["DevSoliLoc"] + "'," + "U_LSTCHG_BRANCH = '" + dr["Branch"] + "'," + "U_LSTCHG_PANO = '" + dr["PAName"] + "'," + "U_LSTCHG_PRSTNO = '" + dr["PresentationNo"] + "'," + "U_PROPERTY_CHARGED = '" + sCharged.ToString() + "'," + "U_PROPERTY_FREE = '" + sFree.ToString() + "'" + " WHERE Code = (select U_PROPERTY_CODE from OCRD WITH (NOLOCK) where CardCode = '" + sCardCode + "')"; con.Open(); command.ExecuteNonQuery(); //sReturnResult = "SUCCESS"; con.Close(); } else if (sTabId == "5") // Update Loan Principle tab details { DataRow dr = dtLoanPrinciple.Rows[0]; oBP.GetByKey(sCardCode); oBP.UserFields.Fields.Item("U_LOAN_MSTR_BANKCODE").Value = dr["MasterBankName"]; oBP.UserFields.Fields.Item("U_LOAN_BRANCH").Value = dr["BranchName"]; oBP.UserFields.Fields.Item("U_LOAN_BANK_ADD").Value = dr["Address"]; oBP.UserFields.Fields.Item("U_LOAN_BANK_PA_NAME").Value = dr["PAName"]; oBP.UserFields.Fields.Item("U_LOAN_BANK_REF").Value = dr["BankRef"]; oBP.UserFields.Fields.Item("U_LOAN_BANK_INSTR_DT").Value = dr["BankInsDate"]; oBP.UserFields.Fields.Item("U_LOAN_LETTEROFFR_DT").Value = dr["LOFDate"]; oBP.UserFields.Fields.Item("U_PROPERTY_LOAN_CASE").Value = dr["LoanCaseNo"]; oBP.UserFields.Fields.Item("U_LOAN_BANK_SOL_NAME").Value = dr["BankSolicitor"]; oBP.UserFields.Fields.Item("U_LOAN_BANK_SOL_LOC").Value = dr["SoliLoc"]; oBP.UserFields.Fields.Item("U_LOAN_BANK_SOL_REF").Value = dr["SoliRef"]; oBP.UserFields.Fields.Item("U_LOAN_RDMPSTMTREQDT").Value = dr["ReqRedStatement"]; oBP.UserFields.Fields.Item("U_LOAN_RDMPT_STMT_DT").Value = dr["RedStmtDate"]; oBP.UserFields.Fields.Item("U_LOAN_RDMPTPYMTDT").Value = dr["RedPayDate"]; oBP.UserFields.Fields.Item("U_PROJECT_NAME").Value = dr["Project"]; if (dr["TypeofLoan"].ToString() != strSelect.ToString()) { oBP.UserFields.Fields.Item("U_LOAN_PRNCP_TYPE").Value = dr["TypeofLoan"]; } oBP.UserFields.Fields.Item("U_LOAN_PRNCP_FTYPE").Value = dr["TypeofFacility"]; oBP.UserFields.Fields.Item("U_LOAN_PRNCP_FAMT").Value = dr["FacilityAmt"]; oBP.UserFields.Fields.Item("U_LOAN_PRNCP_INT_RT").Value = dr["IntrstRate"]; oBP.UserFields.Fields.Item("U_LOAN_PRNCP_TRMLOAN").Value = dr["TermLoanAmt"]; oBP.UserFields.Fields.Item("U_LOAN_PRNCP_RPYMTPD").Value = dr["Repaymt"]; oBP.UserFields.Fields.Item("U_LOAN_PRNCP_MTHINST").Value = dr["MonthlyInstmt"]; oBP.UserFields.Fields.Item("U_LOAN_PRNCP_INT").Value = dr["Interest"]; oBP.UserFields.Fields.Item("U_LOAN_PRNCP_ODLOAN").Value = dr["ODLoan"]; oBP.UserFields.Fields.Item("U_LOAN_PRNCP_MRTA").Value = dr["MRTA"]; oBP.UserFields.Fields.Item("U_LOAN_PRNCP_BNKGNTE").Value = dr["BankGuarantee"]; oBP.UserFields.Fields.Item("U_LOAN_PRNCP_LC").Value = dr["LetterofCredit"]; oBP.UserFields.Fields.Item("U_LOAN_PRNCP_TRUSTRC").Value = dr["TrustReceipt"]; oBP.UserFields.Fields.Item("U_LOAN_PRNCP_OTHR").Value = dr["Others"]; oBP.UserFields.Fields.Item("U_BRWR_RP_FIRM").Value = dr["RepByFirm"].ToString() == "true" ? "Y" : "N"; oBP.UserFields.Fields.Item("U_LOAN_DET_1").Value = dr["LoanDet1"]; oBP.UserFields.Fields.Item("U_LOAN_DET_2").Value = dr["LoanDet2"]; oBP.UserFields.Fields.Item("U_LOAN_DET_3").Value = dr["LoanDet3"]; oBP.UserFields.Fields.Item("U_LOAN_DET_4").Value = dr["LoanDet4"]; oBP.UserFields.Fields.Item("U_LOAN_DET_5").Value = dr["LoanDet5"]; lRetCode = oBP.Update(); if (lRetCode == 0) { if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Loan Principle tab details Updated Successfully ", sFuncName); sResult = "SUCCESS"; } else { sResult = oDICompany.GetLastErrorDescription(); throw new ArgumentException(sResult); } } else if (sTabId == "6")// Update Loan Subsidary tab details { DataRow dr = dtLoanSubsidary.Rows[0]; oBP.GetByKey(sCardCode); oBP.UserFields.Fields.Item("U_LOAN_DOC_FWD_BK_DT").Value = dr["LoanDocForBankExe"]; oBP.UserFields.Fields.Item("U_FACILITY_AGMT_DT").Value = dr["FaciAgreeDate"]; oBP.UserFields.Fields.Item("U_LOAN_DOC_RTN_BK_DT").Value = dr["LoanDocRetFromBank"]; oBP.UserFields.Fields.Item("U_DISCHARGE_CHRG_DT").Value = dr["DischargeofCharge"]; if (dr["FirstTypeofFacility"].ToString() != strSelect.ToString()) { oBP.UserFields.Fields.Item("U_LOAN_SUB1_FTYPE").Value = dr["FirstTypeofFacility"]; } oBP.UserFields.Fields.Item("U_LOAN_SUB1_FAMT").Value = dr["FirstFacilityAmt"]; oBP.UserFields.Fields.Item("U_LOAN_SUB1_RPYMTPD").Value = dr["FirstRepaymt"]; oBP.UserFields.Fields.Item("U_LOAN_SUB1_INT_RT").Value = dr["FirstIntrstRate"]; oBP.UserFields.Fields.Item("U_LOAN_SUB1_MTHINST").Value = dr["FirstMonthlyInstmt"]; oBP.UserFields.Fields.Item("U_LOAN_SUB1_TRMLOAN").Value = dr["FirstTermLoanAmt"]; oBP.UserFields.Fields.Item("U_LOAN_SUB1_INT").Value = dr["FirstInterest"]; oBP.UserFields.Fields.Item("U_LOAN_SUB1_ODLOAN").Value = dr["FirstODLoan"]; oBP.UserFields.Fields.Item("U_LOAN_SUB1_MRTA").Value = dr["FirstMRTA"]; oBP.UserFields.Fields.Item("U_LOAN_SUB1_BNKGNTE").Value = dr["FirstBankGuarantee"]; oBP.UserFields.Fields.Item("U_LOAN_SUB1_LC").Value = dr["FirstLetterofCredit"]; oBP.UserFields.Fields.Item("U_LOAN_SUB1_TRUSTRC").Value = dr["FirstTrustReceipt"]; oBP.UserFields.Fields.Item("U_LOAN_SUB1_OTHR").Value = dr["FirstOthers"]; if (dr["SecTypeofFacility"].ToString() != strSelect.ToString()) { oBP.UserFields.Fields.Item("U_LOAN_SUB2_FTYPE").Value = dr["SecTypeofFacility"]; } oBP.UserFields.Fields.Item("U_LOAN_SUB2_FAMT").Value = dr["SecFacilityAmt"]; oBP.UserFields.Fields.Item("U_LOAN_SUB2_RPYMTPD").Value = dr["SecRepaymt"]; oBP.UserFields.Fields.Item("U_LOAN_SUB2_INT_RT").Value = dr["SecIntrstRate"]; oBP.UserFields.Fields.Item("U_LOAN_SUB2_MTHINST").Value = dr["SecMonthlyInstmt"]; oBP.UserFields.Fields.Item("U_LOAN_SUB2_TRMLOAN").Value = dr["SecTermLoanAmt"]; oBP.UserFields.Fields.Item("U_LOAN_SUB2_INT").Value = dr["SecInterest"]; oBP.UserFields.Fields.Item("U_LOAN_SUB2_ODLOAN").Value = dr["SecODLoan"]; oBP.UserFields.Fields.Item("U_LOAN_SUB2_MRTA").Value = dr["SecMRTA"]; oBP.UserFields.Fields.Item("U_LOAN_SUB2_BNKGNTE").Value = dr["SecBankGuarantee"]; oBP.UserFields.Fields.Item("U_LOAN_SUB2_LC").Value = dr["SecLetterofCredit"]; oBP.UserFields.Fields.Item("U_LOAN_SUB2_TRUSTRC").Value = dr["SecTrustReceipt"]; oBP.UserFields.Fields.Item("U_LOAN_SUB2_OTHR").Value = dr["SecOthers"]; if (dr["ThirdTypeofFacility"].ToString() != strSelect.ToString()) { oBP.UserFields.Fields.Item("U_LOAN_SUB3_FTYPE").Value = dr["ThirdTypeofFacility"]; } oBP.UserFields.Fields.Item("U_LOAN_SUB3_FAMT").Value = dr["ThirdFacilityAmt"]; oBP.UserFields.Fields.Item("U_LOAN_SUB3_RPYMTPD").Value = dr["ThirdRepaymt"]; oBP.UserFields.Fields.Item("U_LOAN_SUB3_INT_RT").Value = dr["ThirdIntrstRate"]; oBP.UserFields.Fields.Item("U_LOAN_SUB3_MTHINST").Value = dr["ThirdMonthlyInstmt"]; oBP.UserFields.Fields.Item("U_LOAN_SUB3_TRMLOAN").Value = dr["ThirdTermLoanAmt"]; oBP.UserFields.Fields.Item("U_LOAN_SUB3_INT").Value = dr["ThirdInterest"]; oBP.UserFields.Fields.Item("U_LOAN_SUB3_ODLOAN").Value = dr["ThirdODLoan"]; oBP.UserFields.Fields.Item("U_LOAN_SUB3_MRTA").Value = dr["ThirdMRTA"]; oBP.UserFields.Fields.Item("U_LOAN_SUB3_BNKGNTE").Value = dr["ThirdBankGuarantee"]; oBP.UserFields.Fields.Item("U_LOAN_SUB3_LC").Value = dr["ThirdLetterofCredit"]; oBP.UserFields.Fields.Item("U_LOAN_SUB3_TRUSTRC").Value = dr["ThirdTrustReceipt"]; oBP.UserFields.Fields.Item("U_LOAN_SUB3_OTHR").Value = dr["ThirdOthers"]; if (dr["FourthTypeofFacility"].ToString() != strSelect.ToString()) { oBP.UserFields.Fields.Item("U_LOAN_SUB4_FTYPE").Value = dr["FourthTypeofFacility"]; } oBP.UserFields.Fields.Item("U_LOAN_SUB4_FAMT").Value = dr["FourthFacilityAmt"]; oBP.UserFields.Fields.Item("U_LOAN_SUB4_RPYMTPD").Value = dr["FourthRepaymt"]; oBP.UserFields.Fields.Item("U_LOAN_SUB4_INT_RT").Value = dr["FourthIntrstRate"]; oBP.UserFields.Fields.Item("U_LOAN_SUB4_MTHINST").Value = dr["FourthMonthlyInstmt"]; oBP.UserFields.Fields.Item("U_LOAN_SUB4_TRMLOAN").Value = dr["FourthTermLoanAmt"]; oBP.UserFields.Fields.Item("U_LOAN_SUB4_INT").Value = dr["FourthInterest"]; oBP.UserFields.Fields.Item("U_LOAN_SUB4_ODLOAN").Value = dr["FourthODLoan"]; oBP.UserFields.Fields.Item("U_LOAN_SUB4_MRTA").Value = dr["FourthMRTA"]; oBP.UserFields.Fields.Item("U_LOAN_SUB4_BNKGNTE").Value = dr["FourthBankGuarantee"]; oBP.UserFields.Fields.Item("U_LOAN_SUB4_LC").Value = dr["FourthLetterofCredit"]; oBP.UserFields.Fields.Item("U_LOAN_SUB4_TRUSTRC").Value = dr["FourthTrustReceipt"]; oBP.UserFields.Fields.Item("U_LOAN_SUB4_OTHR").Value = dr["FourthOthers"]; if (dr["FifthTypeofFacility"].ToString() != strSelect.ToString()) { oBP.UserFields.Fields.Item("U_LOAN_SUB5_FTYPE").Value = dr["FifthTypeofFacility"]; } oBP.UserFields.Fields.Item("U_LOAN_SUB5_FAMT").Value = dr["FifthFacilityAmt"]; oBP.UserFields.Fields.Item("U_LOAN_SUB5_RPYMTPD").Value = dr["FifthRepaymt"]; oBP.UserFields.Fields.Item("U_LOAN_SUB5_INT_RT").Value = dr["FifthIntrstRate"]; oBP.UserFields.Fields.Item("U_LOAN_SUB5_MTHINST").Value = dr["FifthMonthlyInstmt"]; oBP.UserFields.Fields.Item("U_LOAN_SUB5_TRMLOAN").Value = dr["FifthTermLoanAmt"]; oBP.UserFields.Fields.Item("U_LOAN_SUB5_INT").Value = dr["FifthInterest"]; oBP.UserFields.Fields.Item("U_LOAN_SUB5_ODLOAN").Value = dr["FifthODLoan"]; oBP.UserFields.Fields.Item("U_LOAN_SUB5_MRTA").Value = dr["FifthMRTA"]; oBP.UserFields.Fields.Item("U_LOAN_SUB5_BNKGNTE").Value = dr["FifthBankGuarantee"]; oBP.UserFields.Fields.Item("U_LOAN_SUB5_LC").Value = dr["FifthLetterofCredit"]; oBP.UserFields.Fields.Item("U_LOAN_SUB5_TRUSTRC").Value = dr["FifthTrustReceipt"]; oBP.UserFields.Fields.Item("U_LOAN_SUB5_OTHR").Value = dr["FifthOthers"]; lRetCode = oBP.Update(); if (lRetCode == 0) { if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Loan Subsidary details Updated Successfully ", sFuncName); sResult = "SUCCESS"; } else { sResult = oDICompany.GetLastErrorDescription(); throw new ArgumentException(sResult); } } // have to write the update statement for OCRD Using the DIAPI. return sResult; } catch (Exception Ex) { //if (oDICompany.InTransaction) oDICompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack); sErrDesc = Ex.Message.ToString(); oLog.WriteToErrorLogFile(sErrDesc, sFuncName); if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Completed With ERROR ", sFuncName); sResult = Ex.Message.ToString(); throw Ex; } }
public string SPA_AddCase_AddIndividual(DataTable dtDatatable, string sType) { string sFuncName = string.Empty; string sReturnResult = string.Empty; string sCode = string.Empty; string sResult = string.Empty; string sExistingCheck = string.Empty; int iLoopCount = 0; try { sFuncName = "SPA_AddCase_AddIndividual"; foreach (DataRow item in dtDatatable.Rows) { iLoopCount = iLoopCount + 1; DataTable results = new DataTable(); DataTable ExistingCheck = new DataTable(); SqlConnection con = new SqlConnection(ConnectionString); SqlCommand command = con.CreateCommand(); con.Open(); command.CommandText = "select Code from [@AE_RELATEDPARTY] WITH (NOLOCK) where U_IDNO_F1 = '" + item["IDNo1"].ToString().Replace("\n", "").ToString() + "'"; SqlDataAdapter dataAdapter1 = new SqlDataAdapter(command); dataAdapter1.Fill(ExistingCheck); con.Close(); //if (ExistingCheck.Rows[0][0].ToString().Length == 0) //{ if (item["IDType"].ToString() == "INDIVIDUAL") { if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Connecting to target company ", sFuncName); oDICompany = oLogin.ConnectToTargetCompany(ConnectionString); SAPbobsCOM.GeneralService oGeneralService = null; SAPbobsCOM.GeneralData oGeneralData; SAPbobsCOM.CompanyService oCompanyService = oDICompany.GetCompanyService(); SAPbobsCOM.GeneralDataParams oGeneralParams = null; oGeneralService = oCompanyService.GetGeneralService("RELATEDPARTY"); oGeneralData = (SAPbobsCOM.GeneralData)oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralData); con.Open(); command.CommandText = "SELECT REPLICATE('0', (12-LEN(ISNULL(MAX(SUBSTRING(Code,4,LEN(Code)))+1,1)))) " + " + CONVERT(VARCHAR, ISNULL(MAX(SUBSTRING(Code,4,LEN(Code)))+1,1)) [Code] FROM [@AE_RELATEDPARTY] WITH (NOLOCK)"; SqlDataAdapter dataAdapter = new SqlDataAdapter(command); dataAdapter.Fill(results); if (results.Rows[0][0].ToString().Length > 0) { sCode = results.Rows[0][0].ToString(); } con.Close(); string[] sIDSplitUp = item["IDNo1"].ToString().Split('-'); string sIDNo2 = item["IDNo1"].ToString(); string sAddressId = item["IDAddress1"].ToString() + System.Environment.NewLine + item["IDAddress2"].ToString() + System.Environment.NewLine + item["IDAddress3"].ToString() + System.Environment.NewLine + item["IDAddress4"].ToString() + System.Environment.NewLine + item["IDAddress5"].ToString(); string sCorrespondAddressId = item["CorresAddr1"].ToString() + System.Environment.NewLine + item["CorresAddr2"].ToString() + System.Environment.NewLine + item["CorresAddr3"].ToString() + System.Environment.NewLine + item["CorresAddr4"].ToString() + System.Environment.NewLine + item["CorresAddr5"].ToString(); if (ExistingCheck.Rows.Count > 0) { if (ExistingCheck.Rows[0][0].ToString().Length == 0) { //Adding the Informations //oGeneralData.SetProperty("DocEntry", item["DocEntry"].ToString()); oGeneralData.SetProperty("Code", sCode); oGeneralData.SetProperty("U_NAME", item["EmployeeName"].ToString()); oGeneralData.SetProperty("U_INDIVIDUAL_TITLE", item["Title"].ToString()); oGeneralData.SetProperty("U_GENDER", item["Gender"].ToString()); oGeneralData.SetProperty("U_IDNO_F1", item["IDNo1"].ToString()); oGeneralData.SetProperty("U_IDNO_F2", sIDNo2.Replace("-", "")); oGeneralData.SetProperty("U_IDNO_F3", item["IDNo3"].ToString()); if (sIDSplitUp.Length > 0) { if (sIDSplitUp.Length >= 1) { oGeneralData.SetProperty("U_IDSEC1", sIDSplitUp[0]); } if (sIDSplitUp.Length >= 2) { oGeneralData.SetProperty("U_IDSEC2", sIDSplitUp[1]); } if (sIDSplitUp.Length >= 3) { oGeneralData.SetProperty("U_IDSEC3", sIDSplitUp[2]); } } oGeneralData.SetProperty("U_IDTYPE", "INDIVIDUAL"); oGeneralData.SetProperty("U_TAXNOFORMAT1", item["TaxNo"].ToString()); oGeneralData.SetProperty("U_CONTACT_MOBILE", item["MobileNo"].ToString()); oGeneralData.SetProperty("U_CONTACT_TELEPHONE", item["Telephone"].ToString()); oGeneralData.SetProperty("U_SYARIKATNO", item["OfficeNo"].ToString()); oGeneralData.SetProperty("U_ADDSEG1", item["IDAddress1"].ToString()); oGeneralData.SetProperty("U_ADDSEG2", item["IDAddress2"].ToString()); oGeneralData.SetProperty("U_ADDSEG3", item["IDAddress3"].ToString()); oGeneralData.SetProperty("U_ADDSEG4", item["IDAddress4"].ToString()); oGeneralData.SetProperty("U_ADDSEG5", item["IDAddress5"].ToString()); oGeneralData.SetProperty("U_ADDRESS_ID", sAddressId); oGeneralData.SetProperty("U_CADDSEG1", item["CorresAddr1"].ToString()); oGeneralData.SetProperty("U_CADDSEG2", item["CorresAddr2"].ToString()); oGeneralData.SetProperty("U_CADDSEG3", item["CorresAddr3"].ToString()); oGeneralData.SetProperty("U_CADDSEG4", item["CorresAddr4"].ToString()); oGeneralData.SetProperty("U_CADDSEG5", item["CorresAddr5"].ToString()); oGeneralData.SetProperty("U_ADDRESS_CORRESPOND", sCorrespondAddressId); oGeneralData.SetProperty("U_ADDRESS_TOUSE", item["AddressToUse"].ToString()); oGeneralData.SetProperty("U_BANK", "N"); oGeneralData.SetProperty("U_DEVELOPER", "N"); oGeneralData.SetProperty("U_SOLICITOR", "N"); //oGeneralData.SetProperty("LastUpdatedOn", item["LastUpdatedOn"].ToString()); oGeneralData.SetProperty("U_IDSCAN1", item["ScanFrontICLocation"].ToString()); oGeneralData.SetProperty("U_IDSCAN2", item["ScanBackICLocation"].ToString()); oGeneralService.Add(oGeneralData); } else { //Updating the Informations oGeneralParams = (SAPbobsCOM.GeneralDataParams)oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralDataParams); oGeneralParams.SetProperty("Code", ExistingCheck.Rows[0][0].ToString()); oGeneralData = oGeneralService.GetByParams(oGeneralParams); //oGeneralData.SetProperty("DocEntry", item["DocEntry"].ToString()); oGeneralData.SetProperty("U_NAME", item["EmployeeName"].ToString()); oGeneralData.SetProperty("U_INDIVIDUAL_TITLE", item["Title"].ToString()); oGeneralData.SetProperty("U_GENDER", item["Gender"].ToString()); oGeneralData.SetProperty("U_IDNO_F1", item["IDNo1"].ToString()); oGeneralData.SetProperty("U_IDNO_F2", sIDNo2.Replace("-", "")); oGeneralData.SetProperty("U_IDNO_F3", item["IDNo3"].ToString()); if (sIDSplitUp.Length > 0) { if (sIDSplitUp.Length >= 1) { oGeneralData.SetProperty("U_IDSEC1", sIDSplitUp[0]); } if (sIDSplitUp.Length >= 2) { oGeneralData.SetProperty("U_IDSEC2", sIDSplitUp[1]); } if (sIDSplitUp.Length >= 3) { oGeneralData.SetProperty("U_IDSEC3", sIDSplitUp[2]); } } oGeneralData.SetProperty("U_IDTYPE", "INDIVIDUAL"); oGeneralData.SetProperty("U_TAXNOFORMAT1", item["TaxNo"].ToString()); oGeneralData.SetProperty("U_CONTACT_MOBILE", item["MobileNo"].ToString()); oGeneralData.SetProperty("U_CONTACT_TELEPHONE", item["Telephone"].ToString()); oGeneralData.SetProperty("U_SYARIKATNO", item["OfficeNo"].ToString()); oGeneralData.SetProperty("U_ADDSEG1", item["IDAddress1"].ToString()); oGeneralData.SetProperty("U_ADDSEG2", item["IDAddress2"].ToString()); oGeneralData.SetProperty("U_ADDSEG3", item["IDAddress3"].ToString()); oGeneralData.SetProperty("U_ADDSEG4", item["IDAddress4"].ToString()); oGeneralData.SetProperty("U_ADDSEG5", item["IDAddress5"].ToString()); oGeneralData.SetProperty("U_ADDRESS_ID", sAddressId); oGeneralData.SetProperty("U_CADDSEG1", item["CorresAddr1"].ToString()); oGeneralData.SetProperty("U_CADDSEG2", item["CorresAddr2"].ToString()); oGeneralData.SetProperty("U_CADDSEG3", item["CorresAddr3"].ToString()); oGeneralData.SetProperty("U_CADDSEG4", item["CorresAddr4"].ToString()); oGeneralData.SetProperty("U_CADDSEG5", item["CorresAddr5"].ToString()); oGeneralData.SetProperty("U_ADDRESS_CORRESPOND", sCorrespondAddressId); oGeneralData.SetProperty("U_ADDRESS_TOUSE", item["AddressToUse"].ToString()); oGeneralData.SetProperty("U_BANK", "N"); oGeneralData.SetProperty("U_DEVELOPER", "N"); oGeneralData.SetProperty("U_SOLICITOR", "N"); //oGeneralData.SetProperty("LastUpdatedOn", item["LastUpdatedOn"].ToString()); oGeneralData.SetProperty("U_IDSCAN1", item["ScanFrontICLocation"].ToString()); oGeneralData.SetProperty("U_IDSCAN2", item["ScanBackICLocation"].ToString()); oGeneralService.Update(oGeneralData); // Update the Value } } else { //Adding the Informations //oGeneralData.SetProperty("DocEntry", item["DocEntry"].ToString()); oGeneralData.SetProperty("Code", sCode); oGeneralData.SetProperty("U_NAME", item["EmployeeName"].ToString()); oGeneralData.SetProperty("U_INDIVIDUAL_TITLE", item["Title"].ToString()); oGeneralData.SetProperty("U_GENDER", item["Gender"].ToString()); oGeneralData.SetProperty("U_IDNO_F1", item["IDNo1"].ToString()); oGeneralData.SetProperty("U_IDNO_F2", sIDNo2.Replace("-", "")); oGeneralData.SetProperty("U_IDNO_F3", item["IDNo3"].ToString()); if (sIDSplitUp.Length > 0) { if (sIDSplitUp.Length >= 1) { oGeneralData.SetProperty("U_IDSEC1", sIDSplitUp[0]); } if (sIDSplitUp.Length >= 2) { oGeneralData.SetProperty("U_IDSEC2", sIDSplitUp[1]); } if (sIDSplitUp.Length >= 3) { oGeneralData.SetProperty("U_IDSEC3", sIDSplitUp[2]); } } oGeneralData.SetProperty("U_IDTYPE", "INDIVIDUAL"); oGeneralData.SetProperty("U_TAXNOFORMAT1", item["TaxNo"].ToString()); oGeneralData.SetProperty("U_CONTACT_MOBILE", item["MobileNo"].ToString()); oGeneralData.SetProperty("U_CONTACT_TELEPHONE", item["Telephone"].ToString()); oGeneralData.SetProperty("U_SYARIKATNO", item["OfficeNo"].ToString()); oGeneralData.SetProperty("U_ADDSEG1", item["IDAddress1"].ToString()); oGeneralData.SetProperty("U_ADDSEG2", item["IDAddress2"].ToString()); oGeneralData.SetProperty("U_ADDSEG3", item["IDAddress3"].ToString()); oGeneralData.SetProperty("U_ADDSEG4", item["IDAddress4"].ToString()); oGeneralData.SetProperty("U_ADDSEG5", item["IDAddress5"].ToString()); oGeneralData.SetProperty("U_ADDRESS_ID", sAddressId); oGeneralData.SetProperty("U_CADDSEG1", item["CorresAddr1"].ToString()); oGeneralData.SetProperty("U_CADDSEG2", item["CorresAddr2"].ToString()); oGeneralData.SetProperty("U_CADDSEG3", item["CorresAddr3"].ToString()); oGeneralData.SetProperty("U_CADDSEG4", item["CorresAddr4"].ToString()); oGeneralData.SetProperty("U_CADDSEG5", item["CorresAddr5"].ToString()); oGeneralData.SetProperty("U_ADDRESS_CORRESPOND", sCorrespondAddressId); oGeneralData.SetProperty("U_ADDRESS_TOUSE", item["AddressToUse"].ToString()); oGeneralData.SetProperty("U_BANK", "N"); oGeneralData.SetProperty("U_DEVELOPER", "N"); oGeneralData.SetProperty("U_SOLICITOR", "N"); //oGeneralData.SetProperty("LastUpdatedOn", item["LastUpdatedOn"].ToString()); oGeneralData.SetProperty("U_IDSCAN1", item["ScanFrontICLocation"].ToString()); oGeneralData.SetProperty("U_IDSCAN2", item["ScanBackICLocation"].ToString()); oGeneralService.Add(oGeneralData); } // The following code is update the Related Party data in the Temp table sResult = SPA_AddCase_Purch_UpdatePropInTemp(sType, iLoopCount.ToString(), item["CardCode"].ToString(), sCode, item["IDNo1"].ToString(), item["EmployeeName"].ToString(), item["TaxNo"].ToString(), item["MobileNo"].ToString(), "INDIVIDUAL"); } else { sCode = item["CardCode"].ToString(); sResult = SPA_AddCase_Purch_UpdatePropInTemp(sType, iLoopCount.ToString(), sCode, item["Code"].ToString(), item["IDNo1"].ToString(), item["EmployeeName"].ToString(), item["TaxNo"].ToString(), item["MobileNo"].ToString(), "CORPORATE"); } if (sResult != "SUCCESS") { sReturnResult = sResult; break; } sReturnResult = "SUCCESS"; } } catch (Exception Ex) { sErrDesc = Ex.Message.ToString(); oLog.WriteToErrorLogFile(sErrDesc, sFuncName); if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Completed With ERROR ", sFuncName); throw Ex; } return sReturnResult; }
public string SPA_ProcessCase_UpdateStatus(DataTable dt) { string sFuncName = "SPA_ProcessCase_UpdateStatus"; string sDocType = string.Empty; string sQuoteEntry = string.Empty; string sItemCode = string.Empty; string sItemLine = string.Empty; string sUserRole = string.Empty; SAPbobsCOM.Documents oSalesQuote; string sStatus = string.Empty; string sCaseNo = string.Empty; string sActionBy = string.Empty; try { if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Starting Function ", sFuncName); if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Connecting to target company ", sFuncName); oDICompany = oLogin.ConnectToTargetCompany(ConnectionString); foreach (DataRow iRow in dt.Rows) { sCaseNo = Convert.ToString(iRow["CaseNo"]); sItemCode = Convert.ToString(iRow["ItemCode"]); sDocType = Convert.ToString(iRow["TrnspName"]); sQuoteEntry = Convert.ToString(iRow["DocEntry"]); sItemLine = Convert.ToString(iRow["LineNum"]); sUserRole = Convert.ToString(iRow["UserRole"]); sStatus = Convert.ToString(iRow["Status"]); sActionBy = Convert.ToString(iRow["ActionBy"]); oSalesQuote = oDICompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oQuotations); if ((sActionBy == "MG" || sActionBy == "LA") && (sUserRole == "MG" || sUserRole == "LA")) { if (oSalesQuote.GetByKey(Convert.ToInt16(sQuoteEntry))) { oSalesQuote.Lines.SetCurrentLine(Convert.ToInt16(sItemLine)); oSalesQuote.Lines.UserFields.Fields.Item("U_STATUS").Value = sStatus; oSalesQuote.Lines.UserFields.Fields.Item("U_PROCESS_LAST_UPDAT").Value = DateTime.Now.Date; if (sStatus == "ACCEPT") { oSalesQuote.Lines.UserFields.Fields.Item("U_PROCESS_ACCEPT_DAT").Value = DateTime.Now.Date; oSalesQuote.Lines.UserFields.Fields.Item("U_PROCESS_ACCEPTBY").Value = Convert.ToString(iRow["UserName"]); Updateddate(sCaseNo, sItemCode, oDICompany); } else if (sStatus == "FAIL") { oSalesQuote.Lines.UserFields.Fields.Item("U_PROCESS_FAIL_DAT").Value = DateTime.Now.Date; } if (oSalesQuote.Update() != 0) { sErrDesc = oDICompany.GetLastErrorDescription(); throw new ArgumentException(sErrDesc); } } } else if (sDocType == "FWDOC") { //NEEDED SALES QUOTATION DOCENTRY,LINENUM,DOCNUM TO UPDATE THE STATUS IN LINE LEVEL if (oSalesQuote.GetByKey(Convert.ToInt16(sQuoteEntry))) { oSalesQuote.Lines.SetCurrentLine(Convert.ToInt16(sItemLine)); oSalesQuote.Lines.UserFields.Fields.Item("U_STATUS").Value = sStatus; oSalesQuote.Lines.UserFields.Fields.Item("U_PROCESS_LAST_UPDAT").Value = DateTime.Now.Date; if (sStatus == "ACCEPT") { oSalesQuote.Lines.UserFields.Fields.Item("U_PROCESS_ACCEPT_DAT").Value = DateTime.Now.Date; oSalesQuote.Lines.UserFields.Fields.Item("U_PROCESS_ACCEPTBY").Value = Convert.ToString(iRow["UserName"]); Updateddate(sCaseNo, sItemCode, oDICompany); } else if (sStatus == "FAIL") { oSalesQuote.Lines.UserFields.Fields.Item("U_PROCESS_FAIL_DAT").Value = DateTime.Now.Date; } if (oSalesQuote.Update() != 0) { sErrDesc = oDICompany.GetLastErrorDescription(); throw new ArgumentException(sErrDesc); } } } else if (sDocType == "MANUAL-FIN") { //NEEDED SALES QUOTATION DOCENTRY,LINENUM,DOCNUM TO UPDATE THE STATUS IN LINE LEVEL if (oSalesQuote.GetByKey(Convert.ToInt16(sQuoteEntry))) { oSalesQuote.Lines.SetCurrentLine(Convert.ToInt16(sItemLine)); oSalesQuote.Lines.UserFields.Fields.Item("U_STATUS").Value = sStatus; oSalesQuote.Lines.UserFields.Fields.Item("U_PROCESS_LAST_UPDAT").Value = DateTime.Now.Date; if (sStatus == "ACCEPT") { oSalesQuote.Lines.UserFields.Fields.Item("U_PROCESS_ACCEPT_DAT").Value = DateTime.Now.Date; oSalesQuote.Lines.UserFields.Fields.Item("U_PROCESS_ACCEPTBY").Value = Convert.ToString(iRow["UserName"]); Updateddate(sCaseNo, sItemCode, oDICompany); } else if (sStatus == "FAIL") { oSalesQuote.Lines.UserFields.Fields.Item("U_PROCESS_FAIL_DAT").Value = DateTime.Now.Date; } if (oSalesQuote.Update() != 0) { sErrDesc = oDICompany.GetLastErrorDescription(); throw new ArgumentException(sErrDesc); } } } else if (sDocType == "MANUAL-FIN-C") { //NEEDED SALES QUOTATION DOCENTRY,LINENUM,DOCNUM TO UPDATE THE STATUS IN LINE LEVEL if (oSalesQuote.GetByKey(Convert.ToInt16(sQuoteEntry))) { oSalesQuote.Lines.SetCurrentLine(Convert.ToInt16(sItemLine)); oSalesQuote.Lines.UserFields.Fields.Item("U_STATUS").Value = sStatus; oSalesQuote.Lines.UserFields.Fields.Item("U_PROCESS_LAST_UPDAT").Value = DateTime.Now.Date; if (sStatus == "ACCEPT") { oSalesQuote.Lines.UserFields.Fields.Item("U_PROCESS_ACCEPT_DAT").Value = DateTime.Now.Date; oSalesQuote.Lines.UserFields.Fields.Item("U_PROCESS_ACCEPTBY").Value = Convert.ToString(iRow["UserName"]); Updateddate(sCaseNo, sItemCode, oDICompany); } else if (sStatus == "FAIL") { oSalesQuote.Lines.UserFields.Fields.Item("U_PROCESS_FAIL_DAT").Value = DateTime.Now.Date; } if (oSalesQuote.Update() != 0) { sErrDesc = oDICompany.GetLastErrorDescription(); throw new ArgumentException(sErrDesc); } } } else if (sDocType == "MANUAL-IC") { //NEEDED SALES QUOTATION DOCENTRY,LINENUM,DOCNUM TO UPDATE THE STATUS IN LINE LEVEL if (oSalesQuote.GetByKey(Convert.ToInt16(sQuoteEntry))) { oSalesQuote.Lines.SetCurrentLine(Convert.ToInt16(sItemLine)); oSalesQuote.Lines.UserFields.Fields.Item("U_STATUS").Value = sStatus; oSalesQuote.Lines.UserFields.Fields.Item("U_PROCESS_LAST_UPDAT").Value = DateTime.Now.Date; if (sStatus == "ACCEPT") { oSalesQuote.Lines.UserFields.Fields.Item("U_PROCESS_ACCEPT_DAT").Value = DateTime.Now.Date; oSalesQuote.Lines.UserFields.Fields.Item("U_PROCESS_ACCEPTBY").Value = Convert.ToString(iRow["UserName"]); Updateddate(sCaseNo, sItemCode, oDICompany); } else if (sStatus == "FAIL") { oSalesQuote.Lines.UserFields.Fields.Item("U_PROCESS_FAIL_DAT").Value = DateTime.Now.Date; } if (oSalesQuote.Update() != 0) { sErrDesc = oDICompany.GetLastErrorDescription(); throw new ArgumentException(sErrDesc); } } } } if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Completed With SUCCESS ", sFuncName); } catch (Exception ex) { sErrDesc = ex.Message.ToString(); oLog.WriteToErrorLogFile(sErrDesc, sFuncName); if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Completed With ERROR ", sFuncName); throw ex; } return "SUCCESS"; }
void IArmada_Sync.Add(string sKey, SAPbobsCOM.Company oCompany, string strLogger, string strWareHouse, string[] strValues, Hashtable htCCdet) { DataSet oDS_S_OCRD = null; SAPbobsCOM.BusinessPartners oPartner = (SAPbobsCOM.BusinessPartners)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oBusinessPartners); string str_S_OCRD = "Exec Armada_Service_S_OCRD_s '" + sKey + "'"; oDS_S_OCRD = Armada_Sync.Singleton.objSqlDataAccess.ExecuteDataSet(str_S_OCRD, strLogger); try { if (oDS_S_OCRD == null && oDS_S_OCRD.Tables.Count == 0) { return; } else { if ((oDS_S_OCRD.Tables[0] != null) && (oDS_S_OCRD.Tables[0].Rows.Count > 0)) { int retVal; if (!oPartner.GetByKey(oDS_S_OCRD.Tables[0].Rows[0]["Code"].ToString().Trim())) { oPartner.CardCode = oDS_S_OCRD.Tables[0].Rows[0]["Code"].ToString().Trim(); oPartner.CardName = oDS_S_OCRD.Tables[0].Rows[0]["Name"].ToString().Trim(); oPartner.CardType = SAPbobsCOM.BoCardTypes.cCustomer; oPartner.Cellular = oDS_S_OCRD.Tables[0].Rows[0]["Phone"].ToString().Trim(); oPartner.Currency = "##"; oPartner.EmailAddress = oDS_S_OCRD.Tables[0].Rows[0]["Email"].ToString().Trim(); oPartner.Fax = oDS_S_OCRD.Tables[0].Rows[0]["Fax"].ToString().Trim(); int intLine = 0; oPartner.Addresses.SetCurrentLine(intLine); oPartner.Addresses.AddressType = SAPbobsCOM.BoAddressType.bo_BillTo; oPartner.Addresses.AddressName = oDS_S_OCRD.Tables[0].Rows[0]["Name"].ToString().Trim(); oPartner.Addresses.Street = oDS_S_OCRD.Tables[0].Rows[0]["Address"].ToString().Trim(); oPartner.Addresses.Block = oDS_S_OCRD.Tables[0].Rows[0]["Area"].ToString().Trim(); oPartner.Addresses.ZipCode = oDS_S_OCRD.Tables[0].Rows[0]["ZipCode"].ToString().Trim(); oPartner.Addresses.City = oDS_S_OCRD.Tables[0].Rows[0]["City"].ToString().Trim(); oPartner.Addresses.Country = oDS_S_OCRD.Tables[0].Rows[0]["Country"].ToString(); //oPartner.Addresses.State = oDS_S_OCRD.Tables[0].Rows[0]["Name"].ToString(); oPartner.Addresses.Add(); retVal = oPartner.Add(); if (retVal != 0) { Singleton.objSqlDataAccess.UpdateLog(sKey, TransScenerio.Customer.ToString(), "0", "0", 0, oCompany.GetLastErrorCode().ToString(), oCompany.GetLastErrorDescription().Replace("'", ""), strLogger); } else { string strDkey; oCompany.GetNewObjectCode(out strDkey); Singleton.objSqlDataAccess.UpdateLog(sKey, TransScenerio.Customer.ToString(), strDkey, strDkey, 1, "", "Armada_Sync Completed Sucessfully", strLogger); } } else { Singleton.objSqlDataAccess.UpdateLog(sKey, TransScenerio.Customer.ToString(), "", "", 1, "", "Armada_Sync Completed Sucessfully(Customer Already Exist)", strLogger); } } } } catch (Exception ex) { //Singleton.objSqlDataAccess.UpdateLog(sKey, TransScenerio.Customer.ToString(), "0", "0", 0, "0", ex.Message.ToString(), strLogger); throw ex; } finally { oDS_S_OCRD = null; System.Runtime.InteropServices.Marshal.ReleaseComObject(oPartner); } }
public string SPA_ProcessCase_Alternative(DataTable dt) { string sFuncName = "SPA_ProcessCase_Alternative"; string sDocType = string.Empty; try { if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Starting Function ", sFuncName); if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Connecting to target company ", sFuncName); oDICompany = oLogin.ConnectToTargetCompany(ConnectionString); foreach (DataRow iRow in dt.Rows) { sDocType = Convert.ToString(iRow["TrnspName"]); } if (sDocType == "ADD-PO-D") { } else if (sDocType == "ADD-PO") { } else if (sDocType == "GDOC") { } else if (sDocType == "SDOC") { } else if (sDocType == "OPDOC") { } else if (sDocType == "TDOC") { } else if (sDocType == "FWDOC") { } else if (sDocType == "MANUAL-FIN") { } else if (sDocType == "MANUAL-FIN-C") { } else if (sDocType == "MANUAL-IC") { } else if (sDocType == "FEES") { } if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Completed With SUCCESS ", sFuncName); } catch (Exception ex) { sErrDesc = ex.Message.ToString(); oLog.WriteToErrorLogFile(sErrDesc, sFuncName); if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Completed With ERROR ", sFuncName); throw ex; } return "SUCCESS"; }
public void SBO_Application_StatusBarEvent(string Text, SAPbobsCOM.Company sbo_company, ref Application sbo_application, BoStatusBarMessageType messageType) { }
public string SPA_ProcessCase_BrowseGenerate(string sFileName, DataTable dt) { string sFuncName = "SPA_ProcessCase_BrowseGenerate"; string sReturnResult = string.Empty; string sDocType = string.Empty; string sQuoteEntry = string.Empty; string sItemLine = string.Empty; SAPbobsCOM.Documents oSalesQuote; string sCaseNo = string.Empty; string sItemCode = string.Empty; try { if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Starting Function ", sFuncName); if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Connecting to target company ", sFuncName); oDICompany = oLogin.ConnectToTargetCompany(ConnectionString); foreach (DataRow iRow in dt.Rows) { sCaseNo = Convert.ToString(iRow["CaseNo"]); sItemCode = Convert.ToString(iRow["ItemCode"]); sDocType = Convert.ToString(iRow["TrnspName"]); sQuoteEntry = Convert.ToString(iRow["DocEntry"]); sItemLine = Convert.ToString(iRow["LineNum"]); //AFTER CALLING GOPI'S PROGRAM TO GENERATE PDF FILE THE FILE NAME TO BE SAVED IN sFileName VARIABLE //sFileName = "CS_ITM_20151016"; if (sFileName != string.Empty) { oSalesQuote = oDICompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oQuotations); if (sDocType == "GDOC") { if (oSalesQuote.GetByKey(Convert.ToInt16(sQuoteEntry))) { oSalesQuote.Lines.SetCurrentLine(Convert.ToInt16(sItemLine)); oSalesQuote.Lines.UserFields.Fields.Item("U_RESULTS_FILE").Value = sFileName; oSalesQuote.Lines.UserFields.Fields.Item("U_STATUS").Value = "ACCEPT"; oSalesQuote.Lines.UserFields.Fields.Item("U_PROCESS_LAST_UPDAT").Value = DateTime.Now.Date; oSalesQuote.Lines.UserFields.Fields.Item("U_PROCESS_ACCEPT_DAT").Value = DateTime.Now.Date; oSalesQuote.Lines.UserFields.Fields.Item("U_PROCESS_ACCEPTBY").Value = Convert.ToString(iRow["UserName"]); Updateddate(sCaseNo, sItemCode, oDICompany); if (oSalesQuote.Update() != 0) { sErrDesc = oDICompany.GetLastErrorDescription(); throw new ArgumentException(sErrDesc); } } } } } if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Completed With SUCCESS ", sFuncName); } catch (Exception ex) { sErrDesc = ex.Message.ToString(); oLog.WriteToErrorLogFile(sErrDesc, sFuncName); if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Completed With ERROR ", sFuncName); throw ex; } return "SUCCESS"; }
public void SBO_Application_WidgetEvent(WidgetData pWidgetData, SAPbobsCOM.Company sbo_company, ref Application sbo_application, out bool bBubbleEvent) { bBubbleEvent = true; }
public string SPA_ProcessCase_BrowseUpload(DataTable dt, string sFileName, string sStatus) { string sFuncName = "SPA_ProcessCase_BrowseUpload"; string sDocType = string.Empty; //string sFileName = string.Empty; string sQuoteEntry = string.Empty; string sItemLine = string.Empty; string sItemCode = string.Empty; SAPbobsCOM.Documents oSalesQuote; //string sStatus = string.Empty; DataTable results = new DataTable(); DataTable results1 = new DataTable(); int sScanCount = 0; string sActionBy = string.Empty; string sSql = string.Empty; SAPbobsCOM.Recordset oRecSet; string sCaseNo = string.Empty; try { if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Starting Function ", sFuncName); SqlConnection con = new SqlConnection(ConnectionString); SqlCommand command = con.CreateCommand(); if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Connecting to target company ", sFuncName); oDICompany = oLogin.ConnectToTargetCompany(ConnectionString); foreach (DataRow iRow in dt.Rows) { sCaseNo = Convert.ToString(iRow["CaseNo"]); sDocType = Convert.ToString(iRow["TrnspName"]); sQuoteEntry = Convert.ToString(iRow["DocEntry"]); sItemLine = Convert.ToString(iRow["LineNum"]); sItemCode = Convert.ToString(iRow["ItemCode"]); if (sFileName != string.Empty) { oSalesQuote = oDICompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oQuotations); if (sDocType == "ADD-PO-D") { //NEED TO CALL GOPI'S PROGRAM VALIDATE FILE WITH ITEM CODE AND SET THE RESULT TO THE VARIABLE //sStatus = "0"; if (sStatus == "0") { sStatus = "ACCEPT"; } else { sStatus = "FAIL"; } if (oSalesQuote.GetByKey(Convert.ToInt16(sQuoteEntry))) { oSalesQuote.Lines.SetCurrentLine(Convert.ToInt16(sItemLine)); oSalesQuote.Lines.UserFields.Fields.Item("U_NEXT_ACTION_BY").Value = "IC"; if (sStatus == "ACCEPT") { oSalesQuote.Lines.UserFields.Fields.Item("U_RESULTS_FILE").Value = sFileName; oSalesQuote.Lines.UserFields.Fields.Item("U_STATUS").Value = sStatus; Updateddate(sCaseNo, sItemCode, oDICompany); } else if (sStatus == "FAIL") { oSalesQuote.Lines.UserFields.Fields.Item("U_RESULTS_FILE").Value = sFileName; oSalesQuote.Lines.UserFields.Fields.Item("U_STATUS").Value = sStatus; sSql = "SELECT U_FAIL_CLOSE FROM OITM WITH (NOLOCK) WHERE ItemCode = '" + sItemCode + "'"; oRecSet = oDICompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); oRecSet.DoQuery(sSql); if (oRecSet.RecordCount > 0) { oSalesQuote.Lines.UserFields.Fields.Item("U_NEXT_ACTION_BY").Value = oRecSet.Fields.Item("U_FAIL_CLOSE").Value; } } if (oSalesQuote.Update() != 0) { sErrDesc = oDICompany.GetLastErrorDescription(); throw new ArgumentException(sErrDesc); } } } else if (sDocType == "ADD-PO") { //NEED TO CALL GOPI'S PROGRAM VALIDATE FILE WITH ITEM CODE AND SET THE RESULT TO THE VARIABLE //sStatus = "0"; if (sStatus == "0") { sStatus = "ACCEPT"; } else { sStatus = "FAIL"; } if (oSalesQuote.GetByKey(Convert.ToInt16(sQuoteEntry))) { oSalesQuote.Lines.SetCurrentLine(Convert.ToInt16(sItemLine)); oSalesQuote.Lines.UserFields.Fields.Item("U_NEXT_ACTION_BY").Value = "IC"; if (sStatus == "ACCEPT") { oSalesQuote.Lines.UserFields.Fields.Item("U_RESULTS_FILE").Value = sFileName; oSalesQuote.Lines.UserFields.Fields.Item("U_STATUS").Value = sStatus; Updateddate(sCaseNo, sItemCode, oDICompany); } else if (sStatus == "FAIL") { oSalesQuote.Lines.UserFields.Fields.Item("U_RESULTS_FILE").Value = sFileName; oSalesQuote.Lines.UserFields.Fields.Item("U_STATUS").Value = sStatus; sSql = "SELECT U_FAIL_CLOSE FROM OITM WITH (NOLOCK) WHERE ItemCode = '" + sItemCode + "'"; oRecSet = oDICompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); oRecSet.DoQuery(sSql); if (oRecSet.RecordCount > 0) { oSalesQuote.Lines.UserFields.Fields.Item("U_NEXT_ACTION_BY").Value = oRecSet.Fields.Item("U_FAIL_CLOSE").Value; } } if (oSalesQuote.Update() != 0) { sErrDesc = oDICompany.GetLastErrorDescription(); throw new ArgumentException(sErrDesc); } } } else if (sDocType == "SDOC") { command.CommandText = "select IsNull(U_ScanCount,0) [ScanCount] from QUT1 WITH (NOLOCK) where DocEntry = '" + sQuoteEntry + "' and LineNum = '" + sItemLine + "'"; con.Open(); SqlDataAdapter dataAdapter = new SqlDataAdapter(command); dataAdapter.Fill(results); con.Close(); if (results.Rows.Count > 0) { sScanCount = Convert.ToInt32(results.Rows[0][0]); } //CALL GOPI'S PROGRAM TO GET THE FILE NAME AFTER UPLOAD //sFileName = "CS_UPLOAD_FILE_20151016"; //CALL GOPI'S PROGRAM TO GET THE STATUS sStatus = "0"; if (sStatus == "0") { sStatus = "ACCEPT"; } else { sStatus = "FAIL"; } if (oSalesQuote.GetByKey(Convert.ToInt16(sQuoteEntry))) { oSalesQuote.Lines.SetCurrentLine(Convert.ToInt16(sItemLine)); oSalesQuote.Lines.UserFields.Fields.Item("U_RESULTS_FILE").Value = sFileName; oSalesQuote.Lines.UserFields.Fields.Item("U_STATUS").Value = sStatus; oSalesQuote.Lines.UserFields.Fields.Item("U_PROCESS_LAST_UPDAT").Value = DateTime.Now.Date; if (sStatus == "ACCEPT") { oSalesQuote.Lines.UserFields.Fields.Item("U_PROCESS_ACCEPT_DAT").Value = DateTime.Now.Date; oSalesQuote.Lines.UserFields.Fields.Item("U_PROCESS_ACCEPTBY").Value = Convert.ToString(iRow["UserName"]); Updateddate(sCaseNo, sItemCode, oDICompany); } else if (sStatus == "FAIL") { oSalesQuote.Lines.UserFields.Fields.Item("U_PROCESS_FAIL_DAT").Value = DateTime.Now.Date; if (sScanCount > 5) { command.CommandText = "select U_FAIL_CLOSE from OITM WITH (NOLOCK) where ItemCode = '" + sItemCode + "'"; con.Open(); SqlDataAdapter dataAdapter1 = new SqlDataAdapter(command); dataAdapter1.Fill(results1); con.Close(); if (results1.Rows.Count > 0) { sActionBy = Convert.ToString(results1.Rows[0][0]); } } oSalesQuote.Lines.UserFields.Fields.Item("U_NEXT_ACTION_BY").Value = sActionBy; oSalesQuote.Lines.UserFields.Fields.Item("U_ScanCount").ValidValue = Convert.ToString(sScanCount + 1); } if (oSalesQuote.Update() != 0) { sErrDesc = oDICompany.GetLastErrorDescription(); throw new ArgumentException(sErrDesc); } } } else if (sDocType == "OPDOC") { //CALL GOPI'S PROGRAM TO GET THE FILE NAME AFTER UPLOAD //sFileName = "CS_UPLOAD_FILE_20151016"; if (oSalesQuote.GetByKey(Convert.ToInt16(sQuoteEntry))) { oSalesQuote.Lines.SetCurrentLine(Convert.ToInt16(sItemLine)); oSalesQuote.Lines.UserFields.Fields.Item("U_RESULTS_FILE").Value = sFileName; oSalesQuote.Lines.UserFields.Fields.Item("U_STATUS").Value = "ACCEPT"; oSalesQuote.Lines.UserFields.Fields.Item("U_PROCESS_LAST_UPDAT").Value = DateTime.Now.Date; oSalesQuote.Lines.UserFields.Fields.Item("U_PROCESS_ACCEPT_DAT").Value = DateTime.Now.Date; oSalesQuote.Lines.UserFields.Fields.Item("U_PROCESS_ACCEPTBY").Value = Convert.ToString(iRow["UserName"]); Updateddate(sCaseNo, sItemCode, oDICompany); if (oSalesQuote.Update() != 0) { sErrDesc = oDICompany.GetLastErrorDescription(); throw new ArgumentException(sErrDesc); } } } else if (sDocType == "TDOC") { //CALL GOPI'S PROGRAM TO GET THE FILE NAME AFTER UPLOAD //sFileName = "CS_UPLOAD_FILE_20151016"; //CALL GOPI'S PROGRAM TO VERIFY THE DOCUMENT AND SAVE THE RESULT TO THE VARIABLE sStatus = "0"; if (sStatus == "0") { sStatus = "ACCEPT"; } else { sStatus = "FAIL"; } if (oSalesQuote.GetByKey(Convert.ToInt16(sQuoteEntry))) { oSalesQuote.Lines.SetCurrentLine(Convert.ToInt16(sItemLine)); oSalesQuote.Lines.UserFields.Fields.Item("U_RESULTS_FILE").Value = sFileName; oSalesQuote.Lines.UserFields.Fields.Item("U_STATUS").Value = sStatus; oSalesQuote.Lines.UserFields.Fields.Item("U_PROCESS_LAST_UPDAT").Value = DateTime.Now.Date; if (sStatus == "ACCEPT") { oSalesQuote.Lines.UserFields.Fields.Item("U_PROCESS_ACCEPT_DAT").Value = DateTime.Now.Date; oSalesQuote.Lines.UserFields.Fields.Item("U_PROCESS_ACCEPTBY").Value = Convert.ToString(iRow["UserName"]); Updateddate(sCaseNo, sItemCode, oDICompany); } else if (sStatus == "FAIL") { oSalesQuote.Lines.UserFields.Fields.Item("U_PROCESS_FAIL_DAT").Value = DateTime.Now.Date; } if (oSalesQuote.Update() != 0) { sErrDesc = oDICompany.GetLastErrorDescription(); throw new ArgumentException(sErrDesc); } } } } } if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Completed With SUCCESS ", sFuncName); } catch (Exception ex) { sErrDesc = ex.Message.ToString(); oLog.WriteToErrorLogFile(sErrDesc, sFuncName); if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Completed With ERROR ", sFuncName); throw ex; } return "SUCCESS"; }
public void SBO_Application_FormDataEvent(ref BusinessObjectInfo businessObjectInfo, SAPbobsCOM.Company sbo_company, ref Application sbo_application, out bool bBubbleEvent, string sessionId) { bBubbleEvent = true; switch (businessObjectInfo.FormTypeEx) { case pluginForm.FormType: frmCalidad.FormDataEventHandler(ref businessObjectInfo, sbo_company, ref sbo_application, out bBubbleEvent, sessionId); break; } }
// Written by Jeeva public string SPA_ProcessCase_CreateBilling(DataTable dt) { DataSet oDataset = new DataSet(); string sFuncName = string.Empty; string sProcName = string.Empty; DataView oDTView = new DataView(); string sResult = string.Empty; string sCardCode = string.Empty; string sQuoteEntry = string.Empty; string sSalesEntry = string.Empty; string sPurchaseEntry = string.Empty; string sApInvEntry = string.Empty; string sDocType = string.Empty; string sItemLine = string.Empty; string sCaseNo = string.Empty; try { sFuncName = "SPA_ProcessCase_CreateBilling()"; if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Starting Function ", sFuncName); if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Connecting to target company ", sFuncName); oDICompany = oLogin.ConnectToTargetCompany(ConnectionString); foreach (DataRow iRow in dt.Rows) { sDocType = Convert.ToString(iRow["TrnspName"]); sQuoteEntry = Convert.ToString(iRow["DocEntry"]); sItemLine = Convert.ToString(iRow["LineNum"]); sCaseNo = Convert.ToString(iRow["CaseNo"]); if (sDocType == "ADD-PO-D") { oDICompany.StartTransaction(); sSalesEntry = AddDocuments(dt, oDICompany, sDocType); if (sSalesEntry == string.Empty) { if (oDICompany.InTransaction == true) { oDICompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack); } else { oDICompany.StartTransaction(); oDICompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack); } throw new ArgumentException(sErrDesc); } else if (sSalesEntry != string.Empty) { sPurchaseEntry = CreatePO(sSalesEntry, oDICompany, dt); if (sPurchaseEntry == string.Empty) { if (oDICompany.InTransaction == true) { oDICompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack); } else { oDICompany.StartTransaction(); oDICompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack); } throw new ArgumentException(sErrDesc); } else if (sPurchaseEntry != string.Empty) { sApInvEntry = CreateAPInv(sPurchaseEntry, oDICompany, sCaseNo); if (sApInvEntry == string.Empty) { if (oDICompany.InTransaction == true) { oDICompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack); } else { oDICompany.StartTransaction(); oDICompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack); } throw new ArgumentException(sErrDesc); } } } if (sQuoteEntry != string.Empty) { SAPbobsCOM.Documents oSalesQuote; oSalesQuote = oDICompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oQuotations); if (oSalesQuote.GetByKey(Convert.ToInt16(sQuoteEntry))) { oSalesQuote.Lines.SetCurrentLine(Convert.ToInt16(sItemLine)); oSalesQuote.Lines.UserFields.Fields.Item("U_NEXT_ACTION_BY").Value = "FN"; oSalesQuote.Lines.UserFields.Fields.Item("U_PROCESS_LAST_UPDAT").Value = DateTime.Now.Date; if (oSalesQuote.Update() != 0) { sErrDesc = oDICompany.GetLastErrorDescription(); throw new ArgumentException(sErrDesc); } } } oDICompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_Commit); } else if (sDocType == "ADD-PO") { oDICompany.StartTransaction(); sSalesEntry = AddDocuments(dt, oDICompany, sDocType); if (sSalesEntry == string.Empty) { if (oDICompany.InTransaction == true) { oDICompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack); } else { oDICompany.StartTransaction(); oDICompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack); } throw new ArgumentException(sErrDesc); } else if (sSalesEntry != string.Empty) { sPurchaseEntry = CreatePO(sSalesEntry, oDICompany, dt); if (sPurchaseEntry == string.Empty) { if (oDICompany.InTransaction == true) { oDICompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack); } else { oDICompany.StartTransaction(); oDICompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack); } throw new ArgumentException(sErrDesc); } else if (sPurchaseEntry != string.Empty) { sApInvEntry = CreateAPInv(sPurchaseEntry, oDICompany, sCaseNo); if (sApInvEntry == string.Empty) { if (oDICompany.InTransaction == true) { oDICompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack); } else { oDICompany.StartTransaction(); oDICompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack); } throw new ArgumentException(sErrDesc); } } } if (sQuoteEntry != string.Empty) { SAPbobsCOM.Documents oSalesQuote; oSalesQuote = oDICompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oQuotations); if (oSalesQuote.GetByKey(Convert.ToInt16(sQuoteEntry))) { oSalesQuote.Lines.SetCurrentLine(Convert.ToInt16(sItemLine)); oSalesQuote.Lines.UserFields.Fields.Item("U_NEXT_ACTION_BY").Value = "FN"; oSalesQuote.Lines.UserFields.Fields.Item("U_PROCESS_LAST_UPDAT").Value = DateTime.Now.Date; if (oSalesQuote.Update() != 0) { sErrDesc = oDICompany.GetLastErrorDescription(); throw new ArgumentException(sErrDesc); } } } oDICompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_Commit); } else if (sDocType == "FEES") { oDICompany.StartTransaction(); sSalesEntry = AddDocuments(dt, oDICompany, sDocType); if (sSalesEntry == string.Empty) { if (oDICompany.InTransaction == true) { oDICompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack); } else { oDICompany.StartTransaction(); oDICompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack); } throw new ArgumentException(sErrDesc); } if (sQuoteEntry != string.Empty) { SAPbobsCOM.Documents oSalesQuote; oSalesQuote = oDICompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oQuotations); if (oSalesQuote.GetByKey(Convert.ToInt16(sQuoteEntry))) { oSalesQuote.Lines.SetCurrentLine(Convert.ToInt16(sItemLine)); oSalesQuote.Lines.UserFields.Fields.Item("U_STATUS").Value = "ACCEPT"; oSalesQuote.Lines.UserFields.Fields.Item("U_PROCESS_LAST_UPDAT").Value = DateTime.Now.Date; oSalesQuote.Lines.UserFields.Fields.Item("U_PROCESS_ACCEPT_DAT").Value = DateTime.Now.Date; oSalesQuote.Lines.UserFields.Fields.Item("U_PROCESS_ACCEPTBY").Value = Convert.ToString(iRow["UserName"]); if (oSalesQuote.Update() != 0) { sErrDesc = oDICompany.GetLastErrorDescription(); throw new ArgumentException(sErrDesc); } } } oDICompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_Commit); } } // Note : Write the comments while doing the sResult = "SUCCESS"; return sResult; } catch (Exception Ex) { sErrDesc = Ex.Message.ToString(); oLog.WriteToErrorLogFile(sErrDesc, sFuncName); if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Completed With ERROR ", sFuncName); sResult = Ex.Message.ToString(); if (oDICompany.InTransaction) oDICompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack); throw Ex; } }
public void SBO_Application_LayoutKeyEvent(ref LayoutKeyInfo eventInfo, SAPbobsCOM.Company sbo_company, ref Application sbo_application, out bool bBubbleEvent) { bBubbleEvent = true; }
public override void CreateForm(SAPbouiCOM.Application SboApp, string strXml, SAPbobsCOM.Company cmp, string frmId) { base.CreateForm(SboApp, strXml, cmp, frmId); oForm.EnableMenu("1282", false); // Add New Record oForm.EnableMenu("1288", false); // Next Record oForm.EnableMenu("1289", false); // Pevious Record oForm.EnableMenu("1290", false); // First Record oForm.EnableMenu("1291", false); // Last record oForm.EnableMenu("1281", false); // Find record AllRules.Columns.Add("RULE"); AllRules.Columns.Add("Descr"); AllRules.Columns.Add("VisOrder"); InitiallizeForm(); // oForm.Items.Item("btUpd").Visible = false; }
public void SBO_Application_ProgressBarEvent(ref ProgressBarEvent pVal, SAPbobsCOM.Company sbo_company, ref Application sbo_application, out bool bBubbleEvent) { bBubbleEvent = true; }
public void SBO_Application_FormDataEvent(ref BusinessObjectInfo businessObjectInfo, SAPbobsCOM.Company sbo_company, ref Application sbo_application, out bool bBubbleEvent, string sessionId) { bBubbleEvent = true; }
public void SBO_Application_RightClickEvent(ref ContextMenuInfo eventInfo, SAPbobsCOM.Company sbo_company, ref Application sbo_application, out bool bBubbleEvent) { bBubbleEvent = true; }
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); } }
public Backup() { logs.Clear(); WriteLog("[Log]", "--------------------------------------------------------------------------------"); WriteLog("[Log]", "Integration Begin:[" + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss tt") + "]"); #region Connect to SAP SAPbobsCOM.Company oCom = new SAPbobsCOM.Company(); string dbServerType = ConfigurationManager.AppSettings.Get("dbServerType"); if (dbServerType == "MSSQL2005") { oCom.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2005; } else if (dbServerType == "MSSQL2008") { oCom.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2008; } else if (dbServerType == "MSSQL2012") { oCom.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2012; } else if (dbServerType == "MSSQL2014") { oCom.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2014; } else if (dbServerType == "HANADB") { oCom.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_HANADB; } else if (dbServerType == "DB_2") { oCom.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_DB_2; } oCom.Server = ConfigurationManager.AppSettings.Get("Server"); oCom.DbUserName = ConfigurationManager.AppSettings.Get("dbuser"); oCom.DbPassword = ConfigurationManager.AppSettings.Get("dbpass"); oCom.LicenseServer = ConfigurationManager.AppSettings.Get("LicenseServer"); oCom.CompanyDB = ConfigurationManager.AppSettings.Get("CompanyDB"); oCom.UserName = ConfigurationManager.AppSettings.Get("UserName"); oCom.Password = ConfigurationManager.AppSettings.Get("Password"); oCom.language = SAPbobsCOM.BoSuppLangs.ln_English; if (oCom.Connect() != 0) { WriteLog("[Error]", "Connection:[" + oCom.CompanyDB + "] Message:[" + oCom.GetLastErrorDescription() + "] Time:[" + DateTime.Now.ToString("hh: mm:ss tt") + "]"); goto EndApplication; } WriteLog("[Log]", "Connected to:[" + oCom.CompanyName + "] Time:[" + DateTime.Now.ToString("hh:mm:ss tt") + "]"); #endregion #region Connect to Data Source SqlConnection conn = new SqlConnection(conString); SqlCommand cmd = new SqlCommand("", conn); conn.Close(); try { conn.Open(); } catch (Exception ex) { WriteLog("[Error]", "Data Source Connection : " + DateTime.Now.ToString() + " : " + ex.Message); goto EndApplication; } SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(conString); string server = builder.DataSource; string database = builder.InitialCatalog; WriteLog("[Log]", "Connected to Data Source:[" + database + "] Time:[" + DateTime.Now.ToString("hh:mm:ss tt") + "]"); cmd.CommandText = "SELECT ROW_NUMBER() over (Partition by BaseEntry Order by BaseEntry )-1 as [Line], * " + "FROM [dbo].[ProductionReceipt] T0 Where IsNull(T0.Posted,'N') <> 'Y'"; SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); int nGR = dt.Rows.Count; if (nGR == 0) { WriteLog("[Log]", "No production receipt to import!"); conn.Close(); da.Dispose(); goto EndApplication; } List <int> idList = new List <int>(); Dictionary <int, DataTable> doc = new Dictionary <int, DataTable>(); //Parsing data into header and details foreach (DataRow row in dt.Rows) { int baseEntry = int.Parse(row["BaseEntry"].ToString()); if (doc.ContainsKey(baseEntry)) { DataTable dtDoc = doc[baseEntry]; dtDoc.ImportRow(row); doc[baseEntry] = dtDoc; } else { DataTable dtDoc = dt.Clone(); dtDoc.ImportRow(row); doc.Add(baseEntry, dtDoc); } } WriteLog("[Log]", "Record found:[" + doc.Keys.Count + "] Total Rows:[" + dt.Rows.Count + "]"); oCom.StartTransaction(); int n = 0; foreach (var item in doc) { try { SAPbobsCOM.Documents oDocReceipt = (SAPbobsCOM.Documents)oCom.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInventoryGenEntry); SAPbobsCOM.ProductionOrders oDocProductionOrders = (SAPbobsCOM.ProductionOrders)oCom.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oProductionOrders); SAPbobsCOM.Items oItem = oCom.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oItems); DataTable dtDoc = doc[item.Key]; DataRow hRow = dtDoc.Rows[0]; int retcode = 0; idList = new List <int>(); string itemCode = hRow["ItemCode"].ToString(); oItem.GetByKey(itemCode); SAPbobsCOM.BoYesNoEnum isManageBatchNumbers = oItem.ManageBatchNumbers; WriteLog("[Log]", "No:[" + (++n) + "] H:Production Order[" + hRow["DocNum"].ToString() + "] Base:[" + item.Key + "] TotalRows:[" + dtDoc.Rows.Count + "]" + " PlannedQty:" + hRow["Quantity"].ToString()); // Add Header ----------------------------------- string proNo = hRow["DocNum"].ToString(); int baseEntry = int.Parse(hRow["BaseEntry"].ToString()); oDocReceipt.Series = 53; oDocReceipt.DocDate = DateTime.Parse(hRow["DocDate"].ToString()); oDocReceipt.DocDueDate = DateTime.Parse(hRow["DocDueDate"].ToString()); oDocReceipt.Comments = hRow["Comments"].ToString(); oDocReceipt.JournalMemo = hRow["JournalMemo"].ToString(); // Add Details start ---------------------------- for (int i = 0; i < dtDoc.Rows.Count; i++) { DataRow row = dtDoc.Rows[i]; int id = int.Parse(row["Id"].ToString()); WriteLog("[Log]", "Id:[" + row["Id"].ToString() + "] R:[" + i + "] ItemCode:" + itemCode + "] BatchNo:" + row["DistNumber"].ToString() + " " + row["status"].ToString() + " Qty:" + row["BatchQuantity"].ToString()); idList.Add(id); oDocReceipt.Lines.Add(); oDocReceipt.Lines.SetCurrentLine(i); oDocReceipt.Lines.BaseType = (int)SAPbobsCOM.BoObjectTypes.oProductionOrders; oDocReceipt.Lines.BaseEntry = int.Parse(row["BaseEntry"].ToString()); //oDocReceipt.Lines.BaseLine = 0; oDocReceipt.Lines.Quantity = Double.Parse(row["BatchQuantity"].ToString()); //Batch Quantity = Receipt Quantity oDocReceipt.Lines.WarehouseCode = "KH010"; oDocReceipt.Lines.FreeText = row["Notes"].ToString(); //oDocReceipt.Lines.WarehouseCode = row["WarehouseCode"].ToString(); string status = row["Status"].ToString().Trim(); oDocReceipt.Lines.TransactionType = (status == "AC") ? SAPbobsCOM.BoTransactionTypeEnum.botrntComplete : SAPbobsCOM.BoTransactionTypeEnum.botrntReject; if (isManageBatchNumbers.Equals("tYES")) { oDocReceipt.Lines.BatchNumbers.BatchNumber = row["DistNumber"].ToString(); oDocReceipt.Lines.BatchNumbers.Quantity = Double.Parse(row["BatchQuantity"].ToString()); if (!String.IsNullOrEmpty(row["ExpiryDate"].ToString())) { oDocReceipt.Lines.BatchNumbers.ExpiryDate = DateTime.Parse(row["ExpiryDate"].ToString()); } if (!String.IsNullOrEmpty(row["MnfDate"].ToString())) { oDocReceipt.Lines.BatchNumbers.ManufacturingDate = DateTime.Parse(row["MnfDate"].ToString()); } if (!String.IsNullOrEmpty(row["InDate"].ToString())) { oDocReceipt.Lines.BatchNumbers.AddmisionDate = DateTime.Parse(row["InDate"].ToString()); } oDocReceipt.Lines.BatchNumbers.Notes = row["Notes"].ToString(); oDocReceipt.Lines.BatchNumbers.Add(); } // add line end -------------------- } retcode = oDocReceipt.Add(); if (retcode == 0) { // Success string docEntry = ""; string docNum = ""; oCom.GetNewObjectCode(out docEntry); if (docEntry == "") { errMsg = "Unknown Error! Please try again!"; if (oCom.InTransaction) { oCom.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack); } WriteLog("[Error]", "Production Receipt:" + errMsg); continue; } SAPbobsCOM.Documents sapDoc = (SAPbobsCOM.Documents)oCom.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInventoryGenEntry); if (sapDoc.GetByKey(int.Parse(docEntry))) { docNum = sapDoc.DocNum.ToString(); } foreach (int id in idList) { string str = "exec sp_FT_UpdateProductionOrder '" + id + "','Y','" + "" + "','" + docNum + "'"; SqlCommand cmdExec = new SqlCommand(str, conn); cmdExec.ExecuteNonQuery(); WriteLog("[Success]", "Production Receipt:[" + docNum + "] has been added!"); } if (oCom.InTransaction) { oCom.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_Commit); } cmd.CommandText = "SELECT CASE WHEN Sum(isNull(BatchQuantity,0.00)) >= MAX(T0.Quantity) Then 1 else 0 END " + "FROM[dbo].[ProductionReceipt] T0 " + "Where ISNULL(T0.Posted,'N') = 'Y' AND T0.BaseEntry=" + baseEntry + " GROUP BY T0.BaseEntry"; Int32 totalReceived = (Int32)cmd.ExecuteScalar(); // Closed Production if (oDocProductionOrders.GetByKey(baseEntry) && totalReceived == 1) { string msg = "Production Order:[" + oDocProductionOrders.DocumentNumber.ToString() + "] has been closed!"; string rmk = oDocProductionOrders.Remarks; oDocProductionOrders.ProductionOrderStatus = SAPbobsCOM.BoProductionOrderStatusEnum.boposClosed; oDocProductionOrders.Remarks = rmk + " :closed by integration"; //oDocProductionOrders.ProductionOrderStatus = SAPbobsCOM.BoProductionOrderStatusEnum.boposCancelled; oDocProductionOrders.Update(); WriteLog("[Success]", msg); foreach (int id in idList) { string str = "exec sp_FT_UpdateProductionOrder '" + id + "','Y','" + msg + "','" + docNum + "'"; SqlCommand cmdExec = new SqlCommand(str, conn); cmdExec.ExecuteNonQuery(); } } } else { // Error oCom.GetLastError(out errCode, out errMsg); foreach (int id in idList) { string str = "exec sp_FT_UpdateProductionOrder '" + id + "','N','" + errMsg.Replace("'", "") + "',''"; SqlCommand cmdExec = new SqlCommand(str, conn); cmdExec.ExecuteNonQuery(); } WriteLog("[Error]", "Production Order:[" + proNo + "] Error Msg:" + oCom.GetLastErrorDescription()); if (oCom.InTransaction) { oCom.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack); } } } catch (Exception ex) { oCom.GetLastError(out errCode, out errMsg); string msg = (ex.Message + " SAP msg:" + errMsg).Replace("'", ""); foreach (int id in idList) { string str = "exec sp_FT_UpdateProductionOrder '" + id + "','N','" + msg + "','" + "" + "'"; SqlCommand cmdExec = new SqlCommand(str, conn); cmdExec.ExecuteNonQuery(); } WriteLog("[Error]", "Production Receipt:" + msg); } } #endregion EndApplication: bool sendEmail = false; foreach (KeyValuePair <string, List <string> > kvp in logs) { string status = kvp.Key; List <string> msgs = kvp.Value; if (status == "[Error]") { sendEmail = true; } } if (sendEmail) { WriteLog("[Log]", " ➜ Send E-Mail"); SendEmail(); } ; WriteLog("", "Integration End"); //Thread.Sleep(3000); }
/// <summary> /// Handle Return Code /// Throws Exception if Return Code != 0 /// </summary> /// <param name="returnCode"></param> /// <param name="errorDescription"></param> public static void HandleErrorWithException(int returnCode, string errorDescription, SAPbobsCOM.Company company = null) { if (returnCode == 0) { return; } var error = GetLastErrorMessage(company); throw new Exception($"{errorDescription}: {error.Code} {error.Message}"); }
private void LoadComboQueryRecordset(string _query, dynamic oComboBox, string fieldValue, string fieldDesc, SAPbobsCOM.Company oCompany) { //oApp = (SAPbouiCOM.Application)Application.SBO_Application; //oCompany = (SAPbobsCOM.Company)oApp.Company.GetDICompany(); SAPbobsCOM.Recordset businessObject = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); businessObject.DoQuery(_query); SAPbouiCOM.ValidValues validValues = oComboBox.ValidValues; CleanComboBox(oComboBox); if (!string.Equals(fieldDesc, string.Empty)) { while (!businessObject.EoF) { validValues.Add((dynamic)businessObject.Fields.Item(fieldValue).Value, (dynamic)businessObject.Fields.Item(fieldDesc).Value); businessObject.MoveNext(); } } else { while (!businessObject.EoF) { validValues.Add((dynamic)businessObject.Fields.Item(fieldValue).Value, ""); businessObject.MoveNext(); } } }
private static void Main(string[] args) { try { SAPbouiCOM.Framework.Application oApp = null; if (args.Length < 1) { oApp = new SAPbouiCOM.Framework.Application(); } else { oApp = new SAPbouiCOM.Framework.Application(args[0]); } #region Log string AddOn = AppDomain.CurrentDomain.FriendlyName.Replace(".exe", ""); string User = Environment.UserName + "." + Environment.UserDomainName; string PId = System.Diagnostics.Process.GetCurrentProcess().Id.ToString(); string Path = $"C:\\ProgramData\\SAP\\SAP Business One\\Log\\{AddOn}\\{User}"; System.Threading.Tasks.Task.Run(() => CommonFunctions.DeleteOldLogFiles(Path)); if (!Directory.Exists(Path)) { Directory.CreateDirectory(Path); } LogFile = $"{Path}\\{AddOn}.{DateTime.Now.ToString("yyyyMMdd_HH.mm.ss")}.pid{PId}.log.csv"; #endregion Log sbo_application = SAPbouiCOM.Framework.Application.SBO_Application; sbo_company = (SAPbobsCOM.Company)sbo_application.Company.GetDICompany(); #if DEBUG sbo_application.StatusBar.SetText(string.Format("{0} = {1}", DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"), "Conectando al SL"), SAPbouiCOM.BoMessageTime.bmt_Medium, SAPbouiCOM.BoStatusBarMessageType.smt_Warning); #endif sessionId = sbo_application.Company.GetServiceLayerConnectionContext(ServiceLayer.Address); #if DEBUG sbo_application.StatusBar.SetText(string.Format("{0} = {1}", DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"), "SL conectado"), SAPbouiCOM.BoMessageTime.bmt_Medium, SAPbouiCOM.BoStatusBarMessageType.smt_Warning); #endif oNumberFormatInfo.NumberDecimalSeparator = sbo_company.GetCompanyService().GetAdminInfo().DecimalSeparator; oNumberFormatInfo.NumberGroupSeparator = sbo_company.GetCompanyService().GetAdminInfo().ThousandsSeparator; RemoveMenus(); AddMenuItems(); sbo_application.MenuEvent += new SAPbouiCOM._IApplicationEvents_MenuEventEventHandler(SBO_Application_MenuEvent); sbo_application.AppEvent += new SAPbouiCOM._IApplicationEvents_AppEventEventHandler(SBO_Application_AppEvent); sbo_application.ItemEvent += new SAPbouiCOM._IApplicationEvents_ItemEventEventHandler(SBO_Application_ItemEvent); sbo_application.FormDataEvent += new SAPbouiCOM._IApplicationEvents_FormDataEventEventHandler(SBO_Application_FormDataEvent); sbo_application.ReportDataEvent += new SAPbouiCOM._IApplicationEvents_ReportDataEventEventHandler(SBO_Application_ReportDataEvent); sbo_application.PrintEvent += new SAPbouiCOM._IApplicationEvents_PrintEventEventHandler(SBO_Application_PrintEvent); sbo_application.RightClickEvent += new SAPbouiCOM._IApplicationEvents_RightClickEventEventHandler(SBO_Application_RightClickEvent); sbo_application.ProgressBarEvent += new SAPbouiCOM._IApplicationEvents_ProgressBarEventEventHandler(SBO_Application_ProgressBarEvent); sbo_application.StatusBar.SetText(string.Format("Revisando la estructura de la base de datos"), SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning); //System.Threading.Tasks.Task.Run(() => LoadUserTablesMDToXmlFile(AddonNamespace)); //System.Threading.Tasks.Task.Run(() => LoadUserFieldMDToXmlFile(AddonNamespace)); //System.Threading.Tasks.Task.Run(() => LoadUserObjectsMDToXmlFile(AddonNamespace)); //try{LoadUserTablesMDFromXmlFile(UserTablesFile);} catch (Exception e) {sbo_application.StatusBar.SetText(e.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning);} //try{LoadUserFieldMDFromXmlFile(UserFieldsFile);} catch (Exception e) {sbo_application.StatusBar.SetText(e.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning);} //try{LoadUserObjectMDFromXmlFile(UserObjectsFile);} catch (Exception e) {sbo_application.StatusBar.SetText(e.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning);} CommonFunctions.GET(ServiceLayer.ActivityLocations, null, null, sessionId, out _); sbo_application.StatusBar.SetText(string.Format("Revision completada"), SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success); sbo_application.StatusBar.SetText($"Addon {AddOnName} conectado", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success); #if DEBUG Console.WriteLine(string.Format("{0} = {1}", DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"), "Addon cargado")); #endif oApp.Run(); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); } }
//This Method is for the SAP BP Master Creation; //public string SPA_AddCase(DataTable dtDatatable) //{ // DataSet oDataset = new DataSet(); // string sFuncName = string.Empty; // string sProcName = string.Empty; // DataView oDTView = new DataView(); // string sResult = string.Empty; // string sCardCode = string.Empty; // string sDocEntry = string.Empty; // try // { // sFuncName = "SPA_AddCase()"; // if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Starting Function ", sFuncName); // if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Before calling the Method SPA_AddCase_CheckStatus", sFuncName); // DataSet dsResult = SPA_AddCase_CheckStatus(); // if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("After calling the Method SPA_AddCase_CheckStatus", sFuncName); // if (dsResult != null && dsResult.Tables.Count > 0) // { // if (dsResult.Tables[0].Rows[0]["CaseStatus"].ToString() != string.Empty) // { // sCardCode = dsResult.Tables[0].Rows[0]["CardCode"].ToString(); // sDocEntry = dsResult.Tables[0].Rows[0]["DocEntry"].ToString(); // if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Connecting to target company ", sFuncName); // oDICompany = oLogin.ConnectToTargetCompany(ConnectionString); // SAPbobsCOM.BusinessPartners oBP = oDICompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oBusinessPartners); // oBP.GetByKey("SSS"); // oBP.UserFields.Fields.Item("").Value = ""; // //CUFD Table - For Listing the UDF's // //SAPbobsCOM.GeneralService oGeneralService = null; // //SAPbobsCOM.GeneralData oGeneralData; // //SAPbobsCOM.CompanyService oCompanyService = oDICompany.GetCompanyService(); // //SAPbobsCOM.GeneralDataParams oGeneralParams = null; // //oGeneralService = oCompanyService.GetGeneralService("OCRD"); // //oGeneralParams = (SAPbobsCOM.GeneralDataParams)oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralDataParams); // //oGeneralParams.SetProperty("DocEntry", sDocEntry); // //oGeneralData = oGeneralService.GetByParams(oGeneralParams); // //oGeneralData.SetProperty("QryGroup3", dsResult.Tables[0].Rows[0]["QryGroup3"].ToString()); // //oGeneralService.Update(oGeneralData); // //sResult = "Document Updated Successfully for the CardCode = " + sCardCode + " and DocEntry = " + sDocEntry; // } // else // { // string sUserName = dtDatatable.Rows[0]["UserName"].ToString(); // string sPassword = dtDatatable.Rows[0]["Password"].ToString(); // string sCategory = dtDatatable.Rows[0]["Category"].ToString(); // if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Before calling the Method SPA_AddCase_CheckStatus", sFuncName); // DataSet dsCardCode = SPA_AddCase_GetCardCode(sUserName, sPassword, sCategory); // if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("After calling the Method SPA_AddCase_CheckStatus", sFuncName); // sCardCode = dsCardCode.Tables[0].Rows[0]["CardCode"].ToString(); // sResult = "Add Document for the CardCode = " + sCardCode; // } // } // } // catch (Exception Ex) // { // sErrDesc = Ex.Message.ToString(); // oLog.WriteToErrorLogFile(sErrDesc, sFuncName); // if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Completed With ERROR ", sFuncName); // throw Ex; // } // return sResult; //} public string SPA_AddCase(DataTable dtDatatable, string sUserName) { DataSet oDataset = new DataSet(); DataTable dtAssignCase = new DataTable(); string sFuncName = string.Empty; string sProcName = string.Empty; DataView oDTView = new DataView(); string sResult = string.Empty; string sCardCode = string.Empty; string sDocEntry = string.Empty; bool isExists = false; try { sFuncName = "SPA_AddCase()"; if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Starting Function ", sFuncName); if (dtDatatable != null && dtDatatable.Rows.Count > 0) { //sCardCode = dsResult.Tables[0].Rows[0]["CardCode"].ToString(); //sDocEntry = dsResult.Tables[0].Rows[0]["DocEntry"].ToString(); DataRow dr = dtDatatable.Rows[0]; if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Connecting to target company ", sFuncName); oDICompany = oLogin.ConnectToTargetCompany(ConnectionString); SAPbobsCOM.BusinessPartners oBP = (SAPbobsCOM.BusinessPartners)(oDICompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oBusinessPartners)); if (oBP.GetByKey(dr["CardCode"].ToString())) { //exists isExists = true; } else { //not exists oBP.CardCode = dr["CardCode"].ToString(); } // oBP.CardCode = dr["CardCode"].ToString(); oBP.CardName = dr["CardName"].ToString(); oBP.CardForeignName = dr["CardFName"].ToString(); oBP.CardType = SAPbobsCOM.BoCardTypes.cCustomer; oBP.GroupCode = Convert.ToInt32(dr["GroupCode"]); oBP.PayTermsGrpCode = -1; oBP.Currency = dr["Currency"].ToString(); oBP.AdditionalID = dr["AddID"].ToString(); if (dr["QryGroup3"].ToString() == "Y") { oBP.set_Properties(3, SAPbobsCOM.BoYesNoEnum.tYES); } if (dr["QryGroup4"].ToString() == "Y") { oBP.set_Properties(4, SAPbobsCOM.BoYesNoEnum.tYES); } if (dr["QryGroup5"].ToString() == "Y") { oBP.set_Properties(5, SAPbobsCOM.BoYesNoEnum.tYES); } if (dr["QryGroup6"].ToString() == "Y") { oBP.set_Properties(6, SAPbobsCOM.BoYesNoEnum.tYES); } if (dr["QryGroup7"].ToString() == "Y") { oBP.set_Properties(7, SAPbobsCOM.BoYesNoEnum.tYES); } if (dr["QryGroup8"].ToString() == "Y") { oBP.set_Properties(8, SAPbobsCOM.BoYesNoEnum.tYES); } if (dr["QryGroup9"].ToString() == "Y") { oBP.set_Properties(9, SAPbobsCOM.BoYesNoEnum.tYES); } if (dr["QryGroup10"].ToString() == "Y") { oBP.set_Properties(10, SAPbobsCOM.BoYesNoEnum.tYES); } if (dr["QryGroup11"].ToString() == "Y") { oBP.set_Properties(11, SAPbobsCOM.BoYesNoEnum.tYES); } if (dr["QryGroup17"].ToString() == "Y") { oBP.set_Properties(17, SAPbobsCOM.BoYesNoEnum.tYES); } if (dr["QryGroup21"].ToString() == "Y") { oBP.set_Properties(21, SAPbobsCOM.BoYesNoEnum.tYES); } if (dr["U_PROPERTY_CHARGED"].ToString() == "Y") { oBP.set_Properties(12, SAPbobsCOM.BoYesNoEnum.tYES); oBP.set_Properties(13, SAPbobsCOM.BoYesNoEnum.tNO); } if (dr["U_PROPERTY_FREE"].ToString() == "Y") { oBP.set_Properties(12, SAPbobsCOM.BoYesNoEnum.tNO); oBP.set_Properties(13, SAPbobsCOM.BoYesNoEnum.tYES); } oBP.DebitorAccount = dr["DebPayAcct"].ToString(); //if cardCode without 'C', then its DebPayAcct else SalesDebPayAcct oBP.ProjectCode = dr["ProjectCod"].ToString(); oBP.OwnerIDNumber = dr["U_CASE_BRANCH"].ToString(); oBP.UserFields.Fields.Item("U_CASESTATUS").Value = dr["U_CASESTATUS"].ToString(); oBP.UserFields.Fields.Item("U_FILEOPENDATE").Value = dr["U_FILEOPENDATE"].ToString(); //oBP.UserFields.Fields.Item("U_PARTNER_EMPID").Value = dr["U_PARTNER_EMPID"].ToString(); //oBP.UserFields.Fields.Item("U_LA_EMPID").Value = dr["U_LA_EMPID"].ToString(); //oBP.UserFields.Fields.Item("U_MANAGER_EMPID").Value = dr["U_MANAGER_EMPID"].ToString(); //oBP.UserFields.Fields.Item("U_IC_EMPID").Value = dr["U_IC_EMPID"].ToString(); //oBP.UserFields.Fields.Item("U_CS_EMPID").Value = dr["U_CS_EMPID"].ToString(); oBP.UserFields.Fields.Item("U_PURCH_RP_ID1").Value = dr["U_PURCH_RP_ID1"].ToString(); oBP.UserFields.Fields.Item("U_PURCH_RP_NAME1").Value = dr["U_PURCH_RP_NAME1"].ToString(); oBP.UserFields.Fields.Item("U_PURCH_RP_CODE1").Value = dr["U_PURCH_RP_CODE1"].ToString(); oBP.UserFields.Fields.Item("U_PURCH_RP_TAX1").Value = dr["U_PURCH_RP_TAX1"].ToString(); oBP.UserFields.Fields.Item("U_PURCH_CONTACT1").Value = dr["U_PURCH_CONTACT1"].ToString(); oBP.UserFields.Fields.Item("U_PURCH_IDTYPE1").Value = dr["U_PURCH_IDTYPE1"].ToString(); oBP.UserFields.Fields.Item("U_PURCH_RP_ID2").Value = dr["U_PURCH_RP_ID2"].ToString(); oBP.UserFields.Fields.Item("U_PURCH_RP_NAME2").Value = dr["U_PURCH_RP_NAME2"].ToString(); oBP.UserFields.Fields.Item("U_PURCH_RP_CODE2").Value = dr["U_PURCH_RP_CODE2"].ToString(); oBP.UserFields.Fields.Item("U_PURCH_RP_TAX2").Value = dr["U_PURCH_RP_TAX2"].ToString(); oBP.UserFields.Fields.Item("U_PURCH_CONTACT2").Value = dr["U_PURCH_CONTACT2"].ToString(); oBP.UserFields.Fields.Item("U_PURCH_IDTYPE2").Value = dr["U_PURCH_IDTYPE2"].ToString(); oBP.UserFields.Fields.Item("U_PURCH_RP_ID3").Value = dr["U_PURCH_RP_ID3"].ToString(); oBP.UserFields.Fields.Item("U_PURCH_RP_NAME3").Value = dr["U_PURCH_RP_NAME3"].ToString(); oBP.UserFields.Fields.Item("U_PURCH_RP_CODE3").Value = dr["U_PURCH_RP_CODE3"].ToString(); oBP.UserFields.Fields.Item("U_PURCH_RP_TAX3").Value = dr["U_PURCH_RP_TAX3"].ToString(); oBP.UserFields.Fields.Item("U_PURCH_CONTACT3").Value = dr["U_PURCH_CONTACT3"].ToString(); oBP.UserFields.Fields.Item("U_PURCH_IDTYPE3").Value = dr["U_PURCH_IDTYPE3"].ToString(); oBP.UserFields.Fields.Item("U_PURCH_RP_ID4").Value = dr["U_PURCH_RP_ID4"].ToString(); oBP.UserFields.Fields.Item("U_PURCH_RP_NAME4").Value = dr["U_PURCH_RP_NAME4"].ToString(); oBP.UserFields.Fields.Item("U_PURCH_RP_CODE4").Value = dr["U_PURCH_RP_CODE4"].ToString(); oBP.UserFields.Fields.Item("U_PURCH_RP_TAX4").Value = dr["U_PURCH_RP_TAX4"].ToString(); oBP.UserFields.Fields.Item("U_PURCH_CONTACT4").Value = dr["U_PURCH_CONTACT4"].ToString(); oBP.UserFields.Fields.Item("U_PURCH_IDTYPE4").Value = dr["U_PURCH_IDTYPE4"].ToString(); oBP.UserFields.Fields.Item("U_VNDR_RP_ID1").Value = dr["U_VNDR_RP_ID1"].ToString(); oBP.UserFields.Fields.Item("U_VNDR_RP_NAME1").Value = dr["U_VNDR_RP_NAME1"].ToString(); oBP.UserFields.Fields.Item("U_VNDR_RP_CODE1").Value = dr["U_VNDR_RP_CODE1"].ToString(); oBP.UserFields.Fields.Item("U_VNDR_RP_TAX1").Value = dr["U_VNDR_RP_TAX1"].ToString(); oBP.UserFields.Fields.Item("U_VNDR_CONTACT1").Value = dr["U_VNDR_CONTACT1"].ToString(); oBP.UserFields.Fields.Item("U_VNDR_IDTYPE1").Value = dr["U_VNDR_IDTYPE1"].ToString(); oBP.UserFields.Fields.Item("U_VNDR_RP_ID2").Value = dr["U_VNDR_RP_ID2"].ToString(); oBP.UserFields.Fields.Item("U_VNDR_RP_NAME2").Value = dr["U_VNDR_RP_NAME2"].ToString(); oBP.UserFields.Fields.Item("U_VNDR_RP_CODE2").Value = dr["U_VNDR_RP_CODE2"].ToString(); oBP.UserFields.Fields.Item("U_VNDR_RP_TAX2").Value = dr["U_VNDR_RP_TAX2"].ToString(); oBP.UserFields.Fields.Item("U_VNDR_CONTACT2").Value = dr["U_VNDR_CONTACT2"].ToString(); oBP.UserFields.Fields.Item("U_VNDR_IDTYPE2").Value = dr["U_VNDR_IDTYPE2"].ToString(); oBP.UserFields.Fields.Item("U_VNDR_RP_ID3").Value = dr["U_VNDR_RP_ID3"].ToString(); oBP.UserFields.Fields.Item("U_VNDR_RP_NAME3").Value = dr["U_VNDR_RP_NAME3"].ToString(); oBP.UserFields.Fields.Item("U_VNDR_RP_CODE3").Value = dr["U_VNDR_RP_CODE3"].ToString(); oBP.UserFields.Fields.Item("U_VNDR_RP_TAX3").Value = dr["U_VNDR_RP_TAX3"].ToString(); oBP.UserFields.Fields.Item("U_VNDR_CONTACT3").Value = dr["U_VNDR_CONTACT3"].ToString(); oBP.UserFields.Fields.Item("U_VNDR_IDTYPE3").Value = dr["U_VNDR_IDTYPE3"].ToString(); oBP.UserFields.Fields.Item("U_VNDR_RP_ID4").Value = dr["U_VNDR_RP_ID4"].ToString(); oBP.UserFields.Fields.Item("U_VNDR_RP_NAME4").Value = dr["U_VNDR_RP_NAME4"].ToString(); oBP.UserFields.Fields.Item("U_VNDR_RP_CODE4").Value = dr["U_VNDR_RP_CODE4"].ToString(); oBP.UserFields.Fields.Item("U_VNDR_RP_TAX4").Value = dr["U_VNDR_RP_TAX4"].ToString(); oBP.UserFields.Fields.Item("U_VNDR_CONTACT4").Value = dr["U_VNDR_CONTACT4"].ToString(); oBP.UserFields.Fields.Item("U_VNDR_IDTYPE4").Value = dr["U_VNDR_IDTYPE4"].ToString(); oBP.UserFields.Fields.Item("U_PROPERTY_CODE").Value = dr["U_PROPERTY_CODE"].ToString(); oBP.UserFields.Fields.Item("U_CHRG_BANK_CODE").Value = dr["U_CHRG_BANK_CODE"].ToString(); oBP.UserFields.Fields.Item("U_CHRG_BANK_BRANCH").Value = dr["U_CHRG_BANK_BRANCH"].ToString(); oBP.UserFields.Fields.Item("U_CHRG_BANK_PA_NAME").Value = dr["U_CHRG_BANK_PA_NAME"].ToString(); oBP.UserFields.Fields.Item("U_CHRG_BANK_PRSNTNO").Value = dr["U_CHRG_BANK_PRSNTNO"].ToString(); oBP.UserFields.Fields.Item("U_TITLETYPE").Value = dr["U_TITLETYPE"].ToString(); oBP.UserFields.Fields.Item("U_TITLENO").Value = dr["U_TITLENO"].ToString(); oBP.UserFields.Fields.Item("U_LOTNO").Value = dr["U_LOTNO"].ToString(); oBP.UserFields.Fields.Item("U_LOTTYPE").Value = dr["U_LOTTYPE"].ToString(); oBP.UserFields.Fields.Item("U_FORMERLY_KNOWN_AS").Value = dr["U_FORMERLY_KNOWN_AS"].ToString(); oBP.UserFields.Fields.Item("U_STATE").Value = dr["U_STATE"].ToString(); oBP.UserFields.Fields.Item("U_AREA").Value = dr["U_AREA"].ToString(); oBP.UserFields.Fields.Item("U_BPM").Value = dr["U_BPM"].ToString(); oBP.UserFields.Fields.Item("U_LOTAREA").Value = dr["U_LOTAREA"].ToString(); oBP.UserFields.Fields.Item("U_PROPERTY_PURPRC").Value = dr["PurchasePrice"].ToString(); //oBP.UserFields.Fields.Item("U_PARTNER_FST_NAME").Value = dr["U_PARTNER_FST_NAME"].ToString(); //oBP.UserFields.Fields.Item("U_LA_FST_NAME").Value = dr["U_LA_FST_NAME"].ToString(); //oBP.UserFields.Fields.Item("U_MANAGER_FST_NAME").Value = dr["U_MANAGER_FST_NAME"].ToString(); //oBP.UserFields.Fields.Item("U_IC_FST_NAME").Value = dr["U_IC_FST_NAME"].ToString(); //oBP.UserFields.Fields.Item("U_CS_FST_NAME").Value = dr["U_CS_FST_NAME"].ToString(); oBP.UserFields.Fields.Item("U_PROJECT_NAME").Value = dr["U_PROJECT_NAME"].ToString(); oBP.UserFields.Fields.Item("U_CASE_BRANCH").Value = dr["U_CASE_BRANCH"].ToString(); oBP.UserFields.Fields.Item("U_PURCH_RP_FIRM").Value = dr["U_PURCH_RP_FIRM"].ToString(); oBP.UserFields.Fields.Item("U_PURCH_RP_LWYR").Value = dr["U_PURCH_RP_LWYR"].ToString(); oBP.UserFields.Fields.Item("U_VNDR_RP_FIRM").Value = dr["U_VNDR_RP_FIRM"].ToString(); oBP.UserFields.Fields.Item("U_VNDR_RP_LWYR").Value = dr["U_VNDR_RP_LWYR"].ToString(); if (!oDICompany.InTransaction) oDICompany.StartTransaction(); double lRetCode; if (isExists == true) { lRetCode = oBP.Update(); } else { lRetCode = oBP.Add(); } if (lRetCode == 0) { if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("BP Record Created Successfully ", sFuncName); oBP.GetByKey(dr["CardCode"].ToString()); oBP.CardCode = dr["SalesCardCode"].ToString(); oBP.CardName = dr["SalesCardName"].ToString(); oBP.CardForeignName = dr["SalesCardFName"].ToString(); lRetCode = oBP.Add(); if (lRetCode == 0) { if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("BP Record Duplicated Successfully ", sFuncName); oBP.GetByKey(dr["SalesCardCode"].ToString()); oBP.DebitorAccount = dr["SalesDebPayAcct"].ToString(); lRetCode = oBP.Update(); if (lRetCode == 0) { if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("BP Record DebitorAccount Updated Successfully ", sFuncName); } sResult = "Customer Added/ successfully for the CardName = " + dr["CardName"].ToString(); } else { if (oDICompany.InTransaction) oDICompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack); sResult = oDICompany.GetLastErrorDescription(); throw new ArgumentException(sResult); } //Assign the Case if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Starting to assign the case ", sFuncName); if (dr["SubRole"].ToString() == "CS") { oDataset = SqlHelper.ExecuteDataSet(ConnectionString, CommandType.StoredProcedure, "assignCase", Data.CreateParameter("@apptype", dr["Category"].ToString()), Data.CreateParameter("@caseno", dr["CardCode"].ToString())); if (oDataset != null && oDataset.Tables.Count > 0) { if (oDataset.Tables[0].Rows.Count > 0) { oBP.GetByKey(dr["CardCode"].ToString()); oBP.UserFields.Fields.Item("U_PARTNER_EMPID").Value = oDataset.Tables[0].Rows[0]["PTEmpId"].ToString(); oBP.UserFields.Fields.Item("U_LA_EMPID").Value = oDataset.Tables[0].Rows[0]["LAEmpId"].ToString(); oBP.UserFields.Fields.Item("U_MANAGER_EMPID").Value = oDataset.Tables[0].Rows[0]["MGEmpId"].ToString(); oBP.UserFields.Fields.Item("U_IC_EMPID").Value = oDataset.Tables[0].Rows[0]["ICEmpId"].ToString(); oBP.UserFields.Fields.Item("U_CS_EMPID").Value = dr["EmpId"].ToString(); oBP.UserFields.Fields.Item("U_PARTNER_FST_NAME").Value = oDataset.Tables[0].Rows[0]["PTEmpName"].ToString(); oBP.UserFields.Fields.Item("U_LA_FST_NAME").Value = oDataset.Tables[0].Rows[0]["LAEmpName"].ToString(); oBP.UserFields.Fields.Item("U_MANAGER_FST_NAME").Value = oDataset.Tables[0].Rows[0]["MGEmpName"].ToString(); oBP.UserFields.Fields.Item("U_IC_FST_NAME").Value = oDataset.Tables[0].Rows[0]["ICEmpName"].ToString(); oBP.UserFields.Fields.Item("U_CS_FST_NAME").Value = dr["EmpName"].ToString(); lRetCode = oBP.Update(); if (lRetCode == 0) { if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Case assigned successfully for CS ", sFuncName); } else { if (oDICompany.InTransaction) oDICompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack); sResult = oDICompany.GetLastErrorDescription(); throw new ArgumentException(sResult); } } } } else if (dr["SubRole"].ToString() == "IC") { oDataset = SqlHelper.ExecuteDataSet(ConnectionString, CommandType.StoredProcedure, "assigncase_ICuser", Data.CreateParameter("@apptype", dr["Category"].ToString()), Data.CreateParameter("@usercode", sUserName.ToString())); if (oDataset != null && oDataset.Tables.Count > 0) { if (oDataset.Tables[0].Rows.Count > 0) { oBP.GetByKey(dr["CardCode"].ToString()); oBP.UserFields.Fields.Item("U_PARTNER_EMPID").Value = oDataset.Tables[0].Rows[0]["PTEmpId"].ToString(); oBP.UserFields.Fields.Item("U_LA_EMPID").Value = oDataset.Tables[0].Rows[0]["LAEmpId"].ToString(); oBP.UserFields.Fields.Item("U_MANAGER_EMPID").Value = oDataset.Tables[0].Rows[0]["MGEmpId"].ToString(); oBP.UserFields.Fields.Item("U_IC_EMPID").Value = oDataset.Tables[0].Rows[0]["ICEmpId"].ToString(); oBP.UserFields.Fields.Item("U_PARTNER_FST_NAME").Value = oDataset.Tables[0].Rows[0]["PTEmpName"].ToString(); oBP.UserFields.Fields.Item("U_LA_FST_NAME").Value = oDataset.Tables[0].Rows[0]["LAEmpName"].ToString(); oBP.UserFields.Fields.Item("U_MANAGER_FST_NAME").Value = oDataset.Tables[0].Rows[0]["MGEmpName"].ToString(); oBP.UserFields.Fields.Item("U_IC_FST_NAME").Value = oDataset.Tables[0].Rows[0]["ICEmpName"].ToString(); lRetCode = oBP.Update(); if (lRetCode == 0) { if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Case assigned successfully for IC ", sFuncName); } else { if (oDICompany.InTransaction) oDICompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack); sResult = oDICompany.GetLastErrorDescription(); throw new ArgumentException(sResult); } } } } // Create sales Quotation //ItemCode - if (oDICompany.InTransaction) oDICompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_Commit); DataTable dt = new DataTable(); DataSet ds = SPA_AddCase_GetSalesQuotationItems(dr["CardCode"].ToString()); if (ds != null && ds.Tables.Count > 0) { if (ds.Tables[0].Rows.Count > 0) { dt = ds.Tables[0]; if (dt.Rows.Count > 0) { if (Add_SalesQuotation(dt, oDICompany, dr["CardCode"].ToString(), sErrDesc) != "SUCCESS") throw new ArgumentException(sErrDesc); } } } // After Customer added in BP Master, Update the BPCode in the TempOCRD Table SqlConnection con = new SqlConnection(ConnectionString); SqlCommand command = con.CreateCommand(); command.CommandText = "Update [AE_OCRD] set U_BPCode ='" + dr["CardCode"].ToString() + "' where Code ='" + dr["TempCardCode"].ToString() + "'"; if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Executing the Query : " + command.CommandText, sFuncName); con.Open(); command.ExecuteNonQuery(); con.Close(); sResult = "SUCCESS" + dr["CardCode"].ToString(); } else { if (oDICompany.InTransaction) oDICompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack); sResult = oDICompany.GetLastErrorDescription(); throw new ArgumentException(sResult); } } } catch (Exception Ex) { //if (oDICompany.InTransaction) oDICompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack); sErrDesc = Ex.Message.ToString(); oLog.WriteToErrorLogFile(sErrDesc, sFuncName); if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Completed With ERROR ", sFuncName); sResult = Ex.Message.ToString(); throw Ex; } return sResult; }
public void Add(string strKey, SAPbobsCOM.Company oCompany, string strLogger, string strWareHouse, string[] strValues, Hashtable oht) { throw new NotImplementedException(); }
public string SPA_AddCase_AddPropertyEnquiry(DataTable dtDatatable) { string sFuncName = string.Empty; string sReturnResult = string.Empty; //int sCode = 1; string sCode = string.Empty; string sSql = string.Empty; SAPbobsCOM.Recordset oRecSet; try { sFuncName = "SPA_AddCase_AddPropertyEnquiry"; DataTable results = new DataTable(); SqlConnection con = new SqlConnection(ConnectionString); SqlCommand command = con.CreateCommand(); //command.CommandText = "select Count(CODE) from [@AE_PROPERTY]"; command.CommandText = "SELECT REPLICATE('0', (12-LEN(ISNULL(MAX(SUBSTRING(Code,4,LEN(Code)))+1,1)))) " + " + CONVERT(VARCHAR, ISNULL(MAX(SUBSTRING(Code,4,LEN(Code)))+1,1)) [Code] FROM [@AE_PROPERTY] WITH (NOLOCK)"; con.Open(); SqlDataAdapter dataAdapter = new SqlDataAdapter(command); dataAdapter.Fill(results); if (results.Rows[0][0].ToString().Length > 0) { //sCode = Convert.ToInt32(results.Rows[0][0].ToString()) + 1; sCode = results.Rows[0][0].ToString(); } con.Close(); if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Connecting to target company ", sFuncName); oDICompany = oLogin.ConnectToTargetCompany(ConnectionString); SAPbobsCOM.GeneralService oGeneralService = null; SAPbobsCOM.GeneralData oGeneralData; SAPbobsCOM.CompanyService oCompanyService = oDICompany.GetCompanyService(); oGeneralService = oCompanyService.GetGeneralService("PROPERTY"); oGeneralData = (SAPbobsCOM.GeneralData)oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralData); //Adding the Informations oGeneralData.SetProperty("Code", sCode.ToString()); oGeneralData.SetProperty("U_TITLETYPE", dtDatatable.Rows[0]["TITLETYPE"].ToString()); oGeneralData.SetProperty("U_TITLENO", dtDatatable.Rows[0]["TITLENO"].ToString()); oGeneralData.SetProperty("U_LOTTYPE", dtDatatable.Rows[0]["LOTTYPE"].ToString()); oGeneralData.SetProperty("U_LOTNO", dtDatatable.Rows[0]["LOTNO"].ToString()); oGeneralData.SetProperty("U_FORMERLY_KNOWN_AS", dtDatatable.Rows[0]["FORMERLY_KNOWN_AS"].ToString()); oGeneralData.SetProperty("U_BPM", dtDatatable.Rows[0]["BPM"].ToString()); oGeneralData.SetProperty("U_STATE", dtDatatable.Rows[0]["STATE"].ToString()); oGeneralData.SetProperty("U_AREA", dtDatatable.Rows[0]["AREA"].ToString()); oGeneralData.SetProperty("U_LOTAREA", dtDatatable.Rows[0]["LOTAREA"].ToString()); //oGeneralData.SetProperty("U_LASTUPDATEDON", dtDatatable.Rows[0]["LASTUPDATEDON"].ToString()); oGeneralData.SetProperty("U_DEVELOPER", dtDatatable.Rows[0]["DEVELOPER"].ToString()); oGeneralData.SetProperty("U_DVLPR_CODE", dtDatatable.Rows[0]["DVLPR_CODE"].ToString()); oGeneralData.SetProperty("U_PROJECT_CODE", dtDatatable.Rows[0]["PROJECT_CODE"].ToString()); oGeneralData.SetProperty("U_PROJECTNAME", dtDatatable.Rows[0]["PROJECTNAME"].ToString()); oGeneralData.SetProperty("U_DEVLICNO", dtDatatable.Rows[0]["DEVLICNO"].ToString()); oGeneralData.SetProperty("U_DEVSOLICTOR", dtDatatable.Rows[0]["DEVSOLICTOR"].ToString()); oGeneralData.SetProperty("U_DVLPR_SOL_CODE", dtDatatable.Rows[0]["DVLPR_SOL_CODE"].ToString()); oGeneralData.SetProperty("U_DVLPR_LOC", dtDatatable.Rows[0]["DVLPR_LOC"].ToString()); oGeneralData.SetProperty("U_LSTCHG_BANKCODE", dtDatatable.Rows[0]["LSTCHG_BANKCODE"].ToString()); oGeneralData.SetProperty("U_LSTCHG_BANKNAME", dtDatatable.Rows[0]["LSTCHG_BANKNAME"].ToString()); oGeneralData.SetProperty("U_LSTCHG_BRANCH", dtDatatable.Rows[0]["LSTCHG_BRANCH"].ToString()); oGeneralData.SetProperty("U_LSTCHG_PANO", dtDatatable.Rows[0]["LSTCHG_PANO"].ToString()); oGeneralData.SetProperty("U_LSTCHG_PRSTNO", dtDatatable.Rows[0]["LSTCHG_PRSTNO"].ToString()); oGeneralData.SetProperty("U_TITLE_LINK", dtDatatable.Rows[0]["TITLELINK"].ToString()); oGeneralData.SetProperty("U_LSTCHG_PRSTLINK", dtDatatable.Rows[0]["LSTCHG_PRSTLINK"].ToString()); if (dtDatatable.Rows[0]["PROPERTYCHARGED"].ToString() == "Y") { oGeneralData.SetProperty("U_PROPERTY_CHARGED", "Y"); oGeneralData.SetProperty("U_PROPERTY_FREE", "N"); } else { oGeneralData.SetProperty("U_PROPERTY_CHARGED", "N"); oGeneralData.SetProperty("U_PROPERTY_FREE", "Y"); } oGeneralService.Add(oGeneralData); //SqlConnection con = new SqlConnection(ConnectionString); //SqlCommand command = con.CreateCommand(); command.CommandText = "Update [AE_OCRD] set U_PROPERTY_CODE ='" + sCode + "', U_PURCHPRICE = '" + dtDatatable.Rows[0]["PurchasePrice"].ToString() + "' where Code ='" + dtDatatable.Rows[0]["CARDCODE"].ToString() + "'"; if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Executing the Query : " + command.CommandText, sFuncName); con.Open(); command.ExecuteNonQuery(); con.Close(); command.CommandType = CommandType.StoredProcedure; command.CommandText = "AE_SPA029_Mobile_AddCase_UpdateTitleLink"; command.Parameters.Add("@PropertyCode", SqlDbType.VarChar).Value = sCode; command.Connection = con; con.Open(); command.ExecuteNonQuery(); con.Close(); sReturnResult = "SUCCESS"; } catch (Exception Ex) { sErrDesc = Ex.Message.ToString(); oLog.WriteToErrorLogFile(sErrDesc, sFuncName); if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Completed With ERROR ", sFuncName); throw Ex; } return sReturnResult; }
public void Sync(string strKey, TransType eTrnType, SAPbobsCOM.Company oCompany_S, SAPbobsCOM.Company oCompany_D, string strLogger, string strFromWare, string strToWare, string[] strValues) { try { switch (eTrnType) { case TransType.A: ((IArmada_Sync)this).Add(strKey, oCompany_S, oCompany_D, strLogger, strFromWare, strToWare, strValues); break; default: break; } } catch (Exception ex) { Singleton.objSqlDataAccess.UpdateLog(strKey, TransScenerio.InventoryTransfer.ToString(), "0", "0", 0, "0", ex.Message.ToString(), strLogger); //throw; } }
public SAPbobsCOM.Company ConnectToTargetCompany(string sCompanyDB) { string sFuncName = string.Empty; string sReturnValue = string.Empty; DataSet oDTCompanyList = new DataSet(); DataSet oDSResult = new DataSet(); //SAPbobsCOM.Company oDICompany = new SAPbobsCOM.Company(); string sConnString = string.Empty; DataView oDTView = new DataView(); string[] MyArr = new string[7]; try { sFuncName = "ConnectToTargetCompany()"; //oSessionCompany = oSessionCompany + sSessionUserName; // SAPbobsCOM.Company Convert.ToString(Session["sLoginUserName"]); //SAPbobsCOM.Company = sSessionUserName + oSessionCompany; if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Starting Function ", sFuncName); // oDICompany = (SAPbobsCOM.Company)Session["SAPCompany"]; MyArr = ConnString.Split(';'); string DatabaseName, SQLUser, SQLPwd, SQLServer, LicenseServer, DbUserName, DbPassword = string.Empty; SQLServer = MyArr[0].ToString(); DatabaseName = MyArr[1].ToString(); SQLUser = MyArr[2].ToString(); SQLPwd = MyArr[3].ToString(); LicenseServer = MyArr[4].ToString(); DbUserName = MyArr[5].ToString(); DbPassword = MyArr[6].ToString(); if (oDICompany != null) { if (oDICompany.CompanyDB == sCompanyDB) { if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("ODICompany Name " + oDICompany.CompanyDB, sFuncName); if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("SCompanyDB " + sCompanyDB, sFuncName); return oDICompany; } } if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Calling ConnectToTargetCompany() ", sFuncName); sConnString = ConnectionString; oDICompany = ConnectToTargetCompany(oDICompany, DbUserName, DbPassword , DatabaseName, SQLServer, LicenseServer , SQLUser, SQLPwd, sErrDesc); if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Completed With SUCCESS ", sFuncName); //SAPCompany(oDIComapny, sConnString); return oDICompany; } catch (Exception Ex) { sErrDesc = Ex.Message.ToString(); if (p_iDebugMode == DEBUG_ON) oLog.WriteToErrorLogFile(sErrDesc, sFuncName); if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Completed With ERROR ", sFuncName); throw Ex; } }
public void Sync(string strKey, TransType eTrnType, SAPbobsCOM.Company oCompany_S, SAPbobsCOM.Company oCompany_D, string strLogger, string strFromWare, string strToWare, string[] strValues) { throw new NotImplementedException(); }