Exemplo n.º 1
0
        public long Save(POCO.MstCustomer t)
        {
            Data.MstCustomer result;
            var mappingProfile = new MappingProfile <POCO.MstCustomer, Data.MstCustomer>();

            using (var ctx = new posDataContext())
            {
                if (t.Id != 0)
                {
                    result = ctx.MstCustomers.SingleOrDefault(x => x.Id == t.Id);

                    mappingProfile.mapper.Map(t, result);
                }
                else
                {
                    result = mappingProfile.mapper.Map <POCO.MstCustomer, Data.MstCustomer>(t);

                    result.TermId           = 2;
                    result.TIN              = "NA";
                    result.WithReward       = false;
                    result.RewardConversion = 0;
                    result.AccountId        = 64;
                    result.EntryUserId      = 1;
                    result.EntryDateTime    = DateTime.Now;
                    result.UpdateUserId     = 1;
                    result.UpdateDateTime   = DateTime.Now;

                    ctx.MstCustomers.InsertOnSubmit(result);
                }

                ctx.SubmitChanges();
            }

            return(result?.Id ?? 0);
        }
Exemplo n.º 2
0
        public void Delete(long id)
        {
            using (var ctx = new posDataContext())
            {
                if (id > 0)
                {
                    var result = ctx.TrnSales.SingleOrDefault(x => x.Id == id);

                    ctx.TrnSales.DeleteOnSubmit(result);
                    ctx.SubmitChanges();
                }
            }
        }
Exemplo n.º 3
0
        public long Save(POCO.TrnCollection t)
        {
            Data.TrnCollection result = new Data.TrnCollection();
            var mappingProfile        = new MappingProfileForTrnCollectionReverse();

            using (var ctx = new posDataContext())
            {
                if (t.Id != 0)
                {
                    //TODO: Start collection view on Xamarin Project
                }
                else
                {
                    var preORNumber    = ctx.TrnCollections?.Where(x => x.CollectionNumber != "NA")?.Max(x => x.CollectionNumber) ?? "001-0001-000000";
                    var splitORNumber  = preORNumber.Split('-');
                    var maxORNumber    = long.Parse(splitORNumber[2]);
                    var newORNumberLng = maxORNumber + 1000001;

                    var newORNumber = $"001-0001-{newORNumberLng.ToString().Substring(1, 6)}";

                    t.PeriodId         = 1;
                    t.CollectionNumber = newORNumber;
                    t.ManualORNumber   = newORNumber;
                    t.TerminalId       = 1;
                    t.PreparedBy       = 1;
                    t.CheckedBy        = 1;
                    t.ApprovedBy       = 1;
                    t.IsCancelled      = false;
                    t.IsLocked         = true;
                    t.EntryUserId      = 1;
                    t.EntryDateTime    = DateTime.Now;
                    t.UpdateUserId     = 1;
                    t.UpdateDateTime   = DateTime.Now;

                    result = mappingProfile.mapper.Map <Data.TrnCollection>(t);

                    ctx.TrnCollections?.InsertOnSubmit(result);
                }

                ctx.SubmitChanges();
            }

            return(result?.Id ?? 0);
        }
Exemplo n.º 4
0
        public long Save(POCO.MstItem t)
        {
            Data.MstItem result;
            var          mappingProfile = new MappingProfile <POCO.MstItem, Data.MstItem>();

            using (var ctx = new posDataContext())
            {
                if (t.Id != 0)
                {
                    result = ctx.MstItems.SingleOrDefault(x => x.Id == t.Id);

                    mappingProfile.mapper.Map(t, result);
                }
                else
                {
                    result = mappingProfile.mapper.Map <POCO.MstItem, Data.MstItem>(t);

                    result.SalesAccountId    = 159;
                    result.AssetAccountId    = 74;
                    result.CostAccountId     = 238;
                    result.InTaxId           = 9;
                    result.OutTaxId          = 9;
                    result.DefaultSupplierId = 23;
                    result.IsPackage         = false;
                    result.ImagePath         = "NA";
                    result.EntryUserId       = 1;
                    result.EntryDateTime     = DateTime.Now;
                    result.UpdateUserId      = 1;
                    result.UpdateDateTime    = DateTime.Now;

                    ctx.MstItems.InsertOnSubmit(result);
                }

                ctx.SubmitChanges();
            }

            return(result?.Id ?? 0);
        }
Exemplo n.º 5
0
        public long Save(POCO.TrnSales t)
        {
            TrnSale result;
            var     mappingProfile = new MappingProfileForTrnSalesReverse();

            using (var ctx = new posDataContext())
            {
                if (t.Id != 0)
                {
                    foreach (var tLine in t.TrnSalesLines.Where(x => x.Id == 0))
                    {
                        tLine.SalesAccountId     = 159;
                        tLine.AssetAccountId     = 74;
                        tLine.CostAccountId      = 238;
                        tLine.TaxAccountId       = 238;
                        tLine.SalesLineTimeStamp = DateTime.Now;
                    }

                    result = ctx.TrnSales.SingleOrDefault(x => x.Id == t.Id);

                    mappingProfile.mapper.Map(t, result);

                    ctx.TrnSalesLines.InsertAllOnSubmit(result.TrnSalesLines.Where(x => x.Id == 0));
                    ctx.TrnSalesLines.DeleteAllOnSubmit(result.TrnSalesLines.Where(x => x.IsDeleted));
                }
                else
                {
                    var preSalesNumber    = ctx.TrnSales?.Max(x => x.SalesNumber) ?? "0001-000000";
                    var splitSalesNumber  = preSalesNumber.Split('-');
                    var maxSalesNumber    = long.Parse(splitSalesNumber[1]);
                    var newSalesNumberLng = maxSalesNumber + 1000001;

                    var newSalesNumber = $"0001-{newSalesNumberLng.ToString().Substring(1, 6)}";

                    t.PeriodId            = 1;
                    t.SalesNumber         = newSalesNumber;
                    t.ManualInvoiceNumber = newSalesNumber;
                    if (t.TermId == 0)
                    {
                        t.TermId = 7;
                    }
                    t.AccountId      = 64;
                    t.SalesAgent     = 1;
                    t.TerminalId     = 1;
                    t.PreparedBy     = 1;
                    t.CheckedBy      = 1;
                    t.ApprovedBy     = 1;
                    t.IsCancelled    = false;
                    t.PaidAmount     = 0;
                    t.CreditAmount   = 0;
                    t.DebitAmount    = 0;
                    t.EntryUserId    = 1;
                    t.EntryDateTime  = DateTime.Now;
                    t.UpdateUserId   = 1;
                    t.UpdateDateTime = DateTime.Now;

                    foreach (var tLine in t.TrnSalesLines)
                    {
                        tLine.SalesAccountId     = 159;
                        tLine.AssetAccountId     = 74;
                        tLine.CostAccountId      = 238;
                        tLine.SalesLineTimeStamp = DateTime.Now;
                    }

                    result = mappingProfile.mapper.Map <TrnSale>(t);

                    ctx.TrnSales?.InsertOnSubmit(result);
                }

                ctx.SubmitChanges();
            }

            return(result?.Id ?? 0);
        }