示例#1
0
 public void AddLogSap(SAPbobsCOM.Company oCompany, String Comentario, String Archivo, double Cantidad, String Code, String Razon, String Ref1,
                       String Ref2, String Ref4, String Orden, String ItemCode, String ASN, String LPN, String Carton)
 {
     SAPbobsCOM.GeneralService    oGeneralService = null;
     SAPbobsCOM.GeneralData       oGeneralData    = null;
     SAPbobsCOM.GeneralDataParams oGeneralParams  = null;
     SAPbobsCOM.CompanyService    oCompanyService = null;
     try
     {
         oCompanyService = oCompany.GetCompanyService();
         // Get GeneralService (oCmpSrv is the CompanyService)
         oGeneralService = oCompanyService.GetGeneralService("LOGSAP");
         // Create data for new row in main UDO
         oGeneralData = ((SAPbobsCOM.GeneralData)(oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralData)));
         oGeneralData.SetProperty("U_Archivo", Archivo);
         oGeneralData.SetProperty("U_Cantidad", Cantidad);
         oGeneralData.SetProperty("U_Code", Code);
         oGeneralData.SetProperty("U_Razon", Razon);
         oGeneralData.SetProperty("U_Ref1", Ref1);
         oGeneralData.SetProperty("U_Ref2", Ref2);
         oGeneralData.SetProperty("U_Ref4", Ref4);
         oGeneralData.SetProperty("U_Orden", Orden);
         oGeneralData.SetProperty("U_ItemCode", ItemCode);
         oGeneralData.SetProperty("U_ASN", ASN);
         oGeneralData.SetProperty("U_LPN", LPN);
         oGeneralData.SetProperty("U_Carton", Carton);
         oGeneralData.SetProperty("U_Comentario", Comentario);
         oGeneralParams = oGeneralService.Add(oGeneralData);
     }
     catch (Exception ex)
     {
         AddLog(ex.Message + "Error Exception");
     }
 }
示例#2
0
文件: B1_UDO.cs 项目: Fun33/code
       public string  AddUDORecord(Pair[] src,string sUDOCode)
       {
           string ret="";

           SAPbobsCOM.GeneralService oGeneralService = null;
           SAPbobsCOM.GeneralData oGeneralData = null;
           SAPbobsCOM.GeneralDataParams oGeneralParams = null;
           SAPbobsCOM.CompanyService oCompanyService = null;
           int i = 0;
           try
           {
               oCompanyService = oCompany.GetCompanyService();
               // Get GeneralService (oCmpSrv is the CompanyService)
               oGeneralService = oCompanyService.GetGeneralService(sUDOCode);
               // Create data for new row in main UDO
               oGeneralData = ((SAPbobsCOM.GeneralData)(oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralData)));
               foreach (Pair p in src)
               {
                   //if (p.value.Length > 20)
                   //    oGeneralData.SetProperty(p.key, p.value.Substring(0, 20));
                   //else
                       oGeneralData.SetProperty(p.key, p.value);
               }

               oGeneralParams = oGeneralService.Add(oGeneralData);
               ret = System.Convert.ToString(oGeneralParams.GetProperty("DocEntry"));
           }
           catch (Exception ex)
           {
               throw (ex);
           }
           return ret;
       }
示例#3
0
        //No usado
        public static bool eliminar(string codigo)
        {
            var res = true;

            SAPbobsCOM.GeneralService    mService     = null;
            SAPbobsCOM.GeneralDataParams searchParams = null;

            try
            {
                mService     = Conexion.company.GetCompanyService().GetGeneralService(TipoUsuario.getTabla().nombre);
                searchParams = mService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralDataParams);
                searchParams.SetProperty("Code", codigo);
                SAPbobsCOM.GeneralData fObj = mService.GetByParams(searchParams);
                mService.Delete(searchParams);
            }
            catch (Exception ex)
            {
                res = false;
                StatusMessageError("TipoUsuarioDAO > eliminar() > " + ex.Message);
            }
            finally
            {
                if (mService != null)
                {
                    LiberarObjetoGenerico(mService);
                }

                if (searchParams != null)
                {
                    LiberarObjetoGenerico(searchParams);
                }
            }

            return(res);
        }
