示例#1
0
        private void StartUp()
        {
            try
            {
                SetupApplication();
                NumericSeparators();
                CatchingEvents();
                CreateUDT();
                CreateUDF();
                CreateUDO();
                CreateMenu();
                CreateFolder();
                CreateFMS();
                CreateSP();

                oSBOApplication.StatusBar.SetText(addonName + " Add-On Subtitution Connected", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success);
            }
            catch (Exception ex)
            {
                if (oSBOApplication != null)
                {
                    oSBOApplication.MessageBox(ex.Message);
                }
                else
                {
                    MessageBox.Show(ex.Message);
                }

                System.Windows.Forms.Application.Exit();
            }
        }
        /// <summary>
        /// Validate customer code - nomor memo
        /// </summary>
        private void Validate_CashDisc_CustCode(string formUID, ref ItemEvent pVal, ref bool bubbleEvent)
        {
            if (bubbleEvent)
            {
                if (pVal.BeforeAction == false && pVal.ActionSuccess == true && pVal.ItemChanged == true)
                {
                    Form         oForm    = oSBOApplication.Forms.Item(formUID);
                    DBDataSource dtSource = oForm.DataSources.DBDataSources.Item("@SOL_CASHDISC");
                    Recordset    oRec     = oSBOCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);

                    try
                    {
                        oForm.Freeze(true);
                        string noMemo = GenerateNoMemo(oForm.Items.Item("tCusCd").Specific.Value);
                        dtSource.SetValue("Code", 0, noMemo);
                    }
                    catch (Exception ex)
                    {
                        bubbleEvent = false;
                        oSBOApplication.MessageBox(ex.Message);
                    }
                    finally
                    {
                        if (oForm != null)
                        {
                            oForm.Freeze(false);
                        }

                        Utils.releaseObject(oForm);
                        Utils.releaseObject(dtSource);
                        Utils.releaseObject(oRec);
                    }
                }
            }
        }
示例#3
0
        /// <summary>
        /// Template Fix Discount When Load
        /// </summary>
        public void Template_Add_FixDisc(ref Form oForm)
        {
            try
            {
                DBDataSource dtSource = null;
                dtSource = oForm.DataSources.DBDataSources.Item("@SOL_FIXDISC_H");

                oForm.Freeze(true);
                Template_Clear_FixDisc(ref oForm);
                oForm.DataBrowser.BrowseBy = "tCode";

                oForm.Items.Item("tab2").Click();
                oForm.Items.Item("tab1").Click();

                oForm.Items.Item("tCustCd").Click();

                Utils.releaseObject(dtSource);
            }
            catch (Exception ex)
            {
                oSBOApplication.MessageBox(ex.Message);
            }
            finally
            {
                oForm.Freeze(false);
            }
        }
示例#4
0
        public void DownloadEmbFile(string pathstr)
        {
            try
            {
                string strFileName = SaveFile(pathstr);


                if (!string.IsNullOrEmpty(strFileName))
                {
                    System.IO.Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(pathstr);

                    byte[] buf = new byte[stream.Length + 1];
                    stream.Read(buf, 0, buf.Length);
                    File.WriteAllBytes(strFileName, buf);
                    oApplication.MessageBox("File saved successfully !");
                    //streamwriter.WriteLine(streamreader.ReadLine())
                }
            }
            catch (Exception ex)
            {
                oApplication.StatusBar.SetText("Failed to Load XML,AddXMl Method Failed" + ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning);
            }
            finally
            {
            }
        }
        /// <summary>
        /// Handle item event
        /// </summary>
        public void HandleItemEvent(string FormUID, ref ItemEvent pVal, out bool bubbleEvent)
        {
            bubbleEvent = true;
            AlternativeItem altItem       = new AlternativeItem(oSBOApplication, oSBOCompany);
            ChangeCompItem  changeCompItm = new ChangeCompItem(oSBOApplication, oSBOCompany);
            UpdateBomVer    updateBom     = new UpdateBomVer(oSBOApplication, oSBOCompany);

            try
            {
                if (pVal.EventType != BoEventTypes.et_FORM_UNLOAD)
                {
                    switch (pVal.FormTypeEx)
                    {
                    case "ALTITEM": altItem.ItemEvent_AltItem(FormUID, ref pVal, ref bubbleEvent); break;

                    case "COMPITM": changeCompItm.ItemEvent_ChangeCompItm(FormUID, ref pVal, ref bubbleEvent); break;

                    case "UPBOMVER": updateBom.ItemEvent_UpdateBomVer(FormUID, ref pVal, ref bubbleEvent); break;
                    }
                }
            }
            catch (Exception ex)
            {
                bubbleEvent = false;
                oSBOApplication.MessageBox(ex.Message);
            }
        }
