コード例 #1
0
ファイル: frmRejectO.b1f.cs プロジェクト: xavl369/UGRS
        private void InvoiceRDraft()
        {
            SAPbouiCOM.Form lObjFormDraft = null;

            int  lIntRetCode = 0;
            int  lIntKeyD    = 0;
            int  lIntCounter = 0;
            int  lIntPrevKey = 0;
            bool lBoolDraft  = false;

            string lStrArticle = mObjRejectedDAO.GetArticleToInvoice();

            lObjDraftInvoice = (SAPbobsCOM.Documents)DIApplication.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDrafts);



            var lVarRejectedToInv = from p in lListRejectedToInvoice group p by p.Client into gr select gr;

            try
            {
                foreach (var lVarClient in lVarRejectedToInv)
                {
                    foreach (var item in lVarClient)
                    {
                        lObjErrorListDTO = new DTO.ErrorListDTO();
                        lStrReference    = lStrMainRWhs + "_" + item.Inspection;

                        if (!CheckThreeDays(lIntCounter))
                        {
                            if (!HasInvoice(lStrReference, item.DistNumb))
                            {
                                if (SetCosts(item.Inspection, lIntCounter) != -1)
                                {
                                    lIntKeyD = mObjRejectedDAO.GetDraftKey(lStrReference, lStrArticle);

                                    if (lIntKeyD > 0 && lIntKeyD != lIntPrevKey)
                                    {
                                        lObjDraftInvoice.GetByKey(lIntKeyD);

                                        lObjDraftInvoice.Remove();
                                        lIntKeyD = 0;
                                    }
                                    if (lIntKeyD == 0)
                                    {
                                        lObjDraftInvoice.DocObjectCodeEx = "13";
                                        lObjDraftInvoice.CardCode        = item.Client;
                                        lObjDraftInvoice.Lines.FreeText  = lStrReference;
                                        lObjDraftInvoice.Lines.ItemCode  = lStrArticle;
                                        lObjDraftInvoice.Lines.TaxCode   = mObjRejectedDAO.GetTaxCode(lStrArticle);
                                        lObjDraftInvoice.Lines.Quantity  = item.QuantityConcept;
                                        lObjDraftInvoice.Lines.LineTotal = item.Price;

                                        lObjDraftInvoice.Lines.Add();

                                        lBoolDraft = true;

                                        lObjErrorListDTO.Option     = "Correct";
                                        lObjErrorListDTO.Inspection = lListRejectedToInvoice[lIntCounter].Inspection;
                                        lObjlstErrorDTO.Add(lObjErrorListDTO);
                                    }
                                    //else
                                    //{
                                    //    lObjErrorListDTO.Option = "HasDraft";
                                    //    lObjErrorListDTO.Inspection = lListRejectedToInvoice[lIntCounter].Inspection;
                                    //    lObjlstErrorDTO.Add(lObjErrorListDTO);

                                    //    if (lObjChckBox.Checked)
                                    //    {

                                    //        lIntKeyD = mObjRejectedDAO.GetDraftKey(lStrReference, lStrArticle);

                                    //        if (lIntKeyD > 0 && lIntKeyD != lIntPrevKey)
                                    //        {
                                    //            lObjDraftInvoice.GetByKey(lIntKeyD);
                                    //            if (lObjDraftInvoice.DocDate < lObjDatetime)
                                    //            {
                                    //                lObjDraftInvoice.Remove();
                                    //            }
                                    //            else
                                    //            {

                                    //                lObjFormDraft = Application.SBO_Application.OpenForm((SAPbouiCOM.BoFormObjectEnum)112, "", lIntKeyD.ToString());
                                    //                lIntPrevKey = lIntKeyD;
                                    //            }
                                    //        }
                                    //    }
                                    //}
                                }
                                else
                                {
                                    lObjErrorListDTO.Option     = "InvalidDate";
                                    lObjErrorListDTO.Inspection = lListRejectedToInvoice[lIntCounter].Inspection.ToString();

                                    lObjlstErrorDTO.Add(lObjErrorListDTO);
                                }
                            }
                            else
                            {
                                lObjErrorListDTO.Option     = "WithInvoice";
                                lObjErrorListDTO.Inspection = lListRejectedToInvoice[lIntCounter].Inspection.ToString();

                                lObjlstErrorDTO.Add(lObjErrorListDTO);
                            }
                        }
                        else
                        {
                            lObjErrorListDTO.Option     = "OnTime";
                            lObjErrorListDTO.Inspection = lListRejectedToInvoice[lIntCounter].Inspection.ToString();

                            lObjlstErrorDTO.Add(lObjErrorListDTO);
                        }

                        lIntCounter++;
                    }

                    if (lBoolDraft)
                    {
                        lIntRetCode = lObjDraftInvoice.Add();

                        if (lIntRetCode != 0)
                        {
                            string lStrError = DIApplication.Company.GetLastErrorDescription();
                            Application.SBO_Application.StatusBar.SetText(lStrError
                                                                          , SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error);
                        }

                        lIntKeyD = mObjRejectedDAO.GetDraftKey(lStrReference, lStrArticle);

                        if (lObjChckBox.Checked)
                        {
                            if (lIntKeyD > 0 && lIntKeyD != lIntPrevKey)
                            {
                                lObjFormDraft = Application.SBO_Application.OpenForm((SAPbouiCOM.BoFormObjectEnum) 112, "", lIntKeyD.ToString());
                                lIntPrevKey   = lIntKeyD;
                            }
                        }
                    }
                }
            }
            catch (Exception lObjException)
            {
                throw new DAOException(lObjException.Message, lObjException);
            }
            finally
            {
                MemoryUtility.ReleaseComObject(lObjDraftInvoice);
            }
        }