示例#4
0
        public static bool actualizar(EquipoBean bean)
        {
            var res = true;

            SAPbobsCOM.GeneralService    mService     = null;
            SAPbobsCOM.GeneralDataParams searchParams = null;
            SAPbobsCOM.GeneralData       mEquipo      = null;

            try
            {
                mService = Conexion.company.GetCompanyService().GetGeneralService(Movil.getTabla().nombre);
                mEquipo  = mService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralData);

                searchParams = mService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralDataParams);
                searchParams.SetProperty("Code", bean.codigo);

                mEquipo = mService.GetByParams(searchParams);
                mEquipo.SetProperty("Name", bean.descripcion);
                mEquipo.SetProperty("U_MSSM_MOD", bean.modelo);
                mEquipo.SetProperty("U_MSSM_SER", bean.serie);
                mEquipo.SetProperty("U_MSSM_COL", bean.color);
                mEquipo.SetProperty("U_MSSM_IDU", bean.codigoUnico);
                mEquipo.SetProperty("U_MSSM_VAL", bean.verificarId);

                mService.Update(mEquipo);
            }
            catch (Exception e)
            {
                res = false;
                StatusMessageError("EquipoDAO > actualizar() > " + e.Message);
            }
            finally
            {
                if (mService != null)
                {
                    LiberarObjetoGenerico(mService);
                }

                if (searchParams != null)
                {
                    LiberarObjetoGenerico(searchParams);
                }

                if (mEquipo != null)
                {
                    LiberarObjetoGenerico(mEquipo);
                }
            }

            return(res);
        }
示例#5
0
        static public void loadDepto()
        {
            SAPbobsCOM.CompanyService          objCompanyService = null;
            SAPbobsCOM.GeneralService          UDOService        = null;
            SAPbobsCOM.GeneralData             headerInfo        = null;
            SAPbobsCOM.GeneralDataParams       addResult         = null;
            SAPbobsCOM.GeneralCollectionParams objList           = null;

            try
            {
                objCompanyService = MainObject.Instance.B1Company.GetCompanyService();
                UDOService        = objCompanyService.GetGeneralService(Settings._Main.loadDeptUDO);
                headerInfo        = UDOService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralData);
                try
                {
                    objList = UDOService.GetList();
                }
                catch (COMException comEx)
                {
                    if (comEx.ErrorCode == -2028)
                    {
                        objList = null;
                    }
                }
                catch (Exception er)
                {
                    _Logger.Error("", er);
                    objList = null;
                }
                if (objList == null || objList.Count == 0)
                {
                    using (StreamReader sr = new StreamReader(AppDomain.CurrentDomain.BaseDirectory + "LoadData\\" + Settings._Main.loadDeptUDO))
                    {
                        while (!sr.EndOfStream)
                        {
                            string   strLine   = sr.ReadLine();
                            string[] strResult = strLine.Split('|');
                            headerInfo.SetProperty("Code", strResult[0].Trim());
                            headerInfo.SetProperty("Name", strResult[1].Trim());
                            addResult = UDOService.Add(headerInfo);
                        }
                    }
                }
            }
            catch (Exception er)
            {
                _Logger.Error("", er);
            }
        }
示例#6
0
        public static bool actualizar(string codigo, string descripcion, string activo, string supervisor, string cobrador)
        {
            var res = true;

            SAPbobsCOM.GeneralService    mService     = null;
            SAPbobsCOM.GeneralDataParams searchParams = null;
            SAPbobsCOM.GeneralData       mTipoUsuario = null;

            try
            {
                mService     = Conexion.company.GetCompanyService().GetGeneralService(TipoUsuario.getTabla().nombre);
                mTipoUsuario = mService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralData);

                searchParams = mService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralDataParams);
                searchParams.SetProperty("Code", codigo);

                mTipoUsuario = mService.GetByParams(searchParams);
                mTipoUsuario.SetProperty("Name", descripcion);
                mTipoUsuario.SetProperty("U_MSSM_HAB", activo);
                mTipoUsuario.SetProperty("U_MSSM_SUP", supervisor);
                mTipoUsuario.SetProperty("U_MSSM_COB", cobrador);

                mService.Update(mTipoUsuario);
            }
            catch (Exception e)
            {
                res = false;
                StatusMessageError("TipoUsuarioDAO > actualizar() > " + e.Message);
            }
            finally
            {
                if (mService != null)
                {
                    LiberarObjetoGenerico(mService);
                }

                if (searchParams != null)
                {
                    LiberarObjetoGenerico(searchParams);
                }

                if (mTipoUsuario != null)
                {
                    LiberarObjetoGenerico(mTipoUsuario);
                }
            }

            return(res);
        }