示例#6
0
        /// <summary>
        /// Consume el web service
        /// </summary>
        /// <param name="parametros"></param>
        /// <returns></returns>
        public void SobresTrancados(object parametros)
        {
            //while (true)
            //{
            try
            {
                SAPbouiCOM.Form formularioActivo = SAPbouiCOM.Framework.Application.SBO_Application.Forms.ActiveForm;
                GC.SuppressFinalize(formularioActivo);
                GC.Collect();


                if (ConsultoPendientes())
                {
                    // app.StatusBar.SetText("Hay CFE para Re-Enviar a DGI, Favor verifique.", BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning);

                    app.MessageBox("Hay CFE para Re-Enviar a DGI, Favor verifique.", 1, "Ok");
                }



                Thread.Sleep(9000000);
            }
            catch (Exception)
            {
                //SAPbouiCOM.Framework.Application.SBO_Application.MessageBox("consumir consulta " + ex.ToString());
            }
            //}
            finally
            {
                SobresTrancados(parametros);
            }
        }
        /// <summary>
        /// Menu add row
        /// </summary>
        public void MenuEvent_AltItemAdd(ref MenuEvent pVal, ref bool bubbleEvent)
        {
            if (pVal.BeforeAction == true)
            {
                Form oForm = oSBOApplication.Forms.ActiveForm;
                if (oForm.TypeEx == "ALTITEM")
                {
                    try
                    {
                        oForm.Freeze(true);

                        string mtxName    = "mt_1";
                        string dataSource = "@SOL_ALTITEM_D";

                        Matrix oMtx = oForm.Items.Item(mtxName).Specific;
                        oMtx.FlushToDataSource();

                        DBDataSource dtSource = oForm.DataSources.DBDataSources.Item(dataSource);
                        dtSource.InsertRecord(GeneralVariables.iDelRow);

                        dtSource.SetValue("U_SOL_ITEMCODE", GeneralVariables.iDelRow, "");
                        dtSource.SetValue("U_SOL_ITEMNAME", GeneralVariables.iDelRow, "");
                        dtSource.SetValue("U_SOL_FACTOR", GeneralVariables.iDelRow, "");

                        oMtx.LoadFromDataSource();
                        for (int i = 1; i <= oMtx.RowCount; i++)
                        {
                            oMtx.Columns.Item("#").Cells.Item(i).Specific.value = i;
                        }
                        oMtx.FlushToDataSource();

                        oMtx.Columns.Item(1).Cells.Item(GeneralVariables.iDelRow + 1).Click();
                        Utils.releaseObject(dtSource);
                        Utils.releaseObject(oMtx);
                    }
                    catch (Exception ex)
                    {
                        oSBOApplication.MessageBox(ex.Message);
                    }
                    finally
                    {
                        oForm.Freeze(false);
                        Utils.releaseObject(oForm);
                    }
                }
            }
        }
示例#8
0
        /// <summary>
        /// Termina el proceso del Addon.
        /// </summary>
        public void salirAddon()
        {
            try
            {
                if (oCompany.Connected == true)
                {
                    oCompany.Disconnect();
                }

                System.Windows.Forms.Application.Exit();
            }
            catch (Exception ex)
            {
                SBO_Application.MessageBox("Addon término su proceso - " + ex.Message);
                System.Windows.Forms.Application.Exit();
            }
        }
示例#9
0
        private void OApplication_AppEvent(BoAppEventTypes EventType)
        {
            switch (EventType)
            {
            case SAPbouiCOM.BoAppEventTypes.aet_CompanyChanged:
                oApplication.MessageBox("A Empresa foi trocada");
                System.Windows.Forms.Application.Exit();
                break;

            case SAPbouiCOM.BoAppEventTypes.aet_ShutDown:
                oApplication.MessageBox("O evento Shut Down foi chamado!!"
                                        + Environment.NewLine
                                        + "Fechando o Addon..."
                                        , 1, "OK", "", "");
                System.Windows.Forms.Application.Exit();
                break;
            }
        }
示例#10
0
 public static void MsgBoxWrapper(String msg, MsgBoxType msgBoxType = MsgBoxType.B1MsgBox, BoMessageTime msgTime = BoMessageTime.bmt_Short, bool isError = true)
 {
     if (msgBoxType == MsgBoxType.B1MsgBox)
     {
         oApplication.MessageBox(msg);
     }
     else
     {
         oApplication.SetStatusBarMessage(msg, msgTime, isError);
     }
 }
