Example #1
0
        private void changeStatus()
        {
            string selButton      = btAct.Selected.Value;
            string confirmMessage = "Are you sure you want to release selected production orders? ";

            if (selButton == "02")
            {
                confirmMessage = "Are you sure you want to cancel selected production orders? ";
            }
            int confirmresult = oApplication.MessageBox(confirmMessage, 1, "Yes", "No");

            if (confirmresult == 1)
            {
                SAPbobsCOM.ProductionOrders prodOrder = (SAPbobsCOM.ProductionOrders)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oProductionOrders);

                int selRowInd = 0;


                for (int i = 1; i <= mtReport.RowCount; i++)
                {
                    if (mtReport.IsRowSelected(i))
                    {
                        selRowInd = i - 1;

                        string DocEntry = Convert.ToString(dtRpt.GetValue("DocEntry", selRowInd));
                        prodOrder.GetByKey(Convert.ToInt32(DocEntry));
                        if (selButton == "01")
                        {
                            prodOrder.ProductionOrderStatus = SAPbobsCOM.BoProductionOrderStatusEnum.boposReleased;
                        }
                        else
                        {
                            prodOrder.ProductionOrderStatus = SAPbobsCOM.BoProductionOrderStatusEnum.boposCancelled;
                        }

                        int result = prodOrder.Update();
                        if (result != 0)
                        {
                            int    errorCode = 0;
                            string errmsg    = "";
                            oCompany.GetLastError(out errorCode, out errmsg);
                            oApplication.MessageBox(errmsg);
                        }
                        else
                        {
                        }
                    }
                }
            }
        }
Example #2
0
        public override void etAfterCmbSelect(ref SAPbouiCOM.ItemEvent pVal, ref bool BubbleEvent)
        {
            base.etAfterCmbSelect(ref pVal, ref BubbleEvent);
            if (pVal.ItemUID == cbPL.Item.UniqueID && !initiallizing)
            {
                fillReport();
            }
            if (pVal.ItemUID == btAct.Item.UniqueID)
            {
                changeStatus();

                fillReport();
                btAct.Caption = "Change To";
            }
            if (pVal.ItemUID == btPL.Item.UniqueID)
            {
                assignPL();

                fillReport();
                btPL.Caption = "Assign to Production Line";
            }
            if (pVal.ItemUID == mtReport.Item.UniqueID)
            {
                if (pVal.ColUID == "cProdLine" || pVal.ColUID == "cLabel" || pVal.ColUID == "cFT")
                {
                    mtReport.FlushToDataSource();
                    int selRowIndex = pVal.Row - 1;
                    if (selRowIndex >= 0)
                    {
                        string DocEntry       = Convert.ToString(dtRpt.GetValue("DocEntry", selRowIndex));
                        string ProductionLine = Convert.ToString(dtRpt.GetValue("ProdLine", selRowIndex));
                        string Label          = Convert.ToString(dtRpt.GetValue("Label", selRowIndex));
                        SAPbobsCOM.ProductionOrders prodOrder = (SAPbobsCOM.ProductionOrders)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oProductionOrders);
                        prodOrder.GetByKey(Convert.ToInt32(DocEntry));

                        prodOrder.UserFields.Fields.Item("U_PMX_PLCD").Value = ProductionLine;
                        prodOrder.UserFields.Fields.Item("U_B1_Label").Value = Label;

                        int result = prodOrder.Update();
                        if (result != 0)
                        {
                            int    errorCode = 0;
                            string errmsg    = "";
                            oCompany.GetLastError(out errorCode, out errmsg);
                            oApplication.MessageBox(errmsg);
                        }
                    }
                }
            }
        }
Example #3
0
        public override void etAfterValidate(ref SAPbouiCOM.ItemEvent pVal, ref bool BubbleEvent)
        {
            base.etAfterValidate(ref pVal, ref BubbleEvent);
            if (pVal.ItemUID == txFrom.Item.UniqueID || pVal.ItemUID == txTo.Item.UniqueID)
            {
                fillReport();
            }
            if (pVal.ItemUID == mtReport.Item.UniqueID)
            {
                if (pVal.ColUID == "cFT")
                {
                    mtReport.FlushToDataSource();
                    int selRowIndex = pVal.Row - 1;
                    if (selRowIndex >= 0)
                    {
                        string DocEntry = Convert.ToString(dtRpt.GetValue("DocEntry", selRowIndex));
                        string Seq      = Convert.ToString(dtRpt.GetValue("Seq", selRowIndex));
                        string FreeText = Convert.ToString(dtRpt.GetValue("FreeText", selRowIndex));
                        string prodLine = Convert.ToString(dtRpt.GetValue("ProdLine", selRowIndex));

                        if (pVal.ColUID == "cFT")
                        {
                            SAPbobsCOM.ProductionOrders prodOrder = (SAPbobsCOM.ProductionOrders)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oProductionOrders);
                            prodOrder.GetByKey(Convert.ToInt32(DocEntry));

                            prodOrder.UserFields.Fields.Item("U_B1_FrTxt").Value = FreeText;
                            int result = prodOrder.Update();
                            if (result != 0)
                            {
                                int    errorCode = 0;
                                string errmsg    = "";
                                oCompany.GetLastError(out errorCode, out errmsg);
                                oApplication.MessageBox(errmsg);
                            }
                            else
                            {
                            }
                        }
                        else
                        {
                            //  UpdateSeq(Convert.ToInt32(DocEntry), Convert.ToInt32(Seq), prodLine);
                        }
                    }
                }
            }
        }