示例#7
0
        private void Button0_PressedAfter(object sboObject, SAPbouiCOM.SBOItemEventArg pVal)
        {
            SAPbobsCOM.GeneralService        oGeneralService = null;
            SAPbobsCOM.GeneralDataParams     oGeneralParams  = null;
            SAPbobsCOM.CompanyService        sCmp            = null;
            SAPbobsCOM.GeneralData           oGeneralData    = null;
            SAPbobsCOM.GeneralData           oChild          = null;
            SAPbobsCOM.GeneralDataCollection oChildren       = null;

            sCmp            = oCompany.GetCompanyService();
            oGeneralService = sCmp.GetGeneralService("BaseLine");
            //Create data for new row in main UDO
            oGeneralData = (SAPbobsCOM.GeneralData)oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralData);
            //Financial Project
            oGeneralData.SetProperty("U_FProject", FProject);
            //Date
            oGeneralData.SetProperty("U_BaseDate", DateTime.Today);
            //Note
            oGeneralData.SetProperty("U_Note", EditText2.Value.Trim());
            //Add Quy trinh duyet
            DataTable rs = Get_Approve_Process_BASELINE();

            if (rs.Rows.Count > 0)
            {
                oChildren = oGeneralData.Child("BASELINE_APPR");
                foreach (DataRow r in rs.Rows)
                {
                    oChild = oChildren.Add();
                    oChild.SetProperty("U_Level", r["LEVEL"].ToString());
                    oChild.SetProperty("U_Posistion", r["Position"].ToString());
                    oChild.SetProperty("U_DeptName", r["DeptName"].ToString());
                    oChild.SetProperty("U_PosName", r["PosName"].ToString());
                }
            }
            oGeneralParams = oGeneralService.Add(oGeneralData);

            if (!string.IsNullOrEmpty(oGeneralParams.GetProperty("DocEntry").ToString()))
            {
                int BaseLine_DocEntry = 0;
                int.TryParse(oGeneralParams.GetProperty("DocEntry").ToString(), out BaseLine_DocEntry);
                //Add BaseLine Data
                Add_Data(BaseLine_DocEntry);
                oApp.SetStatusBarMessage("Add Completed - DocEntry: " + oGeneralParams.GetProperty("DocEntry").ToString(), SAPbouiCOM.BoMessageTime.bmt_Medium, false);
                this.UIAPIRawForm.Close();
            }
        }
示例#8
0
        private void CrearRegistroLog(string codError, string descError, string nroPed)
        {
            SAPbobsCOM.CompanyService oCompanyService = null;
            SAPbobsCOM.GeneralData    oGeneralData    = null;
            SAPbobsCOM.GeneralService oGeneralService = null;

            oCompanyService = oCompany.GetCompanyService();
            oGeneralService = oCompanyService.GetGeneralService("EXXLOGCASTPEDID");
            oGeneralData    = ((SAPbobsCOM.GeneralData)(oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralData)));

            oGeneralData.SetProperty("U_EXX_CodError", codError);
            oGeneralData.SetProperty("U_EXX_DescError", descError);
            oGeneralData.SetProperty("U_EXX_NroPed", nroPed);
            oGeneralData.SetProperty("U_EXX_Fecha", String.Format("{0:G}", DateTime.Now.ToString()));

            SAPbobsCOM.GeneralDataParams oGeneralParams = null;
            oGeneralParams = oGeneralService.Add(oGeneralData);

            dbSap.LiberarObjeto(oCompanyService);
            dbSap.LiberarObjeto(oGeneralData);
            dbSap.LiberarObjeto(oGeneralService);
            dbSap.LiberarObjeto(oGeneralParams);
        }