示例#11
0
        /// <summary>
        /// Realiza el envio de los sobre por medio del web service de DGI.
        /// </summary>
        /// <param name="sobre"></param>
        public void EnviarSobre(int tipo, string serie, int numero)
        {
            ComunicacionDgi comunicacionDGI = new ComunicacionDgi();

            try
            {
                ParametrosJobWsDGIMasivo parametrosJobWsDGI =
                    new ParametrosJobWsDGIMasivo(RUTA_CERTIFICADO, CLAVE_CERTIFICADO, URL_ENVIO, URL_CONSULTAS);
                parametrosJobWsDGI.NombreSobre = tipo + serie + numero;
                parametrosJobWsDGI.Tipo        = tipo;
                parametrosJobWsDGI.Serie       = serie;
                parametrosJobWsDGI.Numero      = numero;

                comunicacionDGI.ConsumirWsEnviarSobreMasivo(parametrosJobWsDGI);
            }
            catch (Exception ex)
            {
                app.MessageBox("ERROR: " + ex.ToString());
            }
        }
示例#12
0
        private void TemplateLoad(ref Form oForm)
        {
            try
            {
                DBDataSource dtSource = null;
                dtSource = oForm.DataSources.DBDataSources.Item("@SOL_UPBOMVER_H");
                oForm.Freeze(true);

                DateTime updDate = DateTime.Now.Date;
                string   updTime = DateTime.Now.TimeOfDay.ToString();
                GetLastUpdate(out updDate, out updTime);

                dtSource.SetValue("U_SOL_UPDATE", 0, updDate.ToString("yyyyMMdd", CultureInfo.InvariantCulture));
                dtSource.SetValue("U_SOL_UPTIME", 0, updTime);

                EditText oEdit = oForm.Items.Item("tEdit").Specific;
                oEdit.Active = true;

                oForm.Items.Item("tUpDt").Enabled = false;
                oForm.Items.Item("tUpTm").Enabled = false;

                Utils.releaseObject(dtSource);
            }
            catch (Exception ex)
            {
                oSBOApplication.MessageBox(ex.Message);
            }
            finally
            {
                oForm.Freeze(false);
            }
        }
        private void OApplication_StatusBarEvent(string Text, BoStatusBarMessageType messageType)
        {
            oApplication.MessageBox(
                string.Format("Evento de Status Bar com mensagem:{ 0}, MessageType:{1}", Text, messageType.ToString())

                , 1, "OK", "", "");
        }
示例#14
0
文件: picker.cs 项目: ubaidmughal/SAP
 public System.Data.DataTable ShowInput(string Title, string Message)
 {
     try
     {
         bLoadInputEvents = true;
         sTitle           = Title;
         oApplication.MessageBox(Message);
     }
     catch
     {
         bLoadInputEvents = false;
     }
     return(dtOut);
 }
示例#15
0
        public static void clsSalesOrder_MenuEvent(ref SAPbouiCOM.Application oApplication, ref SAPbobsCOM.Company oCompany, SAPbouiCOM.Form oForm, ref SAPbouiCOM.MenuEvent pVal, ref bool BubbleEvent)
        {
            try
            {
                oHDBDataSource   = oForm.DataSources.DBDataSources.Item("ORDR");
                oChildDataSource = oForm.DataSources.DBDataSources.Item("RDR1");
                oMatrix          = (SAPbouiCOM.Matrix)oForm.Items.Item("38").Specific;

                if (pVal.BeforeAction)
                {
                    if (pVal.MenuUID == "1299")
                    {
                    }
                    if (pVal.MenuUID == "DeleteRow" && oForm.Mode == SAPbouiCOM.BoFormMode.fm_ADD_MODE)
                    {
                    }
                }
            }
            catch (Exception ex)
            {
                oApplication.MessageBox(ex.Message.ToString() + "/" + oCompany.GetLastErrorDescription().ToString(), 1, "OK", "", "");
            }
        }
