예제 #1
0
 public static string FormatMoneyToString(double _double, SAPbobsCOM.Company oCompany, SAPbobsCOM.BoMoneyPrecisionTypes _Precision)
 {
     SAPbobsCOM.SBObob    businessObject = (SAPbobsCOM.SBObob)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoBridge);
     SAPbobsCOM.Recordset recordset      = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
     recordset = businessObject.Format_MoneyToString(_double, _Precision);
     return((string)recordset.Fields.Item(0).Value);
 }
예제 #2
0
    public void SetupInitCardAcct()
    {
        string sql  = "delete from \"@CCCARDACCT\" where \"U_CardCode\" Not in (select \"CreditCard\" from OCRC) or \"U_CardCode\" is null";
        string sql2 = "insert into \"@CCCARDACCT\"(\"DocEntry\", \"U_CardCode\", \"U_CardName\")\r\n" +
                      "Select \"CreditCard\", \"CreditCard\", \"CardName\" from OCRC a where a.\"CreditCard\" not in (select \"U_CardCode\" from \"@CCCARDACCT\")";
        string sql3 = "Update \"@CCCARDACCT\" set \"U_CardName\" = a.\"CardName\" from OCRC a, \"@CCCARDACCT\" b where a.\"CreditCard\" = b.\"U_CardCode\"";

        SAPbobsCOM.Recordset oRS = (SAPbobsCOM.Recordset)oSetupCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);

        try
        {
            oRS.DoQuery(sql);
            oRS.DoQuery(sql2);
            oRS.DoQuery(sql3);
        }
        catch (Exception ex)
        {
            errorLog(ex);
            errorLog(sql);
            errorLog(sql2);
            errorLog(sql3);
        }
        finally
        {
            System.Runtime.InteropServices.Marshal.ReleaseComObject(oRS);
        }
        SetupinitUpdateCardAcctWithOCRC("v", "Visa");
        SetupinitUpdateCardAcctWithOCRC("m", "Ma");
        SetupinitUpdateCardAcctWithOCRC("a", "Am");
        SetupinitUpdateCardAcctWithOCRC("ds", "Disc");
        SetupinitUpdateCardAcctWithOCRC("eCheck", "eCheck");
    }
