public void Button2_ClickBefore(object sboObject, SAPbouiCOM.SBOItemEventArg pVal, out bool BubbleEvent) { BubbleEvent = true; try { if (oGrid.Rows.SelectedRows.Count > 0) //VERIFICA QUE EXISTA UN ROW SELECCIONADO { if (viejaSel != -1) { oGrid.CommonSetting.SetRowFontStyle(viejaSel, SAPbouiCOM.BoFontStyle.fs_Plain); } int nSelecRow = (oGrid.Rows.SelectedRows.Item(0, SAPbouiCOM.BoOrderType.ot_RowOrder)); viejaSel = nSelecRow + 1; //oApp.SetStatusBarMessage("El dato es " + oldSelection + nSelecRow); //seleccion el row y se destaca en negrita oGrid.CommonSetting.SetRowFontStyle(nSelecRow + 1, SAPbouiCOM.BoFontStyle.fs_Bold); sValorGrid = Convert.ToString(oGrid.DataTable.GetValue("Código", nSelecRow)); // Button0.Caption = "Update"; //if (Button0.Caption=="OK"){ Button0.Caption = "Update"; // oForm.Mode = SAPbouiCOM.BoFormMode.fm_UPDATE_MODE; //} } } catch (Exception) { oApp.SetStatusBarMessage("Error en el boton: " + oCompany.GetLastErrorDescription(), SAPbouiCOM.BoMessageTime.bmt_Medium, true); } }
public void AddTables(string strTab, string strDesc, SAPbobsCOM.BoUTBTableType nType) { GC.Collect(); SAPbobsCOM.UserTablesMD oUserTablesMD = null; try { oUserTablesMD = null; oUserTablesMD = ____bobCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables); // Adding Table if (!oUserTablesMD.GetByKey(strTab)) { oUserTablesMD.TableName = strTab; oUserTablesMD.TableDescription = strDesc; oUserTablesMD.TableType = nType; if (oUserTablesMD.Add() != 0) { throw new Exception(____bobCompany.GetLastErrorDescription()); } } } catch (Exception ex) { throw ex; } finally { System.Runtime.InteropServices.Marshal.ReleaseComObject(oUserTablesMD); oUserTablesMD = null; GC.WaitForPendingFinalizers(); GC.Collect(); } }
/// <summary> /// Connect SAP using DI API and replace string connection default. /// </summary> /// <param name="sapCredential"></param> public static void Connect(k.sap.SAPCredential sapCredential) { if (IsConnected()) { conn.Disconnect(); } conn = new SAPbobsCOM.Company(); conn.DbServerType = (SAPbobsCOM.BoDataServerTypes)sapCredential.SapBoDataServerTypes; conn.Server = sapCredential.DbServer; conn.language = (SAPbobsCOM.BoSuppLangs)sapCredential.SapBoSuppLangs; conn.CompanyDB = sapCredential.SapCompanyDb; conn.DbUserName = sapCredential.SapDbUserName; conn.DbPassword = sapCredential.SapDbPassword; conn.UserName = sapCredential.SapUserName; conn.Password = sapCredential.SapUserPassword; var res = conn.Connect(); if (res != 0) { var error = conn.GetLastErrorDescription(); var track = k.Diagnostic.TrackMessages(sapCredential.Info1()); k.Diagnostic.Error(LOG, track, $"({res}) {error}."); throw new Exception($"Error to connect SAP using DI api. Error code {res}", new Exception(error)); } else { k.Diagnostic.Debug(LOG, null, "SAP DI connected on {0} customer as {1}", conn.CompanyName, conn.UserName); LinkClient(); } }
private void Button0_ClickBefore(object sboObject, SAPbouiCOM.SBOItemEventArg pVal, out bool BubbleEvent) { BubbleEvent = true; oUserTable = oCompany.UserTables.Item("SECCIONESCOL"); //hago un getbykey para obtener el valor key necesario para actualizar los datos if (oUserTable.GetByKey(EditText0.Value.ToString())) { // oUserTable.UserFields.Fields.Item("U_CodigoEDC").Value = EditText0.Value.ToString(); oUserTable.UserFields.Fields.Item("U_NombreSEC").Value = EditText1.Value.ToString(); } oUserTable.UserFields.Fields.Item("U_SupraSeccionSEC").Value = EditText2.Value.ToString(); oUserTable.UserFields.Fields.Item("U_PrecioSEC").Value = EditText4.Value.ToString(); //oUserTable.Update(); int i = oUserTable.Update(); //oApp.SetStatusBarMessage("valor"+ i); if (i != 0) { oApp.SetStatusBarMessage("Error en la actualización: " + oCompany.GetLastErrorDescription(), SAPbouiCOM.BoMessageTime.bmt_Medium, false); } else { oApp.SetStatusBarMessage("Exito en la actualizacón", SAPbouiCOM.BoMessageTime.bmt_Medium, false); //oForm = oApp.Forms.Item("fmacted"); //oForm.Close(); } }
static void Main(string[] args) { Console.WriteLine("Hello"); try { SAPbobsCOM.Company company = new SAPbobsCOM.Company(); company.CompanyDB = "SBODemoUS"; company.Server = "MIKISURFACE"; company.LicenseServer = "MIKISURFACE:30000"; company.SLDServer = "MIKISURFACE:40000"; company.DbUserName = "******"; company.DbPassword = "******"; company.UseTrusted = true; company.UserName = "******"; company.Password = "******"; company.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2016; int status = company.Connect(); string errorMsg = company.GetLastErrorDescription(); int errorCode = company.GetLastErrorCode(); System.Diagnostics.Debug.WriteLine($"Connection Status {status} msg {errorMsg} code {errorCode}"); SAPbobsCOM.RecordsetEx rs = company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordsetEx); rs.DoQuery("select * from OITM"); rs.MoveNext(); string ic = rs.GetColumnValue("ItemCode"); System.Diagnostics.Debug.WriteLine($"Item Code is {ic}"); company.Disconnect(); System.Diagnostics.Debug.WriteLine("Disconnected"); } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.Message); } }
private bool Connect_usuario() { SAPbobsCOM.Company Company = new SAPbobsCOM.Company(); Company.Server = "hana:30015"; Company.LicenseServer = "sapb1:40000"; Company.UseTrusted = false; Company.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_HANADB; Company.DbUserName = "******"; Company.DbPassword = "******"; Company.CompanyDB = this.Empresa; Company.UserName = this.Usuario; Company.Password = this.Clave; Company.language = SAPbobsCOM.BoSuppLangs.ln_Spanish_La; Company.AddonIdentifier = string.Empty; if (Company.Connect() != 0) { this.EstadoConexion = Company.GetLastErrorDescription(); Company = null; this.Conectado = false; } else { Company.XMLAsString = true; Company.XmlExportType = SAPbobsCOM.BoXmlExportTypes.xet_ExportImportMode; this.Empresa_SAP = Company; this.Conectado = true; } return(this.Conectado); }
/// <summary> /// Builds a connection to SAP B1 via DI /// </summary> /// <returns></returns> public void Connect(ConnectionParams connectionParams) { this.connectionParams = connectionParams; if (this._company == null) { this._company = new SAPbobsCOM.Company(); } if (!this._company.Connected) { _company.CompanyDB = connectionParams.CompanyDB; _company.Server = connectionParams.Server; _company.LicenseServer = connectionParams.LicenseServer; _company.SLDServer = connectionParams.SLDServer; _company.DbUserName = connectionParams.DbUserName; _company.DbPassword = connectionParams.DbPassword; //UseTrusted must be false when DB User is defined, otherwise cannot connect to SBO-COMMON error is thrown on IIS _company.UseTrusted = string.IsNullOrEmpty(connectionParams.DbUserName) ? connectionParams.UseTrusted : false; _company.UserName = connectionParams.UserName; _company.Password = connectionParams.Password; _company.DbServerType = connectionParams.boDataServerType(); int status = _company.Connect(); _company.XMLAsString = true; //THIS IS TERRIBLY IMPORTANT for XML handling System.Diagnostics.Debug.WriteLine("SAP DI is connected"); } if (!this._company.Connected) { string errorMsg = _company.GetLastErrorDescription(); int errorCode = _company.GetLastErrorCode(); throw new Exception($"Connection was rejected msg { errorMsg } code { errorCode}"); } }
private void Button2_ClickBefore(object sboObject, SAPbouiCOM.SBOItemEventArg pVal, out bool BubbleEvent) { BubbleEvent = true; //oApp = (SAPbouiCOM.Application)Application.SBO_Application; //oCompany = (SAPbobsCOM.Company)oApp.Company.GetDICompany(); oUserTable = oCompany.UserTables.Item("EDICIONESCOL"); oUserTable.Code = EditText4.Value.ToString(); oUserTable.Name = EditText4.Value.ToString(); oUserTable.UserFields.Fields.Item("U_CodigoEDC").Value = EditText4.Value.ToString(); oUserTable.UserFields.Fields.Item("U_NombreEDC").Value = EditText7.Value.ToString(); oUserTable.UserFields.Fields.Item("U_ProyectoEDC").Value = EditText5.Value.ToString(); //oUserTable.Add(); int i = oUserTable.Add(); if (i != 0) { oApp.SetStatusBarMessage("Error" + oCompany.GetLastErrorDescription(), SAPbouiCOM.BoMessageTime.bmt_Medium, false); } else { oApp.SetStatusBarMessage("Exito en la inserción", SAPbouiCOM.BoMessageTime.bmt_Medium, false); oForm = oApp.Forms.Item("fmcred"); oForm.Close(); } }
public SAPbobsCOM.Company Connect(string pServer, string pDBName, string pDBUser, string pDBPassword, SAPbobsCOM.BoDataServerTypes pServerType, string pSAPUser, string pSAPPassword, ref int iErr) { if (pDBName == "") { iErr = 1; } if (iErr != 0) { return(null); } //oConnTrg = SQLDirect.oConnectToSql(txbDBServerTrg.Text, cmbSAPDBTrg.Text.Substring(0, cmbSAPDBTrg.Text.IndexOf(" - ")), txbDBUserTrg.Text, txbDBPassTrg.Text, true, bErr); oComp.Server = pServer; if (pServer == "") { oComp.Server = scServer; } oComp.DbUserName = pDBUser; if (pDBUser == "") { oComp.DbUserName = scSQLName; } oComp.DbPassword = pDBPassword; if (pDBPassword == "") { oComp.DbPassword = scSQLPass; } oComp.DbServerType = pServerType; //if (pServerType == null) oComp.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2008; oComp.CompanyDB = pDBName; oComp.UserName = pSAPUser; if (pSAPUser == "") { oComp.UserName = scSAPName; } oComp.Password = pSAPPassword; if (pSAPPassword == "") { oComp.Password = scSAPPass; } iErr = oComp.Connect(); if (iErr == 0) { return(oComp); } else { DImsg.MessageERR(iErr, oComp.GetLastErrorDescription()); return(null); } }
public string ConectarBD() { oCompany = new SAPbobsCOM.Company(); oCompany.Server = ConfigurationManager.AppSettings["Server"]; oCompany.CompanyDB = ConfigurationManager.AppSettings["Company"]; oCompany.UserName = ConfigurationManager.AppSettings["UserName"]; oCompany.Password = ConfigurationManager.AppSettings["Password"]; oCompany.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2012; oCompany.DbUserName = ConfigurationManager.AppSettings["DbUserName"]; oCompany.DbPassword = ConfigurationManager.AppSettings["DbPassword"]; if (oCompany.Connected == true) { oCompany.Disconnect(); } retVal = oCompany.Connect(); if (retVal != 0) { string retStr = oCompany.GetLastErrorDescription(); return("Error " + retVal + " " + retStr); } else { //return "Conectado a " + oCompany.CompanyName; return(InsertarRegistroInspeccion()); } }
private void TestConnection() { SAPbobsCOM.Company oCompany = new SAPbobsCOM.Company(); ///Open the connection to sbo oCompany.Server = ServerName; oCompany.LicenseServer = LicenseServer; oCompany.UserName = UserName; oCompany.Password = Password; oCompany.CompanyDB = CompanyDB; oCompany.UseTrusted = UseTrusted; if (!UseTrusted) { oCompany.DbUserName = DBUser; oCompany.DbPassword = DBPassword; } oCompany.DbServerType = dbServerType; int err = oCompany.Connect(); if (err != 0) { sMessage = "Failed Connecting to SAP\n\r" + oCompany.GetLastErrorDescription(); } else { sMessage = "Test connection successful"; oCompany.Disconnect(); } System.Runtime.InteropServices.Marshal.ReleaseComObject(oCompany); GC.Collect(); }
private void connect() { try { objCompany = new SAPbobsCOM.Company(); objCompany.Server = DataBaseServer; objCompany.UseTrusted = false; objCompany.DbUserName = DataBaseUserName; objCompany.DbPassword = DataBasePassword; objCompany.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2012; objCompany.CompanyDB = DataBaseName; objCompany.UserName = CompanyUserName; objCompany.Password = CompanyPassword; intRetCode = objCompany.Connect(); if (intRetCode != 0) { strMessage = objCompany.GetLastErrorDescription(); } else { strMessage = "Connected to " + objCompany.CompanyName; } MessageBox.Show(strMessage); } catch (Exception er) { MessageBox.Show(er.Message); } }
public override async Task Execute(Message message, TelegramBotClient client) { var chatId = message.Chat.Id; SAPbobsCOM.Company oCompany = new SAPbobsCOM.Company(); int connect = int.MinValue; oCompany.Server = ""; oCompany.CompanyDB = ""; oCompany.DbUserName = ""; oCompany.DbPassword = ""; oCompany.UserName = ""; await client.SendTextMessageAsync(chatId, "Введіть логін:"); oCompany.UserName = message.Text; if (oCompany.UserName != null) { oCompany.Password = ""; // await client.DeleteMessageAsync(chatId, message.MessageId); oCompany.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2017; connect = oCompany.Connect(); string error = "error(0)"; if (connect != 0) { error = oCompany.GetLastErrorDescription(); await client.SendTextMessageAsync(chatId, error); } else { await client.SendTextMessageAsync(chatId, "З'єднання з SAP успішне"); } } }
private void Button0_ClickBefore(object sboObject, SAPbouiCOM.SBOItemEventArg pVal, out bool BubbleEvent) { BubbleEvent = true; oUserTable = oCompany.UserTables.Item("SECCIONESCOL"); oUserTable.Code = EditText0.Value.ToString(); oUserTable.Name = EditText0.Value.ToString(); oUserTable.UserFields.Fields.Item("U_CodigoSEC").Value = EditText0.Value.ToString(); oUserTable.UserFields.Fields.Item("U_NombreSEC").Value = EditText1.Value.ToString(); oUserTable.UserFields.Fields.Item("U_SupraSeccionSEC").Value = EditText3.Value.ToString(); oUserTable.UserFields.Fields.Item("U_PrecioSEC").Value = EditText2.Value.ToString(); oUserTable.UserFields.Fields.Item("U_ProyectoSEC").Value = ""; //oUserTable.Add(); int i = oUserTable.Add(); if (i != 0) { oApp.SetStatusBarMessage("Error" + oCompany.GetLastErrorDescription(), SAPbouiCOM.BoMessageTime.bmt_Medium, false); } else { oApp.SetStatusBarMessage("Exito en la inserción", SAPbouiCOM.BoMessageTime.bmt_Medium, false); oForm = oApp.Forms.Item("creasecc"); oForm.Close(); } }
private void Button4_ClickBefore(object sboObject, SAPbouiCOM.SBOItemEventArg pVal, out bool BubbleEvent) { BubbleEvent = true; if (Grid0.Rows.SelectedRows.Count > 0) //VERIFICA QUE EXISTA UN ROW SELECCIONADO { int nSelecRow = (Grid0.Rows.SelectedRows.Item(0, SAPbouiCOM.BoOrderType.ot_RowOrder)); String sValorGrid = Convert.ToString(Grid0.DataTable.GetValue("CÓDIGO", nSelecRow)); oUserTable = oCompany.UserTables.Item("SECCIONESCOL"); if (oUserTable.GetByKey(sValorGrid)) { int i = oUserTable.Remove(); if (i != 0) { oApp.SetStatusBarMessage("Error al eliminar : " + oCompany.GetLastErrorDescription(), SAPbouiCOM.BoMessageTime.bmt_Medium, false); } else { oApp.SetStatusBarMessage("Edición Eliminada", SAPbouiCOM.BoMessageTime.bmt_Medium, false); //oForm = oApp.Forms.Item("fmacted"); //oForm.Close(); //presiono el boton refrescar Button3_ClickBefore(sboObject, pVal, out BubbleEvent); } } } else { oApp.SetStatusBarMessage("Error, no has seleccionado una fila", SAPbouiCOM.BoMessageTime.bmt_Medium, false); } }
private void VerifyInvoice(InvoiceRequest r) { SAPbobsCOM.JournalEntries oJou; SAPbobsCOM.JournalEntries_Lines oJouLine; Boolean retcode; int transId, lineId, intretcode; try { oJou = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oJournalEntries); //todas as transaçõesefetuadas string[] array = r.payer_doc_id.Split(new char[] { '-' }, 2); transId = Convert.ToInt32(array.GetValue(0).ToString()); lineId = Convert.ToInt32(array.GetValue(1).ToString()); retcode = oJou.GetByKey(transId); if (!retcode) { MyLogger.Log("Erro ao encontrar titulo " + transId.ToString()); MessageBox.Show("Erro ao encontrar titulo " + transId.ToString()); return; } oJouLine = oJou.Lines; oJouLine.SetCurrentLine(lineId); if (String.Compare(r.due_date.ToShortDateString(), oJouLine.DueDate.ToShortDateString()) != 0)//verificar vencimento { MyLogger.Log("A parcela " + lineId + " do título " + transId + " não está com a mesma data de vencimento. O título não está aprovado para negociação"); r.Invalidate(); } else if (r.value != oJouLine.Credit)//verificar valor do titulo { MyLogger.Log("A parcela " + lineId + " do título " + transId + " não está com a mesma data de vencimento. O título não está aprovado para negociação"); r.Invalidate(); } //else if(1=1)//verificar se o titulo esta com o status confirmado -- não é necessario //{ // // oJouLine.UserFields.Fields. //} else { // alterar para status negociado MyLogger.Log("A parcela " + lineId + " do título " + transId + " está negociada com sucesso!"); oJouLine.UserFields.Fields.Item("U_LB_release").Value = "1"; intretcode = oJou.Update(); if (intretcode != 0) { MyLogger.Log(oCompany.GetLastErrorDescription()); } } } catch (Exception ex) { MyLogger.Log("Erro 5034 -" + ex.Message); } }
private void connectToB1(ConfigurationInformation b1ConnectionInfo) { SAPbobsCOM.Company objCompany = null; int intResult = -1; string strErrorMessage = ""; bool blConnect = false; try { _Logger.Debug("Retreiving connection information from Cache: " + b1ConnectionInfo.ConnectionName); objCompany = T1.CacheManager.CacheManager.Instance.getFromCache(b1ConnectionInfo.ConnectionName); if (objCompany != null) { if (!objCompany.Connected) { blConnect = true; T1.CacheManager.CacheManager.Instance.removeFromCache(b1ConnectionInfo.ConnectionName); } } else { blConnect = true; } if (blConnect) { _Logger.Debug("Starting to Connect to B1 Company"); objCompany = new SAPbobsCOM.Company(); objCompany.Server = b1ConnectionInfo.Server; objCompany.LicenseServer = b1ConnectionInfo.LicenseServer; objCompany.DbServerType = b1ConnectionInfo.B1DBServerType; objCompany.CompanyDB = b1ConnectionInfo.CompanyDB; objCompany.DbUserName = b1ConnectionInfo.DBUserName; objCompany.DbPassword = b1ConnectionInfo.DBUserPassword; objCompany.UserName = b1ConnectionInfo.B1UserName; objCompany.Password = b1ConnectionInfo.B1Password; intResult = objCompany.Connect(); if (intResult == 0) { _Logger.Debug("Conected to: " + objCompany.CompanyName); T1.CacheManager.CacheManager.Instance.addToCache(b1ConnectionInfo.ConnectionName, objCompany, T1.CacheManager.CacheManager.objCachePriority.NotRemovable); } else { strErrorMessage = objCompany.GetLastErrorDescription(); _Logger.Error(strErrorMessage); } } } catch (COMException comEx) { strErrorMessage = "COM Error::" + comEx.ErrorCode + "::" + comEx.Message + "::" + comEx.StackTrace; _Logger.Error(strErrorMessage, comEx); } catch (Exception er) { _Logger.Error("", er); } }
private void btnOrder_Click(object sender, EventArgs e) { SAPbobsCOM.Documents oSO; oSO = (SAPbobsCOM.Documents)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oOrders); try { oSO.CardCode = "C20000"; oSO.DocDueDate = DateTime.Today; oSO.Comments = "Krisztian"; oSO.Lines.ItemCode = "A00001"; oSO.Lines.Quantity = 2; oSO.Lines.Price = 100; oSO.Lines.Add(); oSO.Lines.ItemCode = "A00002"; oSO.Lines.Quantity = 1; oSO.Lines.Price = 50; int ret = oSO.Add(); if (ret == 0) { oCompany.GetNewObjectCode(out MySalesOrder); MessageBox.Show("Add Sales Order successfull - " + MySalesOrder); } else { MessageBox.Show("Add Sales Order failed: " + oCompany.GetLastErrorDescription()); } } catch (Exception ex) { MessageBox.Show("Exception: " + ex.Message); } finally { System.Runtime.InteropServices.Marshal.ReleaseComObject(oSO); oSO = null; } }
public static void Login() { curCompany = new SAPbobsCOM.Company(); curCompany.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2008; //curCompany.LicenseServer = "192.168.3.222:30000"; // curCompany.Server = "LYQ-ACE9616F909"; curCompany.CompanyDB = "Olin_Test5"; curCompany.UserName = "******"; curCompany.Password = "******"; int conRetVal = curCompany.Connect(); string conRetValErrorMsg = curCompany.GetLastErrorDescription(); }
public static bool FailOperation(this SAPbobsCOM.Company oCompany, int lRetCode, out string sResultMsg) { bool error = false; sResultMsg = String.Empty; if (lRetCode != 0) // if the connection failed { error = true; //oCompany.GetLastError(out lErrCode, out sResultMsg); //sResultMsg = String.Format("{0} - {1}", lErrCode, sResultMsg); sResultMsg = String.Format("{0} | {1}", oCompany.GetLastErrorCode(), oCompany.GetLastErrorDescription()); } return(error); }
SAPbobsCOM.Company CompanyConnectTest() { try { SAPbobsCOM.Company Company = new SAPbobsCOM.Company(); Company.DbServerType = (SAPbobsCOM.BoDataServerTypes)System.Enum.Parse(typeof(SAPbobsCOM.BoDataServerTypes), this.cmbB1Type.Text); Company.Server = this.txtDBServer.Text; Company.DbUserName = this.txtDBUser.Text; Company.DbPassword = this.txtDBPassword.Text; Company.CompanyDB = this.cmbDBName.Text; Company.UserName = this.txtB1User.Text; Company.Password = this.txtB1Password.Text; Company.LicenseServer = this.txtB1Server.Text; SAPbobsCOM.BoSuppLangs language; if (System.Enum.TryParse <SAPbobsCOM.BoSuppLangs>(this.cmbLanguage.Text, out language)) { Company.language = language; } int ret = Company.Connect(); if (ret != 0) { throw new Exception(string.Format("连接B1失败,{0}", Company.GetLastErrorDescription())); } return(Company); } catch (Exception ex) { string message = string.Format("[DI API]初始化失败"); if ((ex) is System.IO.FileNotFoundException & ex.Message.IndexOf("632F4591-AA62-4219-8FB6-22BCF5F60090") > 0) { string msg_no_di = string.Format("{0},{1}", message, "可能是此计算机没有安装匹配的{0}位版本DI。"); if ((System.Environment.Is64BitProcess)) { //'64位客户端 message = string.Format(msg_no_di, "64"); } else { //'32位客户端 message = string.Format(msg_no_di, "32"); } } else { message = string.Format("{0},{1}", message, ex.Message); } throw new Exception(message, ex); } }
public static string CreateUDT(string tableName, string tableDesc, SAPbobsCOM.BoUTBTableType tableType) { oApp = (SAPbouiCOM.Application)Application.SBO_Application; oCompany = (SAPbobsCOM.Company)oApp.Company.GetDICompany(); SAPbobsCOM.UserTablesMD oUdtMD = null; SAPbobsCOM.UserFieldsMD oUdtCA = null; tableName = "Prueba"; try { oUdtMD = (SAPbobsCOM.UserTablesMD)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables); if (oUdtMD.GetByKey(tableName) == false) { oUdtMD.TableName = tableName; oUdtMD.TableDescription = tableName; oUdtMD.TableType = tableType; // oUdtCA.Mandatory = "tYes"; int lRetCode; lRetCode = oUdtMD.Add(); oUdtCA.Add(); System.Runtime.InteropServices.Marshal.ReleaseComObject(oUdtMD); oUdtMD = null; GC.Collect(); if ((lRetCode != 0)) { if ((lRetCode == -2035)) { return("-2035"); } return(oCompany.GetLastErrorDescription()); } return(""); } else { return(""); } } catch (Exception ex) { return(ex.Message); } }
public void Connecting(out string message) { message = string.Empty; if (company.Connected) { company.Disconnect(); } if (!company.Connected) { if (company.Connect() != 0) { message = company.GetLastErrorDescription(); } } }
public static string CreateUDT(string tableName, string tableDesc, SAPbobsCOM.BoUTBTableType tableType) { SAPbobsCOM.Company SBO_Company = Conexion.oCompany; //get company service if (!SBO_Company.Connected) { Conexion.Conectar_Aplicacion(); } SAPbobsCOM.UserTablesMD oUdtMD = null /* TODO Change to default(_) if this is not a reference type */; try { oUdtMD = (SAPbobsCOM.UserTablesMD)SBO_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables); if (oUdtMD.GetByKey(tableName) == false) { oUdtMD.TableName = tableName; oUdtMD.TableDescription = tableDesc; oUdtMD.TableType = tableType; int lRetCode; lRetCode = oUdtMD.Add(); System.Runtime.InteropServices.Marshal.ReleaseComObject(oUdtMD); oUdtMD = null /* TODO Change to default(_) if this is not a reference type */; GC.Collect(); if ((lRetCode != 0)) { if ((lRetCode == -2035)) { return("-2035"); } return(SBO_Company.GetLastErrorDescription()); } return(""); } else { return(""); } } catch (Exception ex) { return(ex.Message); } }
public static string CreateUDF(string tableName, string fieldName, string desc, SAPbobsCOM.BoFieldTypes fieldType, int Size, string LinkTab, SAPbobsCOM.BoFldSubTypes SubType = SAPbobsCOM.BoFldSubTypes.st_None) { SAPbobsCOM.Company SBO_Company = Conexion.oCompany; //get company service if (!SBO_Company.Connected) { Conexion.Conectar_Aplicacion(); } try { SAPbobsCOM.UserFieldsMD oUserFieldsMD; oUserFieldsMD = (SAPbobsCOM.UserFieldsMD)SBO_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserFields); oUserFieldsMD.TableName = tableName; oUserFieldsMD.Name = fieldName; oUserFieldsMD.Description = desc; oUserFieldsMD.Type = fieldType; if (Size != 0) { oUserFieldsMD.EditSize = Size; } oUserFieldsMD.SubType = SubType; int lRetCode; lRetCode = oUserFieldsMD.Add(); System.Runtime.InteropServices.Marshal.ReleaseComObject(oUserFieldsMD); GC.Collect(); oUserFieldsMD = null /* TODO Change to default(_) if this is not a reference type */; if (lRetCode != 0) { if ((lRetCode == -2035 | lRetCode == -1120)) { return(System.Convert.ToString(lRetCode)); } return(SBO_Company.GetLastErrorDescription()); } return(""); } catch (Exception ex) { return(ex.Message); } }
private void ReadFileTxt_Banamex(string pStrPath) { mObjForm.Freeze(true); string[] ArrStrWords; mIntCountCarga = 0; mIntTotalCarga = 0; try { ArrStrWords = System.IO.File.ReadAllLines(pStrPath); mObjProgressBar = new ProgressBarManager(Application.SBO_Application, "Cargando extractos bancarios", ArrStrWords.Length); foreach (ExtractBanking lObjlObjExtractBanking in GetBanamexExtractBanking(ArrStrWords)) { mObjBankPage = PopulateBankPages(lObjlObjExtractBanking); int result = mObjBankPage.Add(); mIntTotalCarga++; if (result == 0) { mIntCountCarga++; } if (result != 0) { string r = mObjCompany.GetLastErrorDescription(); //Application.SBO_Application.MessageBox("No se cargo el movimiento número: " + mIntTotalCarga); Application.SBO_Application.StatusBar.SetText("No se cargo el movimiento número: " + mIntTotalCarga, SAPbouiCOM.BoMessageTime.bmt_Long, SAPbouiCOM.BoStatusBarMessageType.smt_Error); } mObjProgressBar.NextPosition(); } ((SAPbouiCOM.EditText)mObjForm.Items.Item("18").Specific).Value = ""; ((SAPbouiCOM.EditText)mObjForm.Items.Item("18").Specific).Value = lStrAccountCode; } catch (Exception ex) { Application.SBO_Application.StatusBar.SetText(ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error); BankStatementsLogService.WriteError(ex.Message); } finally { mObjForm.Freeze(false); MemoryUtility.ReleaseComObject(mObjBankPage); } Application.SBO_Application.MessageBox("Proceso Terminado. Se cargaron " + mIntCountCarga + " de " + mIntTotalCarga + " movimientos bancarios."); }
public int AtualizarPedidoVenda(SAPbobsCOM.Company company, int docEntry) { this.log = new Log(); try { this.oCompany = company; log.WriteLogPedido("Atualizando Pedido de Venda - NF enviada p/ VTEX"); SAPbobsCOM.Documents oInvoice = (SAPbobsCOM.Documents)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices); if (oInvoice.GetByKey(docEntry)) { //SAPbobsCOM.Documents oOrderUpdate = (SAPbobsCOM.Documents)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oOrders); //oOrderUpdate = oOrder; oInvoice.UserFields.Fields.Item("U_EnvioNFVTEX").Value = "S"; int updateOrderNum = oInvoice.Update(); if (updateOrderNum != 0) { string messageError = oCompany.GetLastErrorDescription(); log.WriteLogPedido("AtualizarPedidoVenda error SAP: " + messageError); System.Runtime.InteropServices.Marshal.ReleaseComObject(oInvoice); return(1); } else { System.Runtime.InteropServices.Marshal.ReleaseComObject(oInvoice); return(0); } } return(1); } catch (Exception) { return(1); throw; } }
public static SAPbobsCOM.Company InitializeCompany() { try { Log log = new Log(); oCompany = new SAPbobsCOM.Company(); oCompany.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2016; oCompany.Server = ConfigurationManager.AppSettings["Server"]; oCompany.CompanyDB = ConfigurationManager.AppSettings["DataBase"]; oCompany.DbUserName = ConfigurationManager.AppSettings["DbUser"]; oCompany.DbPassword = ConfigurationManager.AppSettings["DbPassword"]; oCompany.language = SAPbobsCOM.BoSuppLangs.ln_Portuguese_Br; oCompany.UserName = ConfigurationManager.AppSettings["SapUser"]; oCompany.Password = ConfigurationManager.AppSettings["SapPassword"]; long con = oCompany.Connect(); if (con != 0) { //logar erro string erro = oCompany.GetLastErrorDescription(); log.WriteLogPedido("Erro ao conectar ao SAPB1. MsgErro: " + erro); log.WriteLogEstoque("Erro ao conectar ao SAPB1. MsgErro: " + erro); log.WriteLogRetornoNF("Erro ao conectar ao SAPB1. MsgErro: " + erro); return(oCompany); } log.WriteLogPedido("Conectado ao SAPB1 com sucesso."); log.WriteLogEstoque("Conectado ao SAPB1 com sucesso."); log.WriteLogRetornoNF("Conectado ao SAPB1 com sucesso."); return(oCompany); } catch (Exception e) { throw e; } }
private void DIA_CreateBP_Click(object sender, EventArgs e) { try { if (this.objCompany == null || !objCompany.Connected) { this.connect(); } if (this.objCompany != null && objCompany.Connected) { SAPbobsCOM.BusinessPartners oBP = null; int retCode = -1; String retMess = ""; oBP = objCompany.GetBusinessObject( SAPbobsCOM.BoObjectTypes.oBusinessPartners); oBP.CardCode = DIA_BPCode.Text; oBP.CardName = "Insert via DIAPI - " + DIA_BPCode.Text; oBP.CardType = SAPbobsCOM.BoCardTypes.cCustomer; retCode = oBP.Add(); if (retCode != 0) { retMess = objCompany.GetLastErrorDescription(); } else { retMess = "BP inserted successfully! - " + objCompany.GetNewObjectKey(); } MessageBox.Show(retMess); } } catch (Exception er) { MessageBox.Show(er.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 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 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 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; }
//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; } }
//ok public decimal ActualizarDocumento(SDK.Documentos.frmDocumentos form, SDK_SAP.Clases.Document documentConCambios) { //SAPbobsCOM.Documents oDocumentCopy = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseOrders); SAPbobsCOM.Documents oDocumento = (SAPbobsCOM.Documents)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseOrders); oDocumento.GetByKey(Convert.ToInt32(documentConCambios.DocEntry)); //oDocumentCopy = oDocumento; oDocumento.DocDueDate = form.dtpDocDueDate.Value; #region Encabezado if (!string.IsNullOrEmpty(form.txtNumAtCard.Text)) { oDocumento.NumAtCard = form.txtNumAtCard.Text; } if (!string.IsNullOrEmpty(form.txtComments.Text)) { oDocumento.Comments = form.txtComments.Text; } #endregion #region Detalle foreach (UltraGridRow row in form.dgvDatos.Rows) { if (!row.IsAddRow) { //si la linea ya existe la linea solo actiaizar if (Convert.ToInt32(row.Cells["LineNum"].Value == DBNull.Value ? -1 : row.Cells["LineNum"].Value) > -1) { oDocumento.Lines.SetCurrentLine(Convert.ToInt32(row.Index)); oDocumento.Lines.Quantity = Convert.ToDouble(row.Cells["Quantity"].Value); if (row.Cells["ShipDate"].Value != DBNull.Value) { oDocumento.Lines.ShipDate = Convert.ToDateTime(row.Cells["ShipDate"].Value); } if (row.Cells["U_Comentario"].Value != DBNull.Value) { oDocumento.Lines.UserFields.Fields.Item("U_Comentario").Value = row.Cells["U_Comentario"].Value; } else { oDocumento.Lines.UserFields.Fields.Item("U_Comentario").Value = String.Empty; } if (row.Cells["U_Vendedor"].Value != DBNull.Value) { oDocumento.Lines.UserFields.Fields.Item("U_Vendedor").Value = row.Cells["U_Vendedor"].Value; } else { oDocumento.Lines.UserFields.Fields.Item("U_Vendedor").Value = String.Empty; } if (row.Cells["WhsCode"].Value != DBNull.Value) { oDocumento.Lines.UserFields.Fields.Item("U_Warehouse").Value = Convert.ToString(row.Cells["WhsCode"].Value); } if (row.Cells["ShipDate"].Value != DBNull.Value) { oDocumento.Lines.UserFields.Fields.Item("U_ShipDate").Value = Convert.ToDateTime(row.Cells["ShipDate"].Value); } else { oDocumento.Lines.UserFields.Fields.Item("U_ShipDate").Value = oDocumento.DocDueDate; } } else { oDocumento.Lines.Add(); oDocumento.Lines.ItemCode = Convert.ToString(row.Cells["ItemCode"].Value); oDocumento.Lines.Quantity = Convert.ToDouble(row.Cells["Quantity"].Value); oDocumento.Lines.Currency = Convert.ToString(row.Cells["Currency"].Value); oDocumento.Lines.UnitPrice = Convert.ToDouble(row.Cells["Price"].Value); oDocumento.Lines.WarehouseCode = Convert.ToString(row.Cells["WhsCode"].Value); if (row.Cells["ShipDate"].Value != DBNull.Value) { oDocumento.Lines.ShipDate = Convert.ToDateTime(row.Cells["ShipDate"].Value); } if (row.Cells["U_Comentario"].Value != DBNull.Value) { oDocumento.Lines.UserFields.Fields.Item("U_Comentario").Value = row.Cells["U_Comentario"].Value; } else { oDocumento.Lines.UserFields.Fields.Item("U_Comentario").Value = String.Empty; } if (row.Cells["U_Vendedor"].Value != DBNull.Value) { oDocumento.Lines.UserFields.Fields.Item("U_Vendedor").Value = row.Cells["U_Vendedor"].Value; } else { oDocumento.Lines.UserFields.Fields.Item("U_Vendedor").Value = String.Empty; } if (row.Cells["WhsCode"].Value != DBNull.Value) { oDocumento.Lines.UserFields.Fields.Item("U_Warehouse").Value = Convert.ToString(row.Cells["WhsCode"].Value); } if (row.Cells["ShipDate"].Value != DBNull.Value) { oDocumento.Lines.UserFields.Fields.Item("U_ShipDate").Value = Convert.ToDateTime(row.Cells["ShipDate"].Value); } else { oDocumento.Lines.UserFields.Fields.Item("U_ShipDate").Value = oDocumento.DocDueDate; } } } } #endregion if (oDocumento.Update() != 0) { throw new Exception("Error [" + oCompany.GetLastErrorDescription() + "]"); } else { #region Datos SAP form.txtFolio.Text = oCompany.GetNewObjectKey(); oDocumento.GetByKey(Convert.ToInt32(form.txtFolio.Text)); form.txtFolio.Text = oDocumento.DocNum.ToString(); if (SAPbobsCOM.BoStatus.bost_Close == oDocumento.DocumentStatus) { form.txtStatus.Text = "Cerrado"; } else if (SAPbobsCOM.BoStatus.bost_Open == oDocumento.DocumentStatus) { form.txtStatus.Text = "Abierto"; } //form.btnCrear.Enabled = false; #endregion } this.CloseConnection(); return(oDocumento.DocNum); }
// 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 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 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"; }
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_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"; }