示例#16
0
        /// <summary>
        /// Handle Item Event
        /// </summary>
        public void HandleItemEvent(string FormUID, ref ItemEvent pVal, out bool bubbleEvent)
        {
            bubbleEvent = true;

            OneTimeDiscount  cashDisc   = new OneTimeDiscount(oSBOApplication, oSBOCompany);
            PeriodicDiscount prdDisc    = new PeriodicDiscount(oSBOApplication, oSBOCompany);
            FixDiscount      fixDisc    = new FixDiscount(oSBOApplication, oSBOCompany);
            SalesOrder       salesOrder = new SalesOrder(oSBOApplication, oSBOCompany);

            try
            {
                if (pVal.EventType != BoEventTypes.et_FORM_UNLOAD)
                {
                    if (pVal.FormTypeEx == "CASHDISC")
                    {
                        cashDisc.ItemEvent_CashDisc(FormUID, ref pVal, ref bubbleEvent);
                    }
                    else if (pVal.FormTypeEx == "PRDDISC")
                    {
                        prdDisc.ItemEvent_PrdDisc(FormUID, ref pVal, ref bubbleEvent);
                    }
                    else if (pVal.FormTypeEx == "FIXDISC")
                    {
                        fixDisc.ItemEvent_PrdDisc(FormUID, ref pVal, ref bubbleEvent);
                    }
                    else if (pVal.FormType == 139)
                    {
                        salesOrder.ItemEvents_SalesOrder(FormUID, ref pVal, ref bubbleEvent);
                    }
                }
            }
            catch (Exception ex)
            {
                bubbleEvent = false;
                oSBOApplication.MessageBox(ex.Message);
            }
        }
示例#17
0
        private void TemplateLoad(ref Form oForm)
        {
            try
            {
                DBDataSource dtSource = null;
                dtSource = oForm.DataSources.DBDataSources.Item("@SOL_COMP_LOG");
                oForm.Items.Item("mt_1").Specific.LoadFromDataSource();

                Utils.releaseObject(dtSource);
            }
            catch (Exception ex)
            {
                oSBOApplication.MessageBox(ex.Message);
            }
            finally
            {
                oForm.Freeze(false);
            }
        }
        private void OApplication_ItemEvent(string FormUID, ref ItemEvent pVal, out bool BubbleEvent)
        {
            BubbleEvent = true;
            if (pVal.FormType != 0 & pVal.BeforeAction == true)
            {
                switch (pVal.EventType)
                {
                case SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED:
                    oApplication.MessageBox("O evento et_ITEM_PRESSED foi enviado pelo formulário com unique ID:" + FormUID, 1, "OK", "", "");
                    break;

                case SAPbouiCOM.BoEventTypes.et_KEY_DOWN:
                    oApplication.MessageBox("O evento et_KEY_DOWN foi enviado pelo formulário com unique ID:" + FormUID, 1, "OK", "", "");
                    break;

                case SAPbouiCOM.BoEventTypes.et_GOT_FOCUS:
                    oApplication.MessageBox("O evento et_GOT_FOCUS foi enviado pelo formulário com unique ID:" + FormUID, 1, "OK", "", "");
                    break;

                case SAPbouiCOM.BoEventTypes.et_LOST_FOCUS:
                    oApplication.MessageBox("O evento et_LOST_FOCUS foi enviado pelo formulário com unique ID:" + FormUID, 1, "OK", "", "");
                    break;

                case SAPbouiCOM.BoEventTypes.et_COMBO_SELECT:
                    oApplication.MessageBox("O evento et_COMBO_SELECT foi enviado pelo formulário com unique ID:" + FormUID, 1, "OK", "", "");
                    break;

                case SAPbouiCOM.BoEventTypes.et_CLICK:
                    oApplication.MessageBox("O evento et_CLICK foi enviado pelo formulário com unique ID:" + FormUID, 1, "OK", "", "");
                    break;

                case SAPbouiCOM.BoEventTypes.et_DOUBLE_CLICK:
                    oApplication.MessageBox("O evento et_DOUBLE_CLICK foi enviado pelo formulário com unique ID:" + FormUID, 1, "OK", "", "");
                    break;

                case SAPbouiCOM.BoEventTypes.et_VALIDATE:
                    oApplication.MessageBox("O evento et_VALIDATE foi enviado pelo formulário com unique ID:" + FormUID, 1, "OK", "", "");
                    break;

                case SAPbouiCOM.BoEventTypes.et_FORM_UNLOAD:
                    oApplication.MessageBox("O evento et_FORM_UNLOAD foi enviado pelo formulário com unique ID:" + FormUID, 1, "OK", "", "");
                    break;

                case SAPbouiCOM.BoEventTypes.et_FORM_ACTIVATE:
                    break;

                case SAPbouiCOM.BoEventTypes.et_FORM_DEACTIVATE:
                    break;

                case SAPbouiCOM.BoEventTypes.et_FORM_CLOSE:
                    oApplication.MessageBox("O evento et_FORM_CLOSE foi enviado pelo formulário com unique ID:" + FormUID, 1, "OK", "", "");
                    break;

                case SAPbouiCOM.BoEventTypes.et_FORM_RESIZE:
                    oApplication.MessageBox("O evento et_FORM_RESIZE foi enviado pelo formulário com unique ID:" + FormUID, 1, "OK", "", "");
                    break;

                case SAPbouiCOM.BoEventTypes.et_FORM_KEY_DOWN:
                    oApplication.MessageBox("O evento et_FORM_KEY_DOWN foi enviado pelo formulário com unique ID:" + FormUID, 1, "OK", "", "");
                    break;
                }
            }
        }