예제 #3
0
파일: B1_UnitTest.cs 프로젝트: Fun33/code
 public void editPrice(string sItemCode, string sPriceListName, int iPrice)
 {
     try
     {
         SAPbobsCOM.Items oItm = (SAPbobsCOM.Items)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oItems);
         if (oItm.GetByKey(sItemCode))
         {
             for (int i = 0; i < oItm.PriceList.Count - 1; i++)
             {
                 oItm.PriceList.SetCurrentLine(i);
                 if (oItm.PriceList.PriceListName == sPriceListName)  //"基础价格"
                 {
                     oItm.PriceList.Price = iPrice;
                     if (oItm.Update() != 0)
                     {
                         oCompany.GetLastError(out this.iRetCode, out sErrMsg);
                         throw new Exception(iRetCode.ToString() + sErrMsg);
                     }
                     else
                     {
                         MessageBox("OK");
                     }
                     return;
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox(ex.ToString());
         DealError(ex.ToString());
     }
 }
예제 #4
0
        private void CreateTransferRequest()
        {
            UIAPIRawForm.Freeze(true);
            int result = -1;

            try
            {
                mObjTransferRequest = (SAPbobsCOM.StockTransfer)mObjCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInventoryTransferRequest);
                foreach (TransferHeader_DTO lObjTransferHeader_DTO in mObjReceptionTransferService.GetTransferHeader(GetWhsCode(), mIntId))
                {
                    mObjTransferRequest = PopulateTransferRequest(lObjTransferHeader_DTO);
                    int i = 0;
                    foreach (TransferDetail_DTO lObjTransferDetail_DTO in mObjReceptionTransferService.GetTransferDetail(mIntId))
                    {
                        mObjTransferRequest = PopulateTransferRequestDetail(lObjTransferDetail_DTO, i);
                        mObjTransferRequest.Lines.Add();
                        ++i;
                    }
                    result = mObjTransferRequest.Add();
                    if (result == 0)
                    {
                        //Se creo el documento solicitud de transferencia
                        //TicketLogService.WriteSuccess("[CrearTransferencia] DocNum:" + lObjStockTrasnfer.DocNum);
                        UIAPIRawForm.Freeze(false);
                        UIApplication.ShowMessageBox(string.Format("Solicitud de Transferencia realizada correctamente {0}", mIntId));
                        UIAPIRawForm.Freeze(true);
                        bool lBooResultRow = this.LoadMtxHeader(mStrWhsCode);
                        if (lBooResultRow)
                        {
                            mIntId = ((SAPbouiCOM.EditText)mtxHeader.GetCellSpecific(1, 1)).Value;
                            mtxHeader.SelectRow(1, true, false);
                            this.LoadMtxDetail(mIntId);
                            UIControlsEnabled(true);
                        }
                        else
                        {
                            UIControlsEnabled(false);
                        }
                        ClearTxt();
                    }
                    if (result != 0)
                    {
                        UIAPIRawForm.Freeze(false);
                        UIApplication.ShowMessageBox(string.Format("Exception: {0}", DIApplication.Company.GetLastErrorDescription()));
                        //TicketLogService.WriteError("[CrearTransferencia]" + DIApplication.Company.GetLastErrorDescription());
                    }
                }
            }
            catch (Exception ex)
            {
                UIAPIRawForm.Freeze(false);
                UIApplication.ShowError(string.Format(ex.Message, ex.Message));
            }
            finally
            {
                UIAPIRawForm.Freeze(false);
                MemoryUtility.ReleaseComObject(mObjStockTransfer);
            }
        }
        public static void SolicitudCompra_ItemEvent(string FormUID, ref SAPbouiCOM.ItemEvent pVal, out bool bBubbleEvent)
        {
            bBubbleEvent = true;

            try
            {
                switch (pVal.BeforeAction)
                {
                case true:
                    break;

                case false:
                    if ((pVal.EventType == SAPbouiCOM.BoEventTypes.et_COMBO_SELECT) && (pVal.ItemUID == "10000329"))
                    {
                        if (oCompany == null)
                        {
                            Funciones.Connect_Application(ref oCompany);
                        }
                        oComboBox      = (SAPbouiCOM.ComboBox)oForm.Items.Item(pVal.ItemUID).Specific;
                        businessObject = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
                        oItems         = (SAPbobsCOM.Items)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oItems);
                        int    nOrden  = 0;
                        int    nDocOrd = 0;
                        string sSerie  = "";
                        //string sql = "";
                        //string itemCode = "";
                        try
                        {
                            if (oComboBox.Selected.Description == "0")
                            {
                                //Obtener DocEntry de Solicitud de Compra
                                oDBDataSource = oForm.DataSources.DBDataSources.Item("OPRQ");
                                nOrden        = Convert.ToInt32(oDBDataSource.GetValue("DocNum", oDBDataSource.Offset)); //Convert.ToInt32(oEdit.Value);
                                nDocOrd       = Convert.ToInt32(oDBDataSource.GetValue("DocEntry", oDBDataSource.Offset));
                                oComboBox     = (SAPbouiCOM.ComboBox)oForm.Items.Item("88").Specific;
                                sSerie        = oComboBox.Selected.Description;


                                System.Runtime.InteropServices.Marshal.ReleaseComObject(businessObject);

                                //Abrir Pantalla de Salida de Inventario y agregar lineas de acuerdo a Solicitud
                                try
                                {
                                    Application.SBO_Application.ActivateMenuItem("3079");
                                    oForm = Application.SBO_Application.Forms.ActiveForm;
                                    SalidaMercancias.Agregar_Items_Desde_Solicitud_Interna(nDocOrd, nOrden, sSerie);
                                }
                                catch (Exception) { }
                            }
                        }
                        catch (Exception) { }
                    }
                    break;
                }
            }
            catch (Exception) { }
        }
        public static bool CheckTableExists(string TableName)
        {
            SAPbobsCOM.Company SBO_Company = Conexion.oCompany;

            SAPbobsCOM.UserTablesMD oUdtMD = null /* TODO Change to default(_) if this is not a reference type */;
            bool ret = false;

            try
            {
                TableName = TableName.Replace("@", "");
                oUdtMD    = (SAPbobsCOM.UserTablesMD)SBO_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables);

                if (oUdtMD.GetByKey(TableName))
                {
                    ret = true;
                }
                else
                {
                    ret = false;
                }
            }
            catch (Exception ex)
            {
                ret = false;
            }
            finally
            {
                System.Runtime.InteropServices.Marshal.ReleaseComObject(oUdtMD);
                oUdtMD = null /* TODO Change to default(_) if this is not a reference type */;
                GC.Collect();
            }

            return(ret);
        }
예제 #7
0
 public cRecordSet(string sql, SAPbobsCOM.Company empresa)
 {
     //this.RS = new SAPbobsCOM.Recordset();
     this.RS = (SAPbobsCOM.Recordset)empresa.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
     //this.RS = empresa.GetBusinessObject(B)
     this.RS.DoQuery(sql);
 }
        public string ValidateBLId(string blId)
        {
            string _query = string.Empty;

            try
            {
                oRecordSet = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);

                _query = string.Format("SELECT [CctName] FROM [dbo].[OCCT] WHERE CctCode = '{0}'", blId);

                oRecordSet.DoQuery(_query);
                LogDAL _log = new LogDAL();
                _log.WriteEntry(_query);
                if (oRecordSet.RecordCount == 1)
                {
                    return(oRecordSet.Fields.Item("CctName").Value.ToString());
                }
            }
            catch (Exception)
            {
                return("false");
            }

            return("false");
        }
예제 #9
0
 public static void LoadComboQuery(string _query, ref SAPbouiCOM.ComboBox oComboBox, string fieldValue, string fieldDesc, SAPbobsCOM.Company oCompany)
 {
     SAPbobsCOM.Recordset businessObject = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
     businessObject.DoQuery(_query);
     SAPbouiCOM.ValidValues validValues = oComboBox.ValidValues;
     while (oComboBox.ValidValues.Count > 0)
     {
         oComboBox.ValidValues.Remove(0, SAPbouiCOM.BoSearchKey.psk_Index);
     }
     if (!string.Equals(fieldDesc, string.Empty))
     {
         while (!businessObject.EoF)
         {
             validValues.Add((dynamic)businessObject.Fields.Item(fieldValue).Value, (dynamic)businessObject.Fields.Item(fieldDesc).Value);
             businessObject.MoveNext();
         }
     }
     else
     {
         while (!businessObject.EoF)
         {
             validValues.Add((dynamic)businessObject.Fields.Item(fieldValue).Value, "");
             businessObject.MoveNext();
         }
     }
 }