示例#9
0
 private void Form_DataAddAfter(ref SAPbouiCOM.BusinessObjectInfo pVal)
 {
     //throw new System.NotImplementedException();
     if (pVal.ActionSuccess)
     {
         //Get Batch Num has created
         XmlDocument xmldoc = new XmlDocument();
         xmldoc.LoadXml(((SAPbouiCOM.BusinessObjectInfo)pVal).ObjectKey);
         XmlNodeList nodeList = xmldoc.GetElementsByTagName("BatchNum");
         string      BatchNum = string.Empty;
         try
         {
             if (nodeList.Count > 0)
             {
                 BatchNum = nodeList.Item(0).InnerText;
             }
         }
         catch
         {
             BatchNum = string.Empty;
         }
         if (!string.IsNullOrEmpty(BatchNum))
         {
             //Check if exist in JV_APPROVE
             if (!Check_Approve_Process_Exist(BatchNum))
             {
                 //Get Info BatchNum
                 SAPbobsCOM.Recordset oR_RecordSet = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
                 oR_RecordSet.DoQuery("Select top 1 U_LCP,Project from OBTF where BatchNum=" + BatchNum + " order by TransID desc");
                 string U_LCP = oR_RecordSet.Fields.Item("U_LCP").Value.ToString();
                 //string BCH = oR_RecordSet.Fields.Item("U_CP").Value.ToString();
                 string    FProject   = oR_RecordSet.Fields.Item("Project").Value.ToString();
                 string    Type_JV    = "";
                 DataTable tb_lstappr = null;
                 if (U_LCP == "VP")
                 {
                     Type_JV = "VP";
                 }
                 else if (U_LCP == "BCH")
                 {
                     Type_JV = "BCH";
                 }
                 if (Type_JV == "VP" || Type_JV == "BCH")
                 {
                     if (Check_Accountant())
                     {
                         Button0.Item.Visible = false;
                     }
                 }
                 else
                 {
                     if (Check_Accountant())
                     {
                         Button0.Item.Visible = true;
                     }
                 }
                 tb_lstappr = GetList_Approve(FProject, Type_JV);
                 if (tb_lstappr.Rows.Count > 0)
                 {
                     SAPbobsCOM.GeneralService        oGeneralService = null;
                     SAPbobsCOM.GeneralDataParams     oGeneralParams  = null;
                     SAPbobsCOM.CompanyService        sCmp            = null;
                     SAPbobsCOM.GeneralData           oGeneralData    = null;
                     SAPbobsCOM.GeneralData           oChild          = null;
                     SAPbobsCOM.GeneralDataCollection oChildren       = null;
                     sCmp            = oCompany.GetCompanyService();
                     oGeneralService = sCmp.GetGeneralService("JVAPPROVE");
                     //Create data for new row in main UDO
                     oGeneralData = (SAPbobsCOM.GeneralData)oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralData);
                     oGeneralData.SetProperty("U_JVBatchNum", int.Parse(BatchNum));
                     oGeneralData.SetProperty("U_Type", Type_JV);
                     //Create data for a row in the child table
                     oChildren = oGeneralData.Child("JV_APROVE_D");
                     foreach (DataRow r in tb_lstappr.Rows)
                     {
                         oChild = oChildren.Add();
                         oChild.SetProperty("U_Level", r["LEVEL"].ToString());
                         oChild.SetProperty("U_Position", r["Position"].ToString());
                     }
                     oGeneralParams = oGeneralService.Add(oGeneralData);
                     if (!String.IsNullOrEmpty(oGeneralParams.GetProperty("DocEntry").ToString()))
                     {
                         oApp.SetStatusBarMessage("Approve Process Added !!!", SAPbouiCOM.BoMessageTime.bmt_Medium, false);
                         if (Check_Accountant())
                         {
                             Button0.Item.Visible = false;
                         }
                     }
                     else
                     {
                         //Close Voucher
                         //SAPbobsCOM.JournalVouchers oVoucher = (SAPbobsCOM.JournalVouchers)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oJournalVouchers);
                     }
                 }
             }
         }
     }
 }