示例#19
0
        public void ItemEvents_SalesOrder(string formUID, ref ItemEvent pVal, ref bool bubbleEvent)
        {
            #region Add Layout
            if (bubbleEvent)
            {
                if (pVal.BeforeAction == false && pVal.ActionSuccess == true && pVal.EventType == BoEventTypes.et_FORM_LOAD)
                {
                    Form oForm = oSBOApplication.Forms.Item(formUID);
                    //Matrix oMtx = oForm.Items.Item("38").Specific;
                    Item   oItmBtn         = null;
                    Button oBtn            = null;
                    Item   sapCancelButton = oForm.Items.Item("2");

                    try
                    {
                        oItmBtn             = oForm.Items.Add("btnDisc", BoFormItemTypes.it_BUTTON);
                        oItmBtn.Top         = sapCancelButton.Top;
                        oItmBtn.Left        = sapCancelButton.Left + 70;
                        oItmBtn.Width       = 110;
                        oItmBtn.Height      = sapCancelButton.Height;
                        oItmBtn.DisplayDesc = true;
                        oItmBtn.Enabled     = true;
                        oItmBtn.Visible     = true;
                        oItmBtn.LinkTo      = "2";
                        oBtn         = oForm.Items.Item("btnDisc").Specific;
                        oBtn.Caption = "Calculate Discount";

                        //EditText oFlagBns = oMtx.Columns.Item("U_SOL_FLGBNS").Cells.Item(0).Specific;
                        //oFlagBns.Active = true;
                    }
                    catch (Exception ex)
                    {
                        bubbleEvent = false;
                        oSBOApplication.MessageBox(ex.Message + " : " + ex.StackTrace);
                    }
                    finally
                    {
                        if (oForm != null)
                        {
                            oForm.Freeze(false);
                        }
                        Utils.releaseObject(oForm);
                        Utils.releaseObject(oItmBtn);
                        Utils.releaseObject(oBtn);
                        Utils.releaseObject(sapCancelButton);
                    }
                }
            }
            #endregion

            #region Calculate Button
            if (bubbleEvent)
            {
                if (pVal.ItemUID == "btnDisc")
                {
                    if (pVal.BeforeAction == false && pVal.ActionSuccess == true && pVal.EventType == BoEventTypes.et_CLICK)
                    {
                        Form      oForm    = oSBOApplication.Forms.Item(formUID);
                        Form      oUdfForm = oSBOApplication.Forms.Item(oForm.UDFFormUID);
                        Matrix    oMtx     = oForm.Items.Item("38").Specific;
                        string    docNum   = oForm.Items.Item("8").Specific.Value;
                        Recordset oRec     = oSBOCompany.GetBusinessObject(BoObjectTypes.BoRecordset);

                        try
                        {
                            GeneralVariables.oSOCurrent             = new SOForm();
                            GeneralVariables.oSOCurrent.UniqueID    = oForm.UniqueID;
                            GeneralVariables.oSOCurrent.CardCode    = oForm.Items.Item("4").Specific.Value;
                            GeneralVariables.oSOCurrent.PostingDate = oForm.Items.Item("10").Specific.Value;
                            string tipeSO   = oUdfForm.Items.Item("U_SOL_TIPE_SO").Specific.Value;
                            string errorMsg = string.Empty;

                            // validate
                            errorMsg = AllowedCalculate(oMtx, GeneralVariables.oSOCurrent.CardCode, tipeSO, docNum);

                            if (string.IsNullOrEmpty(errorMsg))
                            {
                                if (pVal.FormMode == (int)BoFormMode.fm_ADD_MODE || pVal.FormMode == (int)BoFormMode.fm_UPDATE_MODE)
                                {
                                    oForm.Freeze(true);

                                    ActiveRowUdf(true, ref oMtx, ref oUdfForm);
                                    CalculateDiscount(oForm.UniqueID, GeneralVariables.oSOCurrent.CardCode, GeneralVariables.oSOCurrent.PostingDate);
                                }
                            }
                            else
                            {
                                oSBOApplication.MessageBox(errorMsg);
                            }
                        }
                        catch (Exception ex)
                        {
                            bubbleEvent = false;
                            oSBOApplication.MessageBox(ex.Message + " : " + ex.StackTrace);
                        }
                        finally
                        {
                            ActiveRowUdf(false, ref oMtx, ref oUdfForm);
                            if (oForm != null)
                            {
                                oForm.Freeze(false);
                            }

                            Utils.releaseObject(oForm);
                            Utils.releaseObject(oMtx);
                            Utils.releaseObject(oRec);
                        }
                    }
                }
            }

            #endregion
        }