예제 #10
0
        private void LoadComboQueryRecordset(string _query, dynamic oComboBox, string fieldValue, string fieldDesc, SAPbobsCOM.Company oCompany)
        {
            //oApp = (SAPbouiCOM.Application)Application.SBO_Application;
            //oCompany = (SAPbobsCOM.Company)oApp.Company.GetDICompany();

            SAPbobsCOM.Recordset businessObject = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
            businessObject.DoQuery(_query);
            SAPbouiCOM.ValidValues validValues = oComboBox.ValidValues;

            CleanComboBox(oComboBox);

            if (!string.Equals(fieldDesc, string.Empty))
            {
                while (!businessObject.EoF)
                {
                    validValues.Add((dynamic)businessObject.Fields.Item(fieldValue).Value, (dynamic)businessObject.Fields.Item(fieldDesc).Value);
                    businessObject.MoveNext();
                }
            }
            else
            {
                while (!businessObject.EoF)
                {
                    validValues.Add((dynamic)businessObject.Fields.Item(fieldValue).Value, "");
                    businessObject.MoveNext();
                }
            }
        }
        public static int CreaSoNe(SAPbobsCOM.Company oCompany, SocioNegocio oSocioNegocio)
        {
            oCardCode = oSocioNegocio.ruc + oSocioNegocio.CardType;
            int CreaSoNeReturn = 0;

            SAPbobsCOM.BusinessPartners bp = null;
            bp              = (SAPbobsCOM.BusinessPartners)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oBusinessPartners);
            bp.CardCode     = oCardCode;
            bp.FederalTaxID = oSocioNegocio.ruc;
            bp.CardName     = oSocioNegocio.razonSocial;
            if (oSocioNegocio.CardType == "C")
            {
                bp.CardType = SAPbobsCOM.BoCardTypes.cCustomer;
            }
            else
            {
                bp.CardType = SAPbobsCOM.BoCardTypes.cSupplier;
            }
            CreaSoNeReturn = bp.Add();

            //Inserta Direccion
            if (CreaSoNeReturn == 0)
            {
                CreaSoNeReturn = ActuDire(oCompany, oSocioNegocio);
            }

            return(CreaSoNeReturn);
        }
        public bool TransferirStock(string origen, string destino, string producto, string lote, double cantidad)
        {
            string numTrans;

            //Hacer la transferencia
            SAPbobsCOM.StockTransfer stockTransfer = (SAPbobsCOM.StockTransfer)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oStockTransfer);
            stockTransfer.DocDate                        = DateTime.Now;
            stockTransfer.FromWarehouse                  = origen;
            stockTransfer.ToWarehouse                    = destino;
            stockTransfer.Lines.ItemCode                 = producto;
            stockTransfer.Lines.WarehouseCode            = destino;
            stockTransfer.Lines.Quantity                 = cantidad;
            stockTransfer.Lines.BatchNumbers.BatchNumber = lote;
            stockTransfer.Lines.BatchNumbers.Quantity    = cantidad;
            stockTransfer.Lines.BatchNumbers.Add();

            stockTransfer.Lines.Add();

            stockTransfer.Add();
            numTrans = oCompany.GetNewObjectKey();

            if (stockTransfer.Add() == 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }


            //Traer el número de transferencia
            //numTrans = oCompany.GetNewObjectKey();
        }
예제 #13
0
 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);
     }
 }
예제 #14
0
        private SAPbobsCOM.BankPages PopulateBankPages(ExtractBanking pObjExtractBanking)
        {
            mObjBankPage = (SAPbobsCOM.BankPages)mObjCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oBankPages);

            mObjBankPage.AccountCode = pObjExtractBanking.AccountCode;
            mObjBankPage.DueDate     = pObjExtractBanking.Date;
            mObjBankPage.Reference   = pObjExtractBanking.Reference;
            mObjBankPage.Memo        = pObjExtractBanking.Detail;

            if (pObjExtractBanking.DebitAmount == 0 && pObjExtractBanking.CreditAmount == 0)
            {
            }

            if (pObjExtractBanking.DebitAmount > 0)
            {
                mObjBankPage.DebitAmount = pObjExtractBanking.DebitAmount;
            }

            if (pObjExtractBanking.CreditAmount > 0)
            {
                mObjBankPage.CreditAmount = pObjExtractBanking.CreditAmount;
            }

            return(mObjBankPage);
        }