示例#10
0
        //private static void LoadInfo(SAPbouiCOM.Form oForm)
        //{
        //    SAPbobsCOM.Recordset oRecordset = null;
        //    SAPbouiCOM.Matrix oMatrix = null;
        //    SAPbouiCOM.Matrix oMatrixMm = null;

        //    try
        //    {
        //        oForm.Freeze(true);
        //        oRecordset = Conexion_SBO.m_oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
        //        oMatrix = oForm.Items.Item("Mtx1").Specific;
        //        oMatrixMm = oForm.Items.Item("Mtx_Mn").Specific;
        //        oRecordset.DoQuery("SELECT \"DocNum\" FROM \"@SEI_SETVALH\" ");
        //        if (oRecordset.RecordCount > 0 )
        //        {
        //            SAPbouiCOM.EditText oedit = null;
        //            oForm.Mode = SAPbouiCOM.BoFormMode.fm_FIND_MODE;
        //            oedit = oForm.Items.Item("DocNum").Specific;
        //            oedit.Value = "1";
        //            oForm.EnableMenu("1281", false);// 1281 --> Buscar
        //            oForm.EnableMenu("1282", false);// 1282 --> Crear
        //            oForm.Items.Item("1").Click(SAPbouiCOM.BoCellClickType.ct_Regular);
        //            oForm.Items.Item("DocNum").Enabled = false;
        //            oForm.Items.Item("DocNum").Visible = false;

        //        }
        //        else

        //        {
        //            oForm.Mode = SAPbouiCOM.BoFormMode.fm_ADD_MODE;
        //            oMatrix.AddRow(2);
        //            //lines
        //            ((SAPbouiCOM.EditText)(oMatrix.Columns.Item("Col_0").Cells.Item(1).Specific)).Value = "Entrada de mercancias";
        //            ((SAPbouiCOM.CheckBox)(oMatrix.Columns.Item("Col_1").Cells.Item(1).Specific)).Checked = true;
        //            ((SAPbouiCOM.EditText)(oMatrix.Columns.Item("Col_2").Cells.Item(1).Specific)).Value = "1";
        //            ((SAPbouiCOM.EditText)(oMatrix.Columns.Item("Col_0").Cells.Item(2).Specific)).Value = "Oferta de compra";
        //            ((SAPbouiCOM.CheckBox)(oMatrix.Columns.Item("Col_1").Cells.Item(2).Specific)).Checked = true;
        //            ((SAPbouiCOM.EditText)(oMatrix.Columns.Item("Col_2").Cells.Item(1).Specific)).Value = "2";

        //            ((SAPbouiCOM.CheckBox)(oForm.Items.Item("cbSentAcep").Specific)).Checked = true;

        //            oMatrixMm.AddRow();
        //            ((SAPbouiCOM.EditText)(oMatrixMm.Columns.Item("Col_0").Cells.Item(1).Specific)).Value = "0";
        //            ((SAPbouiCOM.EditText)(oMatrixMm.Columns.Item("Col_1").Cells.Item(1).Specific)).Value = "0";

        //        }
        //        oForm.Items.Item("Mtx1").Visible = false;
        //        oForm.Freeze(false);

        //    }
        //    catch(Exception ex)
        //    {
        //        oForm.Freeze(false);
        //    }
        //}

        private static void UpdateInfo(SAPbouiCOM.Form oForm)
        {
            SAPbouiCOM.Matrix                oMatrix = null;
            SAPbouiCOM.Matrix                oMatrixMm = null;
            SAPbobsCOM.GeneralService        oDocGeneralService = null;
            SAPbobsCOM.CompanyService        oCompService = null;
            SAPbobsCOM.GeneralData           oDocGeneralData = null;
            SAPbobsCOM.GeneralDataCollection oDocLinesCollection = null;
            SAPbobsCOM.GeneralData           oDocLineGeneralData = null;
            string sDocEntry = null, sCode = null, sDscrp = null;
            bool   Check = false;

            try
            {
                #region fm_UPDATE_MODE Validaciones
                //MODIFICAR Setting Validaciones

                sCode     = oForm.DataSources.DBDataSources.Item("@SEI_SETVALH").GetValue("Code", 0);
                sDocEntry = oForm.DataSources.DBDataSources.Item("@SEI_SETVALH").GetValue("DocEntry", 0);


                SAPbobsCOM.GeneralDataParams oGeneralDataParams = null;
                Conexion_SBO.m_oCompany.StartTransaction();
                oCompService       = Conexion_SBO.m_oCompany.GetCompanyService();
                oDocGeneralService = oCompService.GetGeneralService("SEI_SETVAL");
                oGeneralDataParams = oDocGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralDataParams);
                oGeneralDataParams.SetProperty("Code", sCode);
                oDocGeneralData = oDocGeneralService.GetByParams(oGeneralDataParams);


                //oDocGeneralData.SetProperty("U_FechaParada", dtFechP.ToString("yyyy-MM-dd"));
                //oDocGeneralData.SetProperty("U_Turno", strTurP);

                #region Lines validaciones
                oDocLinesCollection = oDocGeneralData.Child("SEI_SETVALL");
                oMatrix             = oForm.Items.Item("Mtx1").Specific;
                for (int reg = 1; reg <= oMatrix.RowCount; reg++)
                {
                    #region Asignacion de Valores
                    sDscrp = ((SAPbouiCOM.EditText)(oMatrix.Columns.Item("Col_0").Cells.Item(reg).Specific)).Value;
                    Check  = ((SAPbouiCOM.CheckBox)(oMatrix.Columns.Item("Col_1").Cells.Item(reg).Specific)).Checked;
                    #endregion Asignacion de Valores

                    #region Crear Lista de validaciones
                    oDocLineGeneralData = oDocLinesCollection.Item(reg - 1);
                    oDocLineGeneralData.SetProperty("U_Dscr", sDscrp);
                    oDocLineGeneralData.SetProperty("U_Validar", (Check == true ?"Y" : "N"));
                    #endregion Crear Lista de validaciones
                }
                //oDocGeneralService.Add(oDocGeneralData);
                #endregion Lines validaciones

                oDocGeneralService.Update(oDocGeneralData);

                if (Conexion_SBO.m_oCompany.InTransaction)
                {
                    Conexion_SBO.m_oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_Commit);
                }

                oCompService = null;
                GC.Collect();

                #endregion fm_UPDATE_MODE Validaciones
            }
            catch (Exception ex)
            {
                if (Conexion_SBO.m_oCompany.InTransaction)
                {
                    Conexion_SBO.m_oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_Commit);
                }
            }
        }