示例#20
0
        private string Copy_Project(int pProjectNo)
        {
            string New_ProjectNo = "-1";
            //Get Project Info through DI API
            Recordset oR_Project_Info = (Recordset)oCompany.GetBusinessObject(BoObjectTypes.BoRecordset);
            string    str_sql         = string.Format("Select * from OPMG where AbsEntry={0}", pProjectNo.ToString());

            oR_Project_Info.DoQuery(str_sql);
            if (oR_Project_Info.RecordCount == 1)
            {
                //Use UI API to create Project
                oApp.ActivateMenuItem("48897");
                var oform1 = oApp.Forms.ActiveForm;
                //Project Type
                string ptype = oR_Project_Info.Fields.Item("TYP").Value.ToString();
                if (ptype == "E")
                {
                    var orad_extype = oform1.Items.Item("234000010").Specific;
                    ((SAPbouiCOM.OptionBtn)orad_extype).Selected = true;
                }
                else
                {
                    var orad_intype = oform1.Items.Item("234000011").Specific;
                    ((SAPbouiCOM.OptionBtn)orad_intype).Selected = true;
                }
                //BPCode
                string bpcode = oR_Project_Info.Fields.Item("CARDCODE").Value.ToString();
                if (!String.IsNullOrEmpty(bpcode))
                {
                    var txt_bpcode = oform1.Items.Item("234000013").Specific;
                    ((SAPbouiCOM.EditText)txt_bpcode).Value = bpcode;
                }
                //BPName
                string bpname = oR_Project_Info.Fields.Item("CARDNAME").Value.ToString();
                if (!String.IsNullOrEmpty(bpname))
                {
                    var txt_bpname = oform1.Items.Item("234000016").Specific;
                    ((SAPbouiCOM.EditText)txt_bpname).Value = bpname;
                }
                //Contact Person
                string contact = oR_Project_Info.Fields.Item("CONTACT").Value.ToString();
                if (!String.IsNullOrEmpty(contact))
                {
                    var cbo_contactperson = oform1.Items.Item("234000018").Specific;
                    ((SAPbouiCOM.ComboBox)cbo_contactperson).Select(contact);
                }
                //Territory
                string territory = oR_Project_Info.Fields.Item("TERRITORY").Value.ToString();
                if (!String.IsNullOrEmpty(territory) && territory != "0")
                {
                    var txt_territory = oform1.Items.Item("234000020").Specific;
                    ((SAPbouiCOM.EditText)txt_territory).Value = territory;
                }
                //Sale Employee
                string employee = oR_Project_Info.Fields.Item("EMPLOYEE").Value.ToString();
                if (!String.IsNullOrEmpty(employee) && employee != "-1")
                {
                    var cbo_employee = oform1.Items.Item("234000023").Specific;
                    ((SAPbouiCOM.ComboBox)cbo_employee).Select(employee);
                }
                //Owner
                string owner = oR_Project_Info.Fields.Item("OWNER").Value.ToString();
                if (!String.IsNullOrEmpty(owner) && owner != "0")
                {
                    var txt_owner = oform1.Items.Item("234000025").Specific;
                    ((SAPbouiCOM.EditText)txt_owner).Value = owner;
                }
                //Bo phan thuc hien
                string u_bpth = oR_Project_Info.Fields.Item("U_BPTH").Value.ToString();
                if (!String.IsNullOrEmpty(u_bpth))
                {
                    var cbo_u_bpth = oform1.Items.Item("U_BPTH").Specific;
                    ((SAPbouiCOM.ComboBox)cbo_u_bpth).Select(u_bpth);
                }
                //Project with Subproject
                string withpahse = oR_Project_Info.Fields.Item("WithPhases").Value.ToString();
                if (withpahse == "Y")
                {
                    var chb_withpahse = oform1.Items.Item("234000027").Specific;
                    ((SAPbouiCOM.CheckBox)chb_withpahse).Checked = true;
                }
                //Project Name
                string pname = oR_Project_Info.Fields.Item("NAME").Value.ToString();
                if (!String.IsNullOrEmpty(pname))
                {
                    var txt_pname = oform1.Items.Item("234000029").Specific;
                    ((SAPbouiCOM.EditText)txt_pname).Value = pname + "_Clone_" + DateTime.Now.ToString("ddMMyyyy HHmmss");
                }
                //Series
                string series = oR_Project_Info.Fields.Item("Series").Value.ToString();
                if (!String.IsNullOrEmpty(series))
                {
                    var cbo_series = oform1.Items.Item("234000031").Specific;
                    ((SAPbouiCOM.ComboBox)cbo_series).Select(series);
                }
                //Status
                string status = oR_Project_Info.Fields.Item("STATUS").Value.ToString();
                if (!String.IsNullOrEmpty(status))
                {
                    var cbo_status = oform1.Items.Item("234000034").Specific;
                    ((SAPbouiCOM.ComboBox)cbo_status).Select(status);
                }
                //Start Date
                string strdate = oR_Project_Info.Fields.Item("START").Value.ToString();
                if (!String.IsNullOrEmpty(strdate))
                {
                    if (DateTime.Parse(strdate).Year > 1900)
                    {
                        var txt_strdate = oform1.Items.Item("234000036").Specific;
                        ((SAPbouiCOM.EditText)txt_strdate).Value = DateTime.Parse(strdate).ToString("yyyyMMdd");
                    }
                }
                //Due Date
                string duedate = oR_Project_Info.Fields.Item("DUEDATE").Value.ToString();
                if (!String.IsNullOrEmpty(duedate))
                {
                    if (DateTime.Parse(duedate).Year > 1900)
                    {
                        var txt_duedate = oform1.Items.Item("234000038").Specific;
                        ((SAPbouiCOM.EditText)txt_duedate).Value = DateTime.Parse(duedate).ToString("yyyyMMdd");
                    }
                }
                //Closing Date
                string closedate = oR_Project_Info.Fields.Item("CLOSING").Value.ToString();
                if (!String.IsNullOrEmpty(closedate))
                {
                    if (DateTime.Parse(closedate).Year > 1900)
                    {
                        var txt_closedate = oform1.Items.Item("234000040").Specific;
                        ((SAPbouiCOM.EditText)txt_closedate).Value = DateTime.Parse(closedate).ToString("yyyyMMdd");
                    }
                }
                //Financial Project
                string finan_project = oR_Project_Info.Fields.Item("FIPROJECT").Value.ToString();
                if (!String.IsNullOrEmpty(finan_project))
                {
                    //var txt_finan_project = oform1.Items.Item("234000049").Specific;
                    //((SAPbouiCOM.EditText)txt_finan_project).Value = finan_project;
                }
                //Overview Panel - Risk Level
                //string risk = oR_Project_Info.Fields.Item("RISK").Value.ToString();
                //if (!String.IsNullOrEmpty(risk))
                //{
                //    oform1.Freeze(true);
                //    oform1.PaneLevel = oform1.Items.Item("234000056").FromPane;//oForm.Items.Item("148").FromPane
                //    var cbo_risk = oform1.Items.Item("234000056").Specific;
                //    ((SAPbouiCOM.ComboBox)cbo_risk).Select(risk);
                //    oform1.Freeze(false);
                //}
                //Overview Panel - Industry
                //string industry = oR_Project_Info.Fields.Item("INDUSTRY").Value.ToString();
                //if (!String.IsNullOrEmpty(industry))
                //{
                //    oform1.Freeze(true);
                //    oform1.PaneLevel = oform1.Items.Item("234000058").FromPane;//oForm.Items.Item("148").FromPane
                //    var cbo_industry = oform1.Items.Item("234000058").Specific;
                //    ((SAPbouiCOM.ComboBox)cbo_industry).Select(industry);
                //    oform1.Freeze(false);
                //}
                //Overview Panel - Comments
                //string comments = oR_Project_Info.Fields.Item("REASON").Value.ToString();
                //if (!String.IsNullOrEmpty(comments))
                //{
                //    var txt_comments = oform1.Items.Item("234000060").Specific;
                //    ((SAPbouiCOM.EditText)txt_comments).Value = comments;
                //}

                //Remark Panel - Free Text
                string freetext = oR_Project_Info.Fields.Item("Free_Text").Value.ToString();
                if (!String.IsNullOrEmpty(freetext))
                {
                    oform1.Freeze(true);
                    oform1.PaneLevel = oform1.Items.Item("234000167").FromPane;//oForm.Items.Item("148").FromPane
                    var txt_freetext = oform1.Items.Item("234000167").Specific;
                    ((SAPbouiCOM.EditText)txt_freetext).Value = freetext;
                    oform1.Freeze(false);
                }
                //U Project Type
                string u_ptype = oR_Project_Info.Fields.Item("U_PRJTYPE").Value.ToString();
                if (!String.IsNullOrEmpty(u_ptype))
                {
                    var cbo_u_ptype = oform1.Items.Item("U_PRJTYPE").Specific;
                    ((SAPbouiCOM.ComboBox)cbo_u_ptype).Select(u_ptype);
                }
                //U Project Group
                string u_pgrp = oR_Project_Info.Fields.Item("U_PRJGROUP").Value.ToString();
                if (!String.IsNullOrEmpty(u_pgrp))
                {
                    var cbo_u_ptype = oform1.Items.Item("U_PRJGROUP").Specific;
                    ((SAPbouiCOM.ComboBox)cbo_u_ptype).Select(u_pgrp);
                }
                //Overview Panel - U_CPHT1
                string u_cpht1 = oR_Project_Info.Fields.Item("U_CPHT1").Value.ToString();
                if (!String.IsNullOrEmpty(u_cpht1))
                {
                    oform1.Freeze(true);
                    oform1.PaneLevel = oform1.Items.Item("U_CPHT1").FromPane;
                    var txt_u_cpht1 = oform1.Items.Item("U_CPHT1").Specific;
                    ((SAPbouiCOM.EditText)txt_u_cpht1).Value = u_cpht1;
                    oform1.Freeze(false);
                }
                //Overview Panel - U_CPHT2
                string u_cpht2 = oR_Project_Info.Fields.Item("U_CPHT2").Value.ToString();
                if (!String.IsNullOrEmpty(u_cpht2))
                {
                    oform1.Freeze(true);
                    oform1.PaneLevel = oform1.Items.Item("U_CPHT2").FromPane;
                    var txt_u_cpht2 = oform1.Items.Item("U_CPHT2").Specific;
                    ((SAPbouiCOM.EditText)txt_u_cpht2).Value = u_cpht2;
                    oform1.Freeze(false);
                }
                //Overview Panel - U_DPBH
                string u_dpbh = oR_Project_Info.Fields.Item("U_DPBH").Value.ToString();
                if (!String.IsNullOrEmpty(u_dpbh))
                {
                    oform1.Freeze(true);
                    oform1.PaneLevel = oform1.Items.Item("U_DPBH").FromPane;
                    var txt_u_dpbh = oform1.Items.Item("U_DPBH").Specific;
                    ((SAPbouiCOM.EditText)txt_u_dpbh).Value = u_dpbh;
                    oform1.Freeze(false);
                }
                //Overview Panel - U_DPCP
                string u_dpcp = oR_Project_Info.Fields.Item("U_DPCP").Value.ToString();
                if (!String.IsNullOrEmpty(u_dpcp))
                {
                    oform1.Freeze(true);
                    oform1.PaneLevel = oform1.Items.Item("U_DPCP").FromPane;
                    var txt_u_dpcp = oform1.Items.Item("U_DPCP").Specific;
                    ((SAPbouiCOM.EditText)txt_u_dpcp).Value = u_dpcp;
                    oform1.Freeze(false);
                }
                //Get New Project No
                var txt_projectno_new = oform1.Items.Item("234000032").Specific;
                New_ProjectNo = ((SAPbouiCOM.EditText)txt_projectno_new).Value;
                //Click Add Button
                oform1.Items.Item("1").Click();
                //Check Add Project Complete ?
                if (((SAPbouiCOM.EditText)oform1.Items.Item("234000032").Specific).Value != New_ProjectNo)
                {
                    oform1.Close();
                }
                else
                {
                    New_ProjectNo = "-1";
                    oApp.MessageBox("Can't copy project !");
                }
            }
            else
            {
                oApp.MessageBox("Không tìm thấy ProjectNo hoặc Trùng ProjectNo");
            }
            return(New_ProjectNo);
        }