Exemplo n.º 1
0
        private void createSPProductionOrder()
        {
            DateTime dt = Convert.ToDateTime(dtHead.GetValue("DocDate", 0));

            for (int i = 0; i < Animals.Rows.Count; i++)
            {
                double AddQty = Math.Round(Convert.ToDouble(Animals.GetValue("Forecast", i)) - Convert.ToDouble(Animals.GetValue("QtySche", i)), 3);

                if (AddQty > 0)
                {
                    SAPbobsCOM.ProductionOrders prodOrder = (SAPbobsCOM.ProductionOrders)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oProductionOrders);

                    prodOrder.ItemNo = Animals.GetValue("ItemCode", i).ToString();
                    double Yield = Convert.ToDouble(Program.objHrmsUI.getScallerValue("Select isnull(U_Yield,0) from oitt where code = '" + prodOrder.ItemNo + "'"));
                    if (Yield == 0)
                    {
                        Yield = 100;
                    }

                    string strSqlDfltPL = "Select isnull(U_B1_dfltPL,'') PL from OITT where Code='" + prodOrder.ItemNo + "'";
                    string strDfltPL    = Convert.ToString(Program.objHrmsUI.getScallerValue(strSqlDfltPL));

                    prodOrder.ProductionOrderType = SAPbobsCOM.BoProductionOrderTypeEnum.bopotDisassembly;
                    prodOrder.PlannedQuantity     = AddQty;
                    prodOrder.DueDate             = dt.Date;
                    prodOrder.PostingDate         = dt.Date;
                    prodOrder.UserFields.Fields.Item("U_B1_Seq").Value = "1";
                    if (strDfltPL != "")
                    {
                        prodOrder.UserFields.Fields.Item("U_PMX_PLCD").Value = strDfltPL;
                    }


                    int result = prodOrder.Add();
                    if (result != 0)
                    {
                        int    errorCode = 0;
                        string errmsg    = "";
                        oCompany.GetLastError(out errorCode, out errmsg);
                        oApplication.MessageBox(errmsg);
                    }
                    else
                    {
                        int newWorEntry = Convert.ToInt32(oCompany.GetNewObjectKey());

                        prodOrder.GetByKey(newWorEntry);
                        for (int p = 0; p < prodOrder.Lines.Count; p++)
                        {
                            prodOrder.Lines.SetCurrentLine(p);
                            prodOrder.Lines.PlannedQuantity = prodOrder.Lines.PlannedQuantity * Yield / 100;
                        }
                        //   prodOrder.ProductionOrderStatus = SAPbobsCOM.BoProductionOrderStatusEnum.boposReleased;
                        prodOrder.Update();
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void createTypeProductionOrder()
        {
            oApplication.SetStatusBarMessage("Creating Main Type Production order of qty ", SAPbouiCOM.BoMessageTime.bmt_Short, false);
            DateTime dt = Convert.ToDateTime(dtHead.GetValue("DocDate", 0));

            double AddQty = 0.00;

            AddQty = Math.Round(Convert.ToDouble(dtHead.GetValue("TodayQty", 0)));
            oApplication.SetStatusBarMessage("Creating Main Item Production order of qty " + AddQty.ToString(), SAPbouiCOM.BoMessageTime.bmt_Short, false);
            if (AddQty > 0)
            {
                SAPbobsCOM.ProductionOrders prodOrder = (SAPbobsCOM.ProductionOrders)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oProductionOrders);

                prodOrder.ItemNo = cbAT.Selected.Value.ToString().Trim();
                double Yield = Convert.ToDouble(Program.objHrmsUI.getScallerValue("Select isnull(U_Yield,0) from oitt where code = '" + prodOrder.ItemNo + "'"));


                if (Yield == 0)
                {
                    Yield = 100;
                }

                string strSqlDfltPL = "Select isnull(U_B1_dfltPL,'') PL from OITT where Code='" + prodOrder.ItemNo + "'";
                string strDfltPL    = Convert.ToString(Program.objHrmsUI.getScallerValue(strSqlDfltPL));



                prodOrder.ProductionOrderType = SAPbobsCOM.BoProductionOrderTypeEnum.bopotDisassembly;
                prodOrder.PlannedQuantity     = AddQty;
                prodOrder.DueDate             = dt.Date;
                prodOrder.PostingDate         = dt.Date;
                prodOrder.UserFields.Fields.Item("U_B1_Seq").Value = "1";
                prodOrder.UserFields.Fields.Item("U_PONum").Value  = newPOEntry.ToString();


                if (strDfltPL != "")
                {
                    prodOrder.UserFields.Fields.Item("U_PMX_PLCD").Value = strDfltPL;
                    string nextSeq = " Select  max( isnull(convert(int,U_B1_SEQ),0))  + 1 from owor where Status<>'L' and ISNUMERIC (U_B1_SEQ) =1 and U_PMX_PLCD = '" + strDfltPL + "'  ";
                    string seq     = Convert.ToString(Program.objHrmsUI.getScallerValue(nextSeq));
                    prodOrder.UserFields.Fields.Item("U_B1_Seq").Value = seq;
                }

                int result = prodOrder.Add();
                if (result != 0)
                {
                    int    errorCode = 0;
                    string errmsg    = "";
                    oCompany.GetLastError(out errorCode, out errmsg);
                    oApplication.MessageBox(errmsg);
                }
                else
                {
                    int newWorEntry = Convert.ToInt32(oCompany.GetNewObjectKey());

                    //prodOrder.GetByKey(newWorEntry);
                    //for (int p = 0; p < prodOrder.Lines.Count; p++)
                    //{
                    //    prodOrder.Lines.SetCurrentLine(p);
                    //    prodOrder.Lines.PlannedQuantity = prodOrder.Lines.PlannedQuantity * Yield / 100;
                    //}
                    //// prodOrder.ProductionOrderStatus = SAPbobsCOM.BoProductionOrderStatusEnum.boposReleased;
                    //prodOrder.Update();
                }
            }
        }