예제 #15
0
 void Load_SubProject(string pFProject)
 {
     if (this.ComboBox1.ValidValues.Count > 1)
     {
         //Remove Valid Value
         this.ComboBox1.Select("", SAPbouiCOM.BoSearchKey.psk_ByValue);
         int itm_count = ComboBox1.ValidValues.Count;
         for (int i = 0; i < itm_count - 1; i++)
         {
             this.ComboBox1.ValidValues.Remove(1, SAPbouiCOM.BoSearchKey.psk_Index);
         }
     }
     SAPbobsCOM.Recordset oR_RecordSet = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
     //oR_RecordSet.DoQuery("Select AbsEntry, NAME as 'Description' from OPHA where TYP =1 and ProjectID = " + pProject_AbsEntry.ToString());
     oR_RecordSet.DoQuery(string.Format("SELECT AbsEntry,NAME FROM OPMG T0 WHERE T0.[FIPROJECT] = '{0}'and T0.[STATUS] <> 'T' ORDER BY AbsEntry", pFProject));
     try
     {
         this.ComboBox1.ValidValues.Add("", "");
     }
     catch
     { }
     if (oR_RecordSet.RecordCount > 0)
     {
         while (!oR_RecordSet.EoF)
         {
             ComboBox1.ValidValues.Add(oR_RecordSet.Fields.Item("AbsEntry").Value.ToString(), oR_RecordSet.Fields.Item("NAME").Value.ToString());
             oR_RecordSet.MoveNext();
         }
     }
 }
예제 #16
0
        private void OnCustomInitialize()
        {
            oApp     = (SAPbouiCOM.Application)Application.SBO_Application;
            oCompany = (SAPbobsCOM.Company)oApp.Company.GetDICompany();



            //busca con recorset los datos y los muestros en los textboxes
            SAPbobsCOM.Recordset oRecordset   = ((SAPbobsCOM.Recordset)(oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)));
            SAPbouiCOM.EditText  oEditStatus  = EditText1;
            SAPbouiCOM.EditText  oEditStatus2 = EditText2;
            SAPbouiCOM.EditText  oEditStatus3 = EditText3;
            //oApp.SetStatusBarMessage("El dato es..." + EditText0.Value);
            string SqlCad1 = "select t0.U_NombreEDC as 'Nombre',t0.U_ProyectoEDC as 'Proyecto',t1.U_NombrePyto as 'NombreProyecto' from [@EDICIONESCOL] as t0  left join [@PROYECTOSCOSTE] as t1 on t0.U_ProyectoEDC = (CAST (t1.U_CentroPyto AS VARCHAR) + '' + CAST (t1.U_DeptoPyto AS VARCHAR) + '' + CAST (t1.U_CodigoPyto AS VARCHAR)) where t0.U_CodigoEDC= '" + sValorGrid2 + "'";

            // oApp.SetStatusBarMessage("El dato es " + SqlCad1);
            oRecordset.DoQuery(SqlCad1);
            string Extraerdequery  = oRecordset.Fields.Item("Nombre").Value.ToString();
            string Extraerdequery2 = oRecordset.Fields.Item("Proyecto").Value.ToString();
            string Extraerdequery3 = oRecordset.Fields.Item("NombreProyecto").Value.ToString();

            oEditStatus.Value  = Extraerdequery;
            oEditStatus2.Value = Extraerdequery2;
            oEditStatus3.Value = Extraerdequery3;



            CleanComboBox(ComboBox0);
            string SqlCad = ("  SELECT CAST (U_CentroPyto AS VARCHAR) + '' + CAST (U_DeptoPyto AS VARCHAR) + '' + CAST (U_CodigoPyto AS VARCHAR) As Codigo,U_NombrePyto FROM [@PROYECTOSCOSTE]");

            // oApp.SetStatusBarMessage("El dato es " + SqlCad );
            LoadComboQueryRecordset(SqlCad, ComboBox0, "Codigo", "U_NombrePyto", oCompany);
        }
예제 #17
0
 private void OnCustomInitialize()
 {
     this.CheckBox0.ValOff = "0";
     this.CheckBox0.ValOn  = "1";
     this.oApp             = (SAPbouiCOM.Application)SAPbouiCOM.Framework.Application.SBO_Application;
     this.oCompany         = (SAPbobsCOM.Company)oApp.Company.GetDICompany();
     //Create Connection SQL
     SAPbobsCOM.Recordset oR_RecordSet = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
     oR_RecordSet.DoQuery("Select * from [@ADDONCFG]");
     if (oR_RecordSet.RecordCount > 0)
     {
         string uid = oR_RecordSet.Fields.Item("Code").Value.ToString();
         string pwd = oR_RecordSet.Fields.Item("Name").Value.ToString();
         conn = new SqlConnection(string.Format("Data Source={0}; Initial Catalog={1}; User id={2}; Password={3};", oCompany.Server, oCompany.CompanyDB, uid, pwd));
     }
     else
     {
         oApp.MessageBox("Can't connect DB !");
     }
     //Get MenuUID KLTT
     MenuUID = Get_MenuUID_BILLVP();
     if (string.IsNullOrEmpty(MenuUID))
     {
         oApp.SetStatusBarMessage("Can't find MenuUID for BILLVP", SAPbouiCOM.BoMessageTime.bmt_Short, true);
     }
     Load_Financial_Project();
 }