コード例 #2
0
ファイル: frmRejectO.b1f.cs プロジェクト: xavl369/UGRS
        private void Outputs()
        {
            lObjErrorListDTO = new DTO.ErrorListDTO();
            int  lIntRetCode = 0;
            int  lIntSeries  = mObjRejectedDAO.GetSerieForOutputs(lIntUserSign);
            bool lBoolValid  = false;

            lObjGoodsIssues = (SAPbobsCOM.Documents)DIApplication.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInventoryGenExit);
            try
            {
                for (int i = 0; i < lListRejectedToInvoice.Count; i++)
                {
                    lObjErrorListDTO = new DTO.ErrorListDTO();
                    lStrReference    = lStrMainRWhs + "_" + lListRejectedToInvoice[i].Inspection;

                    if (CheckThreeDays(i) || HasInvoice(lStrReference, lListRejectedToInvoice[i].DistNumb))
                    {
                        lObjGoodsIssues.HandWritten = SAPbobsCOM.BoYesNoEnum.tNO;
                        lObjGoodsIssues.Series      = lIntSeries;
                        lObjGoodsIssues.UserFields.Fields.Item("U_MQ_OrigenFol").Value = lListRejectedToInvoice[i].Inspection;
                        lObjGoodsIssues.UserFields.Fields.Item("U_GLO_InMo").Value     = "S-GAN";
                        lObjGoodsIssues.DocDate    = DateTime.Today;
                        lObjGoodsIssues.DocDueDate = DateTime.Today;


                        lObjGoodsIssues.Lines.ItemCode      = lListRejectedToInvoice[i].HeadType;
                        lObjGoodsIssues.Lines.WarehouseCode = lStrMainRWhs;
                        lObjGoodsIssues.Lines.Quantity      = lListRejectedToInvoice[i].Quantity;

                        lObjGoodsIssues.Lines.BatchNumbers.BatchNumber = lListRejectedToInvoice[i].DistNumb;
                        lObjGoodsIssues.Lines.BatchNumbers.Quantity    = lListRejectedToInvoice[i].Quantity;

                        lObjGoodsIssues.Lines.BatchNumbers.Add();

                        lObjGoodsIssues.Lines.Add();

                        lIntRetCode = lObjGoodsIssues.Add();

                        if (lIntRetCode != 0)
                        {
                            string error = DIApplication.Company.GetLastErrorDescription();
                            Application.SBO_Application.StatusBar.SetText(error
                                                                          , SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error);
                            lBoolValid = false;
                        }
                        else
                        {
                            lBoolValid = true;
                        }



                        if (lBoolValid == true)
                        {
                            lObjErrorListDTO.Option     = "CorrectOutput";
                            lObjErrorListDTO.Inspection = lListRejectedToInvoice[i].Inspection;
                            lObjlstErrorDTO.Add(lObjErrorListDTO);
                        }
                    }
                    else
                    {
                        lObjErrorListDTO.Option     = "OutOfTime";
                        lObjErrorListDTO.Inspection = lListRejectedToInvoice[i].Inspection.ToString();

                        lObjlstErrorDTO.Add(lObjErrorListDTO);
                    }
                }
            }
            catch (Exception lObjException)
            {
                throw new DAOException(lObjException.Message, lObjException);
            }
            finally
            {
                MemoryUtility.ReleaseComObject(lObjGoodsIssues);
            }
        }