示例#11
0
        //Add Button
        private void Button0_PressedAfter(object sboObject, SAPbouiCOM.SBOItemEventArg pVal)
        {
            SAPbobsCOM.GeneralService        oGeneralService = null;
            SAPbobsCOM.GeneralDataParams     oGeneralParams  = null;
            SAPbobsCOM.CompanyService        sCmp            = null;
            SAPbobsCOM.GeneralData           oGeneralData    = null;
            SAPbobsCOM.GeneralData           oChild          = null;
            SAPbobsCOM.GeneralDataCollection oChildren       = null;
            try
            {
                BpCode = EditText0.Value;
                Get_BpName();

                sCmp            = oCompany.GetCompanyService();
                oGeneralService = sCmp.GetGeneralService("BILLVP");
                //Create data for new row in main UDO
                oGeneralData = (SAPbobsCOM.GeneralData)oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralData);
                //Financial Project
                oGeneralData.SetProperty("U_FProject", ComboBox0.Selected.Value);
                //Project Name
                oGeneralData.SetProperty("U_ProjectName", EditText1.Value);
                //BpCode
                oGeneralData.SetProperty("U_BPCode", BpCode);
                //BpName
                oGeneralData.SetProperty("U_BPName", BpName);
                //Bill Type
                int btype = 2;
                int.TryParse(ComboBox1.Selected.Value, out btype);
                oGeneralData.SetProperty("U_BType", btype);
                //Date From
                oGeneralData.SetProperty("U_DateFr", DateTime.ParseExact(EditText3.Value, "yyyyMMdd", CultureInfo.InvariantCulture));
                //Date To
                oGeneralData.SetProperty("U_DateTo", DateTime.ParseExact(EditText4.Value, "yyyyMMdd", CultureInfo.InvariantCulture));
                //Period
                oGeneralData.SetProperty("U_Period", EditText2.Value);
                //Remarks
                oGeneralData.SetProperty("Remark", EditText7.Value);
                //Add Bill Tam ung
                if (ComboBox1.Selected.Value == "1")
                {
                    Double tmp_tu = 0;
                    Double.TryParse(EditText5.Value, out tmp_tu);
                    oGeneralData.SetProperty("U_Tamung", tmp_tu);
                }
                //Add Bill thanh toan
                else if (ComboBox1.Selected.Value == "2")
                {
                    //Khau tru tam ung
                    Double tmp_ktu = 0;
                    Double.TryParse(EditText6.Value, out tmp_ktu);
                    oGeneralData.SetProperty("U_KhautruTU", tmp_ktu);

                    DataTable rs = Get_Data_BILLVP(ComboBox0.Selected.Value, DateTime.ParseExact(EditText4.Value, "yyyyMMdd", CultureInfo.InvariantCulture), BpCode);
                    Double    t  = 0;
                    if (rs.Rows.Count > 0)
                    {
                        //Create data for a row in the child table
                        oChildren = oGeneralData.Child("BILLVP1");
                        foreach (DataRow r in rs.Rows)
                        {
                            oChild = oChildren.Add();
                            //So chung tu
                            oChild.SetProperty("U_GRPO_Key", int.Parse(r["GRPOKey"].ToString()));
                            //Line details
                            oChild.SetProperty("U_GRPO_Line", int.Parse(r["GRPORowKey"].ToString()));
                            //Ma phong ban
                            oChild.SetProperty("U_DistRule", r["MaPB"].ToString());
                            //Ten phong ban
                            oChild.SetProperty("U_DisRule_Name", r["TenPB"].ToString());
                            //Du an
                            oChild.SetProperty("U_Project", r["DA"].ToString());
                            //Level 1
                            oChild.SetProperty("U_Level1", r["U_ParentID1"].ToString());
                            //Level 1 Name
                            oChild.SetProperty("U_Level1Name", r["Name1"].ToString());
                            //Level 2
                            oChild.SetProperty("U_Level2", r["U_ParentID2"].ToString());
                            //Level 2 Name
                            oChild.SetProperty("U_Level2Name", r["Name2"].ToString());
                            //Level 3
                            oChild.SetProperty("U_Level3", r["U_ParentID3"].ToString());
                            //Level 3 Name
                            oChild.SetProperty("U_Level3Name", r["Name3"].ToString());
                            //Level 4
                            oChild.SetProperty("U_Level4", r["U_ParentID4"].ToString());
                            //Level 4 Name
                            oChild.SetProperty("U_Level4Name", r["Name4"].ToString());
                            //Level 5
                            oChild.SetProperty("U_Level5", r["U_ParentID5"].ToString());
                            //Level 5 Name
                            oChild.SetProperty("U_Level5Name", r["Name5"].ToString());
                            //Ma CP
                            oChild.SetProperty("U_MaCP", r["MaCP"].ToString());
                            //Ten CP
                            oChild.SetProperty("U_TenCP", r["TenCP"].ToString());
                            //Noi dung
                            oChild.SetProperty("U_Noidung", r["DetailsName"].ToString());
                            //GT
                            t = 0;
                            Double.TryParse(r["Gross_Total"].ToString(), out t);
                            oChild.SetProperty("U_GrossTotal", t);
                            //GT no VAT
                            t = 0;
                            Double.TryParse(r["Total"].ToString(), out t);
                            oChild.SetProperty("U_Total", t);
                        }
                    }
                }
                //Add Quy trinh duyet
                DataTable rs2 = Get_Approve_Process_BILLVP();
                if (rs2.Rows.Count > 0)
                {
                    oChildren = oGeneralData.Child("BILLVP2");
                    foreach (DataRow r in rs2.Rows)
                    {
                        oChild = oChildren.Add();
                        oChild.SetProperty("U_Level", r["LEVEL"].ToString());
                        oChild.SetProperty("U_Position", r["Position"].ToString());
                        oChild.SetProperty("U_DeptName", r["DeptName"].ToString());
                        oChild.SetProperty("U_PosName", r["PosName"].ToString());
                    }
                }
                //Add UDO
                oGeneralParams = oGeneralService.Add(oGeneralData);
                if (!string.IsNullOrEmpty(oGeneralParams.GetProperty("DocEntry").ToString()))
                {
                    oApp.SetStatusBarMessage("Add Completed - DocEntry: " + oGeneralParams.GetProperty("DocEntry").ToString(), SAPbouiCOM.BoMessageTime.bmt_Medium, false);
                    Load_Grid_Period(BpCode, ComboBox0.Selected.Value);
                    CheckBox0.Checked = false;
                }
            }
            catch (Exception ex)
            {
                oApp.MessageBox(ex.Message, 1, "OK");
            }
        }