예제 #18
0
        public string GetServiceGroupSAP(string itemCodeSAP)
        {
            string _serviceGroupSAP = string.Empty;

            try
            {
                oRecordSet = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);

                oRecordSet.DoQuery(string.Format("SELECT U_Skill_SerMun, U_Skill_LisSer FROM [dbo].[OITM] WHERE ItemCode = '{0}' ", itemCodeSAP));

                if (oRecordSet.RecordCount == 1)
                {
                    _serviceGroupSAP = oRecordSet.Fields.Item("U_Skill_SerMun").Value.ToString();

                    if (_serviceGroupSAP == null || _serviceGroupSAP == string.Empty)
                    {
                        _serviceGroupSAP = oRecordSet.Fields.Item("U_Skill_LisSer").Value.ToString();
                    }
                }
            }
            catch (Exception)
            {
                return(string.Empty);
            }

            return(_serviceGroupSAP);
        }
예제 #19
0
        private void verificarEstadoBaseMovil()
        {
            SAPbobsCOM.Recordset oRS = null;

            try
            {
                oRS = company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
                oRS.DoQuery("select count(*) as \"Result\" from \"SYS\".\"P_SCHEMAS_\" where \"NAME\" = '" + BdMobile.BD_NAME + "'");
                if (oRS.RecordCount > 0)
                {
                    int result = int.Parse(oRS.Fields.Item("Result").Value.ToString().Trim());
                    if (result == 0)
                    {
                        application.StatusBar.SetText("Base móvil no encontrada. Se registrará la base móvil.", SAPbouiCOM.BoMessageTime.bmt_Medium, SAPbouiCOM.BoStatusBarMessageType.smt_Warning);
                        oRS.DoQuery(BdMobile.getDataBaseSQL());
                        foreach (var scriptTable in BdMobile.getTablesSQL())
                        {
                            oRS.DoQuery(scriptTable);
                        }
                        application.StatusBar.SetText("Base móvil registrada.", SAPbouiCOM.BoMessageTime.bmt_Medium, SAPbouiCOM.BoStatusBarMessageType.smt_Warning);
                    }
                }
            }
            catch (Exception ex)
            {
                application.StatusBar.SetText("verificarEstadoBaseMovil() > " + ex.Message);
            }
            finally
            {
                if (oRS != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(oRS);
                }
            }
        }
예제 #20
0
        public bool UpdateContactName(string bpCardCode, string ctnPrevName, string CtnNewName)

        {
            bool   bRetVal = false;
            string sErrMsg; int lErrCode;

            SAPbobsCOM.Company oCompany = new SAPbobsCOM.Company();
            oCompany = SAPDIAPI.Connect();

            //Check connection before updating

            if (oCompany.Connected)

            {
                //create the BP object

                SAPbobsCOM.BusinessPartners BP          = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oBusinessPartners);
                SAPbobsCOM.ContactEmployees sboContacts = BP.ContactEmployees;

                try
                {
                    if (BP.GetByKey(bpCardCode))
                    {
                        sboContacts = BP.ContactEmployees;
                        //check first for one contact (always gives 1 wether have contact or not) check for no contact to add or update
                        if (sboContacts.Count > 0)
                        {
                            for (int i = 0; i < sboContacts.Count; i++)
                            {
                                sboContacts.SetCurrentLine(i);
                                if (sboContacts.Name == ctnPrevName)
                                {
                                    bRetVal          = true;
                                    sboContacts.Name = CtnNewName;
                                }
                            }
                        }
                        if (bRetVal)
                        {
                            if (BP.Update() != 0)
                            {
                                bRetVal = false;

                                oCompany.GetLastError(out lErrCode, out sErrMsg);
                            }
                        }
                    }
                }

                catch (Exception ex) { log.Error("Error number: " + ex.HResult + " - " + ex.Message + " - " + ex.Data + " - " + ex.InnerException); }

                {
                    bRetVal = false;
                }
            }

            oCompany.Disconnect();

            return(bRetVal);
        }
예제 #21
0
        public SAPbobsCOM.Recordset rsGetDBRecSet(ref SAPbobsCOM.Company oComp, string sSQL, ref bool BubbleEvent)
        {
            SAPbobsCOM.Recordset functionReturnValue = default(SAPbobsCOM.Recordset);

            // routine to execut the sql command and return a record set

            functionReturnValue = null;
            if (BubbleEvent == false)
            {
                return(functionReturnValue);
            }

            //Dim oRS1 As SAPbobsCOM.Recordset = Nothing

            try
            {
                //oRS1 = oComp.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
                //oRS1.DoQuery(sSQL)
                //rsGetDBRecSet = oRS1
                functionReturnValue = (SAPbobsCOM.Recordset)oComp.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
                functionReturnValue.DoQuery(sSQL);
                iTmp = functionReturnValue.RecordCount;
            }
            catch (Exception ex)
            {
                BubbleEvent = false;
                DImsg.MessageERR(ref ex);
            }

            //If Not oRS1 Is Nothing Then System.Runtime.InteropServices.Marshal.ReleaseComObject(oRS1)
            GC.Collect();
            return(functionReturnValue);
        }