Example #4
0
        private void assignPL()
        {
            string selPL          = btPL.Selected.Value;
            string selPLName      = btPL.Selected.Description;
            string confirmMessage = "Are you sure you want selected production orders assign to  " + selPLName;
            int    confirmresult  = oApplication.MessageBox(confirmMessage, 1, "Yes", "No");

            if (confirmresult == 1)
            {
                SAPbobsCOM.ProductionOrders prodOrder = (SAPbobsCOM.ProductionOrders)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oProductionOrders);

                int selRowInd = 0;

                string posLast = "Y";
                if (opFirst.Selected)
                {
                    posLast = "N";
                }

                string maxSeqNum = Program.objHrmsUI.getScallerValue("Select isnull( max( convert(int, U_B1_Seq)),0)  from owor where U_PMX_PLCD='" + selPL + "' and isnull(owor.Status,'')<>'C' ");
                if (maxSeqNum == "")
                {
                    maxSeqNum = "0";
                }
                int maxSeqNumVal = Convert.ToInt32(maxSeqNum);


                for (int i = 1; i <= mtReport.RowCount; i++)
                {
                    if (mtReport.IsRowSelected(i))
                    {
                        maxSeqNumVal++;
                        selRowInd = i - 1;

                        string DocEntry = Convert.ToString(dtRpt.GetValue("DocEntry", selRowInd));
                        prodOrder.GetByKey(Convert.ToInt32(DocEntry));
                        prodOrder.UserFields.Fields.Item("U_PMX_PLCD").Value = selPL;

                        if (posLast == "Y")
                        {
                            prodOrder.UserFields.Fields.Item("U_B1_Seq").Value = maxSeqNumVal.ToString();
                        }
                        else
                        {
                            prodOrder.UserFields.Fields.Item("U_B1_Seq").Value = "1";
                        }


                        int result = prodOrder.Update();
                        if (result != 0)
                        {
                            maxSeqNumVal--;
                            int    errorCode = 0;
                            string errmsg    = "";
                            oCompany.GetLastError(out errorCode, out errmsg);
                            oApplication.MessageBox(errmsg);
                        }
                        else
                        {
                            if (posLast == "N")
                            {
                                string strUpdate = "Update owor set U_B1_SEQ = isnull(U_B1_SEQ,999)  +1 where U_PMX_PLCD = '" + selPL + "'  and docentry <>  '" + DocEntry.ToString() + "' ; ";
                                Program.objHrmsUI.ExecQuery(strUpdate, "Increment old Seq");
                            }
                        }
                    }
                }
            }
        }
Example #5
0
        private void OnTimedEvent(object source, System.Timers.ElapsedEventArgs e)
        {
            if (!busy)
            {
                busy = true;


                try
                {
                    SAPbobsCOM.Recordset rsetUDF = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
                    bool oFlag = true;


                    rsetUDF.DoQuery("select top 1 dbo.getqrystr('PoToRelease') as QryStr from oitm ");
                    string strQry = Convert.ToString(rsetUDF.Fields.Item("QryStr").Value);

                    rsetUDF.DoQuery(strQry);

                    if (rsetUDF.EoF)
                    {
                    }
                    else
                    {
                        SAPbobsCOM.ProductionOrders addedpo = (SAPbobsCOM.ProductionOrders)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oProductionOrders);
                        while (!rsetUDF.EoF)
                        {
                            string strKey = Convert.ToString(rsetUDF.Fields.Item("DocEntry").Value);
                            addedpo.GetByKey(Convert.ToInt32(strKey));
                            addedpo.ProductionOrderStatus = SAPbobsCOM.BoProductionOrderStatusEnum.boposReleased;
                            addedpo.Update();
                            oApplication.StatusBar.SetText("Updated status of Production Order " + Convert.ToString(rsetUDF.Fields.Item("DocNum").Value) + " from Planned to Released!", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Success);
                            rsetUDF.MoveNext();
                        }

                        System.Runtime.InteropServices.Marshal.ReleaseComObject(addedpo);
                        addedpo = null;
                        GC.Collect();
                    }



                    System.Runtime.InteropServices.Marshal.ReleaseComObject(rsetUDF);
                    rsetUDF = null;
                    GC.Collect();
                }
                catch (Exception ex)
                {
                    oApplication.SetStatusBarMessage(ex.Message);
                }
                finally
                {
                }



                busy = false;
            }


            //sendMessage();
        }