示例#12
0
        static public void loadGenericUDO()
        {
            SAPbobsCOM.CompanyService objCompanyService = null;
            SAPbobsCOM.GeneralService UDOService        = null;
            SAPbobsCOM.GeneralData    headerInfo        = null;

            SAPbobsCOM.GeneralDataParams       oResult = null;
            SAPbobsCOM.GeneralCollectionParams objList = null;
            XmlDocument oXMLLod = new XmlDocument();

            try
            {
                if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + "LoadData\\AutomaticLoad.xml"))
                {
                    oXMLLod.Load(AppDomain.CurrentDomain.BaseDirectory + "LoadData\\AutomaticLoad.xml");
                    XmlNodeList oList = oXMLLod.SelectNodes("/LoadFiles/File");
                    if (oList != null && oList.Count > 0)
                    {
                        foreach (XmlNode oFileNode in oList)
                        {
                            string strFilePath = oFileNode.SelectSingleNode("definition/location").InnerText;
                            string strUDOName  = oFileNode.SelectSingleNode("definition/UDO").InnerText;

                            objCompanyService = MainObject.Instance.B1Company.GetCompanyService();
                            UDOService        = objCompanyService.GetGeneralService(strUDOName);
                            headerInfo        = UDOService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralData);
                            try
                            {
                                objList = UDOService.GetList();
                            }

                            catch (COMException comEx)
                            {
                                if (comEx.ErrorCode == -2028)
                                {
                                    objList = null;
                                    _Logger.Error("The UDO with name " + strUDOName + " was not found");
                                }
                            }
                            catch (Exception er)
                            {
                                _Logger.Error("", er);
                                objList = null;
                            }

                            using (StreamReader sr = new StreamReader(AppDomain.CurrentDomain.BaseDirectory + strFilePath))
                            {
                                while (!sr.EndOfStream)
                                {
                                    string   strLine   = sr.ReadLine();
                                    string[] strResult = strLine.Split('|');
                                    bool     runAdd    = false;

                                    string strCode = "";

                                    for (int i = 0; i < strResult.Length; i++)
                                    {
                                        string strPropertyName = oFileNode.SelectSingleNode("mapping/column[@index='" + i.ToString() + "']") != null?oFileNode.SelectSingleNode("mapping/column[@index='" + i.ToString() + "']/@property").InnerText : "";

                                        if (i == 0)
                                        {
                                            oResult = UDOService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralDataParams);
                                            strCode = strResult[i];
                                            oResult.SetProperty("Code", strResult[i]);
                                            try
                                            {
                                                headerInfo = UDOService.GetByParams(oResult);
                                            }
                                            catch (COMException comEx)
                                            {
                                                if (comEx.ErrorCode == -2028)
                                                {
                                                    runAdd     = true;
                                                    headerInfo = UDOService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralData);
                                                    headerInfo.SetProperty("Code", strResult[i].Trim());
                                                }
                                                else
                                                {
                                                    headerInfo = null;
                                                }
                                            }
                                            catch (Exception er)
                                            {
                                                _Logger.Error("", er);
                                                headerInfo = null;
                                            }
                                        }
                                        else
                                        {
                                            if (strPropertyName.Trim().Length > 0 && headerInfo != null)
                                            {
                                                headerInfo.SetProperty(strPropertyName, strResult[i].Trim());
                                            }
                                        }
                                    }
                                    if (runAdd)
                                    {
                                        oResult = UDOService.Add(headerInfo);
                                        _Logger.Info(strCode + " added OK");
                                    }
                                    else
                                    {
                                        try
                                        {
                                            UDOService.Update(headerInfo);
                                            _Logger.Info(strCode + " updated OK");
                                        }
                                        catch (COMException comEx)
                                        {
                                            _Logger.Error("Could not update value " + strCode + " of UDO " + strUDOName, comEx);
                                        }
                                        catch (Exception er)
                                        {
                                            _Logger.Error("Could not update value " + strCode + " of UDO " + strUDOName, er);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception er)
            {
                _Logger.Error("", er);
            }
        }