예제 #22
0
파일: B1_UI.cs 프로젝트: Fun33/code
    public void addUDF(string fldTable, string fldName, string fldDesc, SAPbobsCOM.BoFieldTypes sType, int sSize)
    {
        SAPbobsCOM.UserFieldsMD oUserFieldsMD = default(SAPbobsCOM.UserFieldsMD);
        try
        {
            oUserFieldsMD = (SAPbobsCOM.UserFieldsMD)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserFields);

            oUserFieldsMD.TableName   = fldTable;
            oUserFieldsMD.Name        = fldName;
            oUserFieldsMD.Description = fldDesc;
            oUserFieldsMD.Type        = sType;
            oUserFieldsMD.EditSize    = sSize;

            iRetCode = oUserFieldsMD.Add();

            //// Check for errors
            if (iRetCode != 0)
            {
                oCompany.GetLastError(out iRetCode, out sErrMsg);
            }
            else
            {
                //log("Field: '" & oUserFieldsMD.Name & "' was added successfuly to " & oUserFieldsMD.TableName & " Table")
            }
        }
        catch (Exception ex)
        {
            throw (ex);
        }
        oUserFieldsMD = null;
    }
예제 #23
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(textBox1.Text))
     {
         MessageBox.Show(" Please Input PO Number. ");
     }
     else
     {
         oPoDraft = (SAPbobsCOM.Documents)pCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseOrders);
         oPoDraft.DocObjectCode = SAPbobsCOM.BoObjectTypes.oPurchaseOrders;
         if (oPoDraft.GetByKey(data.CheckPoNumber(textBox1.Text)))
         {
             if (oPoDraft.CardName == vendor)
             {
                 form2.existingPo  = data.CheckPoNumber(textBox1.Text);
                 form2.oPoDraft    = oPoDraft;
                 this.DialogResult = DialogResult.Yes;
                 this.Close();
             }
             else
             {
                 MessageBox.Show(" The Vendor Code Is not Matched with This Purchase Order ");
             }
         }
         else
         {
             MessageBox.Show(" This PO Is Not Exist Or Is Close. ");
         }
     }
 }
예제 #24
0
        public void grBusVlr()
        {
            SAPbobsCOM.Recordset oRecordset1 = ((SAPbobsCOM.Recordset)(oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)));

            oitem = oForm.Items.Item("grdpy");
            oGrid = ((SAPbouiCOM.Grid)(oitem.Specific));
            string vlGrilla = null;

            string Sql10 = "select t0.PayMethCod as 'grcode',t1.Cardcode as 'cod' from OPYM as t0  left join  ocrd as t1 on t0.PayMethCod= t1.pymcode  where t1.cardcode='" + EditText0.Value.ToString() + "'";

            oRecordset1.DoQuery(Sql10);
            string Extraerdequery10 = oRecordset1.Fields.Item("grcode").Value.ToString();

            vlGrilla = Extraerdequery10;
            oForm.DataSources.DataTables.Item("grPagdt");
            oForm.DataSources.DataTables.Item(0).ExecuteQuery("SELECT distinct t0.PayMethCod AS 'Código',t0.Descript as' Descripción',t0.Active as 'Activo'  from OPYM  as t0 left join  ocrd as t1  on t0.PayMethCod= t1.pymcode where t0.type='O' ");
            //oGrid.DataTable = oForm.DataSources.DataTables.Item("grPagdt2");
            oGrid.Columns.Item("Activo").Type = SAPbouiCOM.BoGridColumnType.gct_CheckBox;
            //para agregar el link buton a la grilla
            oGrid.Columns.Item("Código").Type = SAPbouiCOM.BoGridColumnType.gct_EditText;
            SAPbouiCOM.EditTextColumn oEdit = (SAPbouiCOM.EditTextColumn)oGrid.Columns.Item("Código");
            oEdit.LinkedObjectType = "147";

            //oCBC.ValidValues.Add(oRec.Fields.Item(0).Value.ToString(), oRec.Fields.Item(1).Value.ToString());
            //algo parecido a lo que hace el boto de fijar metodo, lo hago aca para que el viejaSel no sea -1 y pueda sacar la linea en negrita
            //string valor = (string)oGrid.DataTable.GetValue("Código", 2); esto es para saber lo que lleva una linea en especifico
            for (int iRows = 0; iRows <= oGrid.Rows.Count - 1; iRows++)
            {
                if ((string)oGrid.DataTable.GetValue("Código", iRows) == vlGrilla)
                {
                    if (viejaSel != -1)
                    {
                        oGrid.CommonSetting.SetRowFontStyle(viejaSel, SAPbouiCOM.BoFontStyle.fs_Plain);
                    }

                    oGrid.CommonSetting.SetRowFontStyle(iRows + 1, SAPbouiCOM.BoFontStyle.fs_Bold);
                    viejaSel = iRows + 1;
                }
            }


            // Extraerdequery1 = Convert.ToString(Grid2.Columns.Item("Descripción"));



            //}
        }
