Exemple #1
0
        static void Main(string[] args)
        {
            try
            {
                ConfigTempoSinglenton currentconfig = ConfigTempoSinglenton.GetInstance();
                Entrence.ConnectionString = string.Format(currentconfig.ConectionString, AppDomain.CurrentDomain.BaseDirectory);
                LoadConfig();
                var context = new TempoDataBaseContext();
                FirmaId               = ConfigTempoSinglenton.GetInstance().ActiveFirma;
                KindDocLookup         = new ObservableCollection <LookUpSpecific>(context.GetAllDocTypes());
                TypeDocuments         = new ObservableCollection <LookUpSpecific>(context.GetAllDocTypes());
                ItemsDdsDnevPurchases = new ObservableCollection <DdsItemModel>(context.GetAllDnevItems(1));
                ItemsDdsDnevSales     = new ObservableCollection <DdsItemModel>(context.GetAllDnevItems(0));


                // Test if input arguments were supplied:
                if (args.Length < 1)
                {
                    System.Console.WriteLine("Невалидни Параметри");
                    return;
                }
                string path    = args[0];
                string command = "2";
                if (args.Length > 1)
                {
                    command = args[1];
                }
                int num;
                switch (command)
                {
                case "1":
                {
                    serialiseConto(context);
                    break;
                }

                case "2":
                {
                    InsertConto(context, path);
                    break;
                }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.ReadKey();
            }
            //serialiseConto(context);
        }
Exemple #2
0
        private static decimal SaveDDS(TempoDataBaseContext context, ContoAll allconto)
        {
            var itemsDdsDnevPurchases    = new List <DdsItemModel>(context.GetAllDnevItems(1));
            var itemsDdsDnevSales        = new List <DdsItemModel>(context.GetAllDnevItems(0));
            var currItemDdsDnevPurchases = itemsDdsDnevPurchases.FirstOrDefault(e => e.Code == allconto.KindDds);
            var currItemDdsDnevSales     = itemsDdsDnevSales.FirstOrDefault(e => e.Code == allconto.KindDds);
            int codeDnev = 2;

            if (allconto.KindDeal == "1")
            {
                codeDnev = 1;
            }
            DdsDnevnikModel ddsDnevnikModel = context.LoadDenevnicItem(allconto.Conto.Id, codeDnev);

            //ddsDnevnikModel.DocId = allconto.Conto.DocNum;
            ddsDnevnikModel.Date         = allconto.Conto.Data;
            ddsDnevnikModel.DataF        = allconto.Conto.Data;
            ddsDnevnikModel.KindActivity = codeDnev;
            ddsDnevnikModel.KindDoc      = 1;
            ddsDnevnikModel.Title        = codeDnev == 1 ? "Дневник покупки" : "Дневник продажби";
            ddsDnevnikModel.CodeDoc      = allconto.Conto.KD;
            ddsDnevnikModel.Stoke        = allconto.Conto.Reason;
            ddsDnevnikModel.DdsIncluded  = allconto.IsDdsInclude ? "ВКЛЮЧЕН ДДС" : "НЕВКЛЮЧЕН ДДС";
            if (codeDnev == 2)
            {
                if (allconto.ItemsCredit != null)
                {
                    foreach (SaldoItem saldoItem in allconto.ItemsCredit)
                    {
                        if (saldoItem.IsLookUp && saldoItem.Name.Contains("Контрагент"))
                        {
                            ddsDnevnikModel.LookupID        = saldoItem.Relookup;
                            ddsDnevnikModel.LookupElementID = saldoItem.LiD;
                            ddsDnevnikModel.ClNum           = saldoItem.Value;
                        }
                        if (saldoItem.Name.Contains("Дата на фактура"))
                        {
                            ddsDnevnikModel.DataF = saldoItem.ValueDate;
                        }
                        if (saldoItem.Name.Contains("Номер фактура"))
                        {
                            ddsDnevnikModel.DocId = saldoItem.Value;
                        }
                    }
                }
                if (allconto.ItemsDebit != null)
                {
                    foreach (SaldoItem saldoItem in allconto.ItemsDebit)
                    {
                        if (saldoItem.IsLookUp && saldoItem.Name.Contains("Контрагент"))
                        {
                            ddsDnevnikModel.LookupID        = saldoItem.Relookup;
                            ddsDnevnikModel.LookupElementID = saldoItem.LiD;
                            ddsDnevnikModel.ClNum           = saldoItem.Value;
                        }
                        if (saldoItem.Name.Contains("Дата на фактура"))
                        {
                            ddsDnevnikModel.DataF = saldoItem.ValueDate;
                        }
                        if (saldoItem.Name.Contains("Номер фактура"))
                        {
                            ddsDnevnikModel.DocId = saldoItem.Value;
                        }
                    }
                }
            }
            else
            {
                if (allconto.ItemsDebit != null)
                {
                    foreach (SaldoItem saldoItem in allconto.ItemsDebit)
                    {
                        if (saldoItem.IsLookUp && saldoItem.Name.Contains("Контрагент"))
                        {
                            ddsDnevnikModel.LookupID        = saldoItem.Relookup;
                            ddsDnevnikModel.LookupElementID = saldoItem.LiD;
                            ddsDnevnikModel.ClNum           = saldoItem.Value;
                        }
                        if (saldoItem.Name.Contains("Дата на фактура"))
                        {
                            ddsDnevnikModel.DataF = saldoItem.ValueDate;
                        }
                        if (saldoItem.Name.Contains("Номер фактура"))
                        {
                            ddsDnevnikModel.DocId = saldoItem.Value;
                        }
                    }
                }
                if (allconto.ItemsDebit != null)
                {
                    foreach (SaldoItem saldoItem in allconto.ItemsCredit)
                    {
                        if (saldoItem.IsLookUp && saldoItem.Name.Contains("Контрагент"))
                        {
                            ddsDnevnikModel.LookupID        = saldoItem.Relookup;
                            ddsDnevnikModel.LookupElementID = saldoItem.LiD;
                            ddsDnevnikModel.ClNum           = saldoItem.Value;
                        }
                        if (saldoItem.Name.Contains("Дата на фактура"))
                        {
                            ddsDnevnikModel.DataF = saldoItem.ValueDate;
                        }
                        if (saldoItem.Name.Contains("Номер фактура"))
                        {
                            ddsDnevnikModel.DocId = saldoItem.Value;
                        }
                    }
                }
            }

            if (allconto.ItemsCredit == null && allconto.ItemsDebit == null)
            {
                ddsDnevnikModel.DataF    = DataFactura;
                ddsDnevnikModel.Bulstat  = Bulstad;
                ddsDnevnikModel.Nzdds    = Vat ?? Bulstad;
                ddsDnevnikModel.DocId    = Factura;
                ddsDnevnikModel.LookupID = 17;
                ddsDnevnikModel.ClNum    = CodeClient;
            }
            decimal ddspercent = 0;

            ddspercent = codeDnev == 1
                    ? currItemDdsDnevPurchases != null ? currItemDdsDnevPurchases.DdsPercent : 0
                    : currItemDdsDnevSales != null ? currItemDdsDnevSales.DdsPercent : 0;
            string name = codeDnev == 1
                    ? currItemDdsDnevPurchases != null ? currItemDdsDnevPurchases.Name : ""
                    : currItemDdsDnevSales != null ? currItemDdsDnevSales.Name : "";
            var vm = new DdsViewModel(ddsDnevnikModel, new DdsDnevnicItem
            {
                DdsPercent = ddspercent,
                DdsSuma    = allconto.Conto.Oborot,
                Name       = name,
                In         = true
            });

            vm.SaveCommand.Execute(null);
            return(Decimal.Round(allconto.Conto.Oborot * ddspercent / 100, 2));
        }