예제 #25
0
파일: SAP.cs 프로젝트: erivelton2612/LB1
        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);
            }
        }
    //public static bool JEAllocation(string _Branch, string _PayrolPeriod)
    //{

    //    string sysDftDBCompany = "DESIHOFC";
    //    string sysDBUsername = ConfigurationManager.AppSettings["sysSAPUsername"];
    //    string sysDBPassword = ConfigurationManager.AppSettings["sysSAPPassword"];

    //    bool isConnected = false;
    //    string _Msg = "";
    //    oCompany = SAPInitializeConnection(sysDftDBCompany, sysDBUsername, sysDBPassword, out isConnected, out _Msg );
    //    MessageBox.Show(_Msg);
    //    if (isConnected == true)
    //    {

    //        string _sqlSelect;
    //        DataTable _tblSelect;

    //        _sqlSelect = @"
    //                                    SELECT A.Account, A.Credit, A.Debit, A.AccountName, A.EmployeeName, A.DocDate
    //                                    FROM [dbo].[fnSAPTransaction]('" + _Branch + @"','" + _PayrolPeriod + @"') A
    //                                ";
    //        _tblSelect = clsSQLClientFunctions.DataList(clsDeclaration.sSystemConnection, _sqlSelect);

    //        string _DocDate = clsSQLClientFunctions.GetData(_tblSelect, "DocDate", "0");


    //        SAPbobsCOM.JournalEntries _JournalEntries;
    //        _JournalEntries = (SAPbobsCOM.JournalEntries)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oJournalEntries);

    //        _JournalEntries.ReferenceDate = DateTime.Parse(_DocDate);
    //        _JournalEntries.TaxDate = DateTime.Parse(_DocDate);
    //        _JournalEntries.DueDate = DateTime.Parse(_DocDate);
    //        _JournalEntries.Memo = "PAYROLL PERIOD " + _PayrolPeriod + @" FOR " + _Branch;
    //        _JournalEntries.UserFields.Fields.Item("U_NSAPADVISENO").Value = _PayrolPeriod;


    //        foreach (DataRow row in _tblSelect.Rows)
    //        {
    //            {
    //                string _Account = row["Account"].ToString();
    //                string _Credit = row["Credit"].ToString();
    //                string _Debit = row["Debit"].ToString();
    //                string _AccountName = row["AccountName"].ToString();
    //                string _EmployeeName = row["EmployeeName"].ToString();

    //                if (_Account.Substring(0,1) == "V")
    //                {
    //                    _JournalEntries.Lines.ShortName = _Account;
    //                }
    //                else
    //                {
    //                    _JournalEntries.Lines.AccountCode = _Account;
    //                }

    //                _JournalEntries.Lines.LineMemo = _AccountName;

    //                _JournalEntries.Lines.Credit = double.Parse(_Credit);
    //                _JournalEntries.Lines.Debit = double.Parse(_Debit);
    //                _JournalEntries.Lines.UserFields.Fields.Item("U_NSAPADVISENO").Value = _PayrolPeriod;
    //                _JournalEntries.Lines.UserFields.Fields.Item("U_EMPLOYEE").Value = _EmployeeName;
    //                _JournalEntries.Lines.Add();
    //            }
    //        }


    //        int lRetCode;
    //        string sErrMsg;
    //        int lErrCode;
    //        Application.DoEvents();
    //        lRetCode = _JournalEntries.Add();

    //        if (lRetCode != 0)
    //        {
    //            oCompany.GetLastError(out lErrCode, out sErrMsg);
    //            MessageBox.Show(lErrCode + " " + sErrMsg);
    //            return false;
    //        }
    //        else
    //        {
    //            MessageBox.Show("Payroll Successfully Posted");
    //            return true;
    //        }

    //        oCompany.Disconnect();
    //    }
    //    else
    //    {
    //        return false;
    //    }



    //}



    public static void CreateIncomingPayment(string _Branch, string _PayrolPeriod, int _DocEntry
                                             , string _CardCode, string _CardName, string _CashAccount, double _Amount, DateTime _DocDate)
    {
        string sysDftDBCompany = "DESIHOFC";
        string sysDBUsername   = ConfigurationManager.AppSettings["sysSAPUsername"];
        string sysDBPassword   = ConfigurationManager.AppSettings["sysSAPPassword"];

        bool   isConnected = false;
        string _Msg        = "";

        oCompany = SAPInitializeConnection(sysDftDBCompany, sysDBUsername, sysDBPassword, out isConnected, out _Msg);
        //MessageBox.Show(_Msg);

        if (isConnected == true)
        {
            SAPbobsCOM.Payments _Payments;
            _Payments = (SAPbobsCOM.Payments)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oIncomingPayments);


            _Payments.CardCode       = _CardCode;
            _Payments.CardName       = _CardName;
            _Payments.CashAccount    = _CashAccount;
            _Payments.CashSum        = _Amount;
            _Payments.DocDate        = _DocDate;
            _Payments.JournalRemarks = "Integra Console " + _PayrolPeriod + @" Branch : " + _Branch;
            _Payments.TaxDate        = _DocDate;


            _Payments.Invoices.DocEntry    = _DocEntry;
            _Payments.Invoices.DocLine     = 0;
            _Payments.Invoices.InvoiceType = SAPbobsCOM.BoRcptInvTypes.it_Invoice;
            _Payments.Invoices.SumApplied  = _Amount;


            int    lRetCode;
            string sErrMsg;
            int    lErrCode;
            Application.DoEvents();
            lRetCode = _Payments.Add();

            if (lRetCode != 0)
            {
                oCompany.GetLastError(out lErrCode, out sErrMsg);
                //MessageBox.Show(lErrCode + " " + sErrMsg);
            }
            else
            {
                //MessageBox.Show("Payroll Successfully Posted");
            }

            oCompany.Disconnect();
        }
        else
        {
            MessageBox.Show(_Msg);
        }
    }
예제 #27
0
        public void StatusChangerForm2()
        {
            foreach (var item in data.Requisitions(jobNo))
            {
                if (item.Status == "6")
                {
                    if (data.GoodReceive(item.SeqNumber ?? default(int)).Equals("C"))
                    {
                        var oInvTransDraft = (SAPbobsCOM.Documents)pCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDrafts);
                        oInvTransDraft.DocObjectCode = SAPbobsCOM.BoObjectTypes.oStockTransfer;
                        var isAvailable = oInvTransDraft.GetByKey(item.SeqNumber ?? default(int));
                        if (isAvailable)
                        {
                            if (oInvTransDraft.UserFields.Fields.Item("U_PartReqStatus").Value == "6")
                            {
                                //    if (data.ItemReceive(item.SeqNumber ?? default(int)))
                                //{


                                oInvTransDraft.UserFields.Fields.Item("U_PartReqStatus").Value = "10";

                                oInvTransDraft.Update();
                                //
                                int IretCode = oInvTransDraft.Update();
                                if (IretCode != 0)
                                {
                                    // MessageBox.Show(LastErrorMessage(IretCode));
                                    oInvTransDraft = (SAPbobsCOM.Documents)pCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDrafts);
                                    oInvTransDraft.DocObjectCode = SAPbobsCOM.BoObjectTypes.oStockTransfer;
                                    isAvailable = oInvTransDraft.GetByKey(item.SeqNumber ?? default(int));
                                }

                                else
                                {
                                    LocationClass.Changer(pCompany, jobNo, 34);

                                    //form2.SendMessage("New Requisition Form has been Sent", "New Requisition form has been sent and needs your approval", "34", "Requisition", oInvTransDraft.DocEntry.ToString(), "112", oInvTransDraft.DocEntry.ToString(), jobNumber.ToString());
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #28
0
        public Form1GridViewsInitializer(int jobNumber, int orderObjectKey, SAPbobsCOM.Company company)
        {
            jobNo    = jobNumber;
            pCompany = company;

            orderKey = orderObjectKey;

            oOrder = (SAPbobsCOM.Documents)pCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oOrders);
            oOrder.GetByKey(orderKey);
        }
 public void InitVars()
 {
     if (oCompany != null)
     {
         oBP = (SAPbobsCOM.BusinessPartners)FCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oBusinessPartners);
     }
     else
     {
         new Exception("Compañia SBO, no encontrada.");
     }
 }
예제 #30
0
        public Form2GridViewsInitializer(int jobNumber, int DraftObjectKey, SAPbobsCOM.Company company)
        {
            // odrfObject = new ODRFConnector(jobNumber,true);
            jobNo    = jobNumber;
            pCompany = company;

            data        = new SqlData();
            invDraftKey = DraftObjectKey;


            oInvTransDraft = (SAPbobsCOM.Documents)pCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDrafts);
            oInvTransDraft.DocObjectCode = SAPbobsCOM.BoObjectTypes.oStockTransfer;
            isAvailable = oInvTransDraft.GetByKey(invDraftKey);
        }
예제 #31
0
        // 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;
            }
        }
예제 #32
0
        public string CloseCase(string sCaseNo, string sUserRole, string sStatus, string sKIV)
        {
            string sFuncName = "CloseCase";
            string sSql = string.Empty;
            SAPbobsCOM.Recordset oRecSet;
            string sResult = string.Empty;
            double lRetCode = 0;
            try
            {
                if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Starting Function ", sFuncName);
                if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Connecting to target company ", sFuncName);
                oDICompany = oLogin.ConnectToTargetCompany(ConnectionString);

                if (sStatus == "CLOSED")
                {
                    sSql = "EXEC AE_UPDATECASESTATUS '" + sCaseNo + "','" + sUserRole + "'";
                    oRecSet = oDICompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
                    oRecSet.DoQuery(sSql);
                    if (oRecSet.RecordCount > 0)
                    {
                        sResult = oRecSet.Fields.Item("Result").Value;
                    }

                }
                else
                {
                    SAPbobsCOM.BusinessPartners oBP = (SAPbobsCOM.BusinessPartners)(oDICompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oBusinessPartners));

                    oBP.GetByKey(sCaseNo);
                    if (sStatus.ToString() != strSelect.ToString())
                    {
                        oBP.UserFields.Fields.Item("U_CASESTATUS").Value = sStatus.ToString();
                    }
                    oBP.UserFields.Fields.Item("U_KIVSTATUS").Value = sKIV.ToString();
                    lRetCode = oBP.Update();
                    if (lRetCode == 0)
                    {
                        if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Case Header details Updated Successfully ", sFuncName);
                    }
                    sResult = "SUCCESS";
                }
                if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Completed With SUCCESS  ", sFuncName);
                return sResult;
            }
            catch (Exception Ex)
            {
                sErrDesc = Ex.Message.ToString();
                oLog.WriteToErrorLogFile(sErrDesc, sFuncName);
                if (p_iDebugMode == DEBUG_ON) oLog.WriteToDebugLogFile("Completed With ERROR  ", sFuncName);
                throw Ex;
            }
        }
예제 #33
0
파일: clsCase.cs 프로젝트: abeob1/sg-ae-T-N
        //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;
        }
예제 #34
0
        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";
        }
예제 #35
0
        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;
            }
        }
예제 #36
0
        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";
        }
예제 #37
0
        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;
        }
예제 #38
0
        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";
        }
예제 #39
0
        //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;
            }
        }
예제 #40
0
        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;
        }