Beispiel #1
0
        public RecipeProductModels CheckInsertProduct(RecipeProductModels model, int ProductType, List <string> ListStoreId)
        {
            var item = new RecipeProductModels();

            using (var cxt = new NuWebContext())
            {
                RecipeProductModels itemDb = null;
                //Check StoreId | ProductId | IngredientId
                if (ProductType == (byte)Commons.EProductType.Dish)
                {
                    itemDb = cxt.I_Recipe_Item.Where(
                        s => s.StoreId.Equals(model.StoreId) &&
                        s.ItemId.Equals(model.ItemId) &&
                        s.IngredientId.Equals(model.IngredientId) &&
                        s.Status == (byte)Commons.EStatus.Actived &&
                        ListStoreId.Contains(s.StoreId)
                        ).Select(x => new RecipeProductModels
                    {
                        Id = x.Id
                    }).FirstOrDefault();
                }
                else if (ProductType == (byte)Commons.EProductType.Modifier)
                {
                    itemDb = cxt.I_Recipe_Modifier.Where(
                        s => s.StoreId.Equals(model.StoreId) &&
                        s.ModifierId.Equals(model.ItemId) &&
                        s.IngredientId.Equals(model.IngredientId) &&
                        s.Status == (byte)Commons.EStatus.Actived &&
                        ListStoreId.Contains(s.StoreId)
                        ).Select(x => new RecipeProductModels
                    {
                        Id = x.Id
                    }).FirstOrDefault();
                }

                if (itemDb != null)
                {
                    item = itemDb;
                }
                return(itemDb);
            }
            //return null;
        }
Beispiel #2
0
        public void UpdateRecipeProduct(RecipeProductModels model, int ProductType)
        {
            using (var cxt = new NuWebContext())
            {
                try
                {
                    if (ProductType == (byte)Commons.EProductType.Dish)
                    {
                        var item = cxt.I_Recipe_Item.Where(s => s.Id == model.Id).FirstOrDefault();
                        if (item != null)
                        {
                            item.UOMId     = model.UOMId;
                            item.Usage     = model.Usage;
                            item.BaseUsage = model.BaseUsage;

                            item.UpdatedBy   = model.UpdatedBy;
                            item.UpdatedDate = DateTime.Now;

                            cxt.SaveChanges();
                        }
                    }
                    else if (ProductType == (byte)Commons.EProductType.Modifier)
                    {
                        var item = cxt.I_Recipe_Modifier.Where(s => s.Id == model.Id).FirstOrDefault();
                        if (item != null)
                        {
                            item.UOMId     = model.UOMId;
                            item.Usage     = model.Usage;
                            item.BaseUsage = model.BaseUsage;

                            item.UpdatedBy   = model.UpdatedBy;
                            item.UpdatedDate = DateTime.Now;

                            cxt.SaveChanges();
                        }
                    }
                }
                catch (Exception e)
                {
                    _logger.Error("RecipeProduct_Update: " + e);
                }
            }
        }
Beispiel #3
0
        public bool Delete(string Id, ref string msg)
        {
            bool result = true;

            using (NuWebContext cxt = new NuWebContext())
            {
                try
                {
                    //
                    var isExist = (from mp in cxt.G_ModulePermission
                                   from ro in cxt.G_RoleOrganization
                                   where mp.ModuleID.Equals(Id) && mp.RoleID.Equals(ro.Id)
                                   select new { mp, ro }).FirstOrDefault();
                    if (isExist != null)
                    {
                        result = false;
                        msg    = "This module is already in use and unable to be deleted.";
                    }
                    else
                    {
                        G_Module itemDelete = (from tb in cxt.G_Module
                                               where tb.Id == Id
                                               select tb).FirstOrDefault();
                        cxt.G_Module.Remove(itemDelete);
                        cxt.SaveChanges();
                    }
                }
                catch (Exception ex)
                {
                    _logger.Error(ex);
                    result = false;
                }
                finally
                {
                    if (cxt != null)
                    {
                        cxt.Dispose();
                    }
                }
            }
            return(result);
        }
Beispiel #4
0
        public List <BusinessDayDisplayModels> GetBusinessDays(DateTime dFrom, DateTime dTo, List <string> lstStoreId, int mode)
        {
            var result = new List <BusinessDayDisplayModels>();

            using (var cxt = new NuWebContext())
            {
                //var query = cxt.G_BusinessDay.Where(ww =>
                //   ww.StartedOn >= dFrom && ww.StartedOn <= dTo
                //    && lstStoreId.Contains(ww.StoreId) && ww.Mode == mode)
                //   .ToList();
                var query = (from b in cxt.G_BusinessDay.AsNoTracking()
                             where b.StartedOn >= dFrom && b.StartedOn <= dTo &&
                             lstStoreId.Contains(b.StoreId) && b.Mode == mode
                             select new BusinessDayModels()
                {
                    StartedOn = b.StartedOn,
                    StoreId = b.StoreId,
                    ClosedOn = b.ClosedOn,
                    Id = b.Id
                }).ToList();
                foreach (var item in query)
                {
                    var obj = new BusinessDayDisplayModels();
                    obj.DateFrom = item.StartedOn;
                    obj.StoreId  = item.StoreId;
                    obj.Id       = item.Id;
                    if (item.ClosedOn == Commons.MinDate)
                    {
                        obj.DateTo      = new DateTime(item.StartedOn.Year, item.StartedOn.Month, item.StartedOn.Day, 23, 59, 59);
                        obj.DateDisplay = item.StartedOn.ToString("dd/MM/yyyy HH:mm") + " - ";
                    }
                    else
                    {
                        obj.DateTo      = item.ClosedOn;
                        obj.DateDisplay = item.StartedOn.ToString("dd/MM/yyyy HH:mm") + " - " + item.ClosedOn.ToString("dd/MM/yyyy HH:mm");
                    }
                    result.Add(obj);
                }
            }
            result = result.OrderBy(oo => oo.DateFrom).ToList();
            return(result);
        }
Beispiel #5
0
        public bool Insert(List <PurchaseOrderDetailModels> models, ref string msg)
        {
            bool result = true;

            using (NuWebContext cxt = new NuWebContext())
            {
                try
                {
                    List <I_Purchase_Order_Detail> listInsert = new List <I_Purchase_Order_Detail>();
                    I_Purchase_Order_Detail        item       = null;
                    foreach (var model in models)
                    {
                        item = new I_Purchase_Order_Detail();

                        item.Id = Guid.NewGuid().ToString();
                        item.PurchaseOrderId      = model.PurchaseOrderId;
                        item.IngredientId         = model.IngredientId;
                        item.Qty                  = model.Qty;
                        item.UnitPrice            = model.UnitPrice;
                        item.Amount               = model.Amount;
                        item.ReceiptNoteQty       = model.ReceiptNoteQty;
                        item.ReturnReceiptNoteQty = model.ReturnReceiptNoteQty;
                        listInsert.Add(item);
                    }
                    cxt.I_Purchase_Order_Detail.AddRange(listInsert);
                    cxt.SaveChanges();
                }
                catch (Exception ex)
                {
                    _logger.Error(ex);
                    result = false;
                }
                finally
                {
                    if (cxt != null)
                    {
                        cxt.Dispose();
                    }
                }
            }
            return(result);
        }
 public List <string> GetDataForSupplier(string SupplierId, string CompanyId)
 {
     using (NuWebContext cxt = new NuWebContext())
     {
         try
         {
             var lstResult = (from IS in cxt.I_Ingredient_Supplier
                              from I in cxt.I_Ingredient
                              where IS.SupplierId.Equals(SupplierId) &&
                              I.IsActive && I.Id.Equals(IS.IngredientId) && I.CompanyId.Equals(CompanyId) && IS.IsActived == true
                              select IS.IngredientId).ToList();
             return(lstResult);
         }
         catch (Exception ex)
         {
             _logger.Error(ex.Message);
             return(null);
         }
     }
 }
Beispiel #7
0
        public List <NoIncludeOnSaleDataReportModels> GetListCateNoIncludeSaleForHourlySale(List <string> lstStoreIds, DateTime dFrom, DateTime dTo, int mode)
        {
            using (var cxt = new NuWebContext())
            {
                var lstResults = cxt.R_NoIncludeOnSaleDataReport.Where(ww => lstStoreIds.Contains(ww.StoreId) &&
                                                                       ww.CreatedDate >= dFrom && ww.CreatedDate <= dTo && ww.Mode == mode)
                                 .GroupBy(gg => new { StoreId = gg.StoreId, Time = (int?)SqlFunctions.DatePart("HH", gg.CreatedDate) })
                                 .Select(ss => new NoIncludeOnSaleDataReportModels()
                {
                    StoreId         = ss.Key.StoreId,
                    Time            = ss.Key.Time.HasValue? ss.Key.Time.Value:0,
                    Amount          = ss.Sum(aa => aa.Amount),
                    DiscountAmount  = ss.Sum(aa => aa.DiscountAmount),
                    PromotionAmount = ss.Sum(aa => aa.PromotionAmount),
                    Tax             = ss.Sum(aa => aa.Tax)
                }).ToList();

                return(lstResults);
            }
        }
Beispiel #8
0
 public async void DeleteTrackingLog()
 {
     using (var cxt = new NuWebContext())
     {
         try
         {
             int month = DateTime.Now.AddMonths(-1).Month, year = DateTime.Now.AddMonths(-1).Year;
             var dataMonthBefore = cxt.G_TrackingLog.Where(ww => ww.CreatedDate.Month == month && ww.CreatedDate.Year == year).ToList();
             if (dataMonthBefore != null && dataMonthBefore.Any())
             {
                 cxt.G_TrackingLog.RemoveRange(dataMonthBefore);
                 cxt.SaveChanges();
             }
         }
         catch (Exception ex)
         {
             _logger.Error(ex);
         }
     }
 }
Beispiel #9
0
        public async void InsertIngredientTrackLog(string code)
        {
            try
            {
                using (var cxt = new NuWebContext())
                {
                    I_IngredientTrackLog trackingLog = new I_IngredientTrackLog();
                    trackingLog.Id          = Guid.NewGuid().ToString();
                    trackingLog.Code        = code;
                    trackingLog.CreatedDate = DateTime.Now;

                    cxt.I_IngredientTrackLog.Add(trackingLog);
                    cxt.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
            }
        }
Beispiel #10
0
 public List <OrderTipModels> GetDataTips(BaseReportModel model)
 {
     using (var cxt = new NuWebContext())
     {
         var lstData = (from tb in cxt.G_OrderTip
                        where model.ListStores.Contains(tb.StoreId) &&
                        (tb.CreatedDate >= model.FromDate &&
                         tb.CreatedDate <= model.ToDate)
                        select new OrderTipModels
         {
             StoreId = tb.StoreId,
             CreatedDate = tb.CreatedDate,
             PaymentId = tb.PaymentId,
             PaymentName = tb.PaymentName,
             Amount = tb.Amount,
             OrderId = tb.OrderId
         }).ToList();
         return(lstData);
     }
 }
Beispiel #11
0
        public bool _Update(List <PurchaseOrderDetailModels> models, List <string> listIdDelete, ref string msg)
        {
            bool result = true;

            using (NuWebContext cxt = new NuWebContext())
            {
                try
                {
                    //Delete Item
                    Delete(listIdDelete, ref msg);
                    //=========
                    List <I_Purchase_Order_Detail> listUpdate = new List <I_Purchase_Order_Detail>();
                    foreach (var model in models)
                    {
                        var itemUpdate = (from tb in cxt.I_Purchase_Order_Detail
                                          where tb.Id == model.Id
                                          select tb).FirstOrDefault();
                        if (itemUpdate != null)
                        {
                            itemUpdate.Qty       = model.Qty;
                            itemUpdate.UnitPrice = model.UnitPrice;
                            itemUpdate.Amount    = model.Amount;
                            cxt.SaveChanges();
                        }
                    }
                }
                catch (Exception ex)
                {
                    _logger.Error(ex);
                    result = false;
                }
                finally
                {
                    if (cxt != null)
                    {
                        cxt.Dispose();
                    }
                }
            }
            return(result);
        }
Beispiel #12
0
        private List <string> ListIngInActive(List <string> lstId)
        {
            List <string> lstIdInActive = lstId;

            using (var cxt = new NuWebContext())
            {
                var listIng = cxt.I_Ingredient.Where(aa => lstIdInActive.Contains(aa.BaseUOMId) && aa.Status != (int)Commons.EStatus.Deleted).Select(x => x.BaseUOMId).ToList();
                listIng.AddRange(cxt.I_Ingredient.Where(aa => lstIdInActive.Contains(aa.ReceivingUOMId) && aa.Status != (int)Commons.EStatus.Deleted).Select(x => x.ReceivingUOMId).ToList());
                listIng.AddRange(cxt.I_Ingredient_UOM.Where(aa => lstIdInActive.Contains(aa.UOMId) /* && aa.Status != (int)Commons.EStatus.Deleted*/).Select(x => x.UOMId).ToList());

                listIng.AddRange(cxt.I_Recipe_Ingredient.Where(aa => (lstIdInActive.Contains(aa.UOMId)) && aa.Status != (int)Commons.EStatus.Deleted).Select(x => x.UOMId).ToList());
                listIng.AddRange(cxt.I_Recipe_Item.Where(aa => lstIdInActive.Contains(aa.UOMId) && aa.Status != (int)Commons.EStatus.Deleted).Select(x => x.UOMId).ToList());
                listIng.AddRange(cxt.I_Recipe_Modifier.Where(aa => lstIdInActive.Contains(aa.UOMId) && aa.Status != (int)Commons.EStatus.Deleted).Select(x => x.UOMId).ToList());

                listIng.AddRange(cxt.I_Stock_Transfer_Detail.Where(aa => lstIdInActive.Contains(aa.UOMId) /*&& aa.Status != (int)Commons.EStatus.Deleted*/).Select(x => x.UOMId).ToList());

                //Remove
                lstIdInActive.RemoveAll(i => listIng.Contains(i));
                return(lstIdInActive);
            }
        }
Beispiel #13
0
 public List <string> GetStoreEmpAccess(string EmpID, string OrganizationId = null)
 {
     using (NuWebContext cxt = new NuWebContext())
     {
         try
         {
             var lstStoreId = new List <string>();
             var lstRoleIds = cxt.G_UserRole.Where(ww => ww.EmployeeID == EmpID && ww.IsActive).Select(ss => ss.RoleID).ToList();
             if (lstRoleIds != null && lstRoleIds.Any())
             {
                 lstStoreId = cxt.G_RoleOnStore.Where(ww => lstRoleIds.Contains(ww.RoleId) && ww.IsActive).Select(ss => ss.StoreId).ToList();
             }
             return(lstStoreId);
         }
         catch (Exception ex)
         {
             _logger.Error(ex.Message);
             return(new List <string>());
         }
     }
 }
Beispiel #14
0
 public List <NoSaleDetailReportModels> GetData(BaseReportModel model, string StoreId)
 {
     using (NuWebContext cxt = new NuWebContext())
     {
         var lstData = (from tb in cxt.R_NoSaleDetailReport
                        where tb.StoreId == StoreId &&
                        (tb.CreatedDate >= model.FromDate && tb.CreatedDate <= model.ToDate)
                        orderby tb.CreatedDate
                        select new NoSaleDetailReportModels
         {
             CashierId = tb.CashierId,
             CashierName = tb.CashierName,
             CreatedDate = tb.CreatedDate,
             DrawerId = tb.DrawerId,
             DrawerName = tb.DrawerName,
             Reason = tb.Reason,
             StoreId = tb.StoreId,
         }).ToList();
         return(lstData);
     }
 }
Beispiel #15
0
        public async void InsertUsageXeroTrackLog(DateTime toDate, string storeId)
        {
            try
            {
                using (var cxt = new NuWebContext())
                {
                    I_UsageManagementXeroTrackLog trackingLog = new I_UsageManagementXeroTrackLog();
                    trackingLog.Id          = Guid.NewGuid().ToString();
                    trackingLog.ToDate      = toDate;
                    trackingLog.StoreId     = storeId;
                    trackingLog.CreatedDate = DateTime.Now;

                    cxt.I_UsageManagementXeroTrackLog.Add(trackingLog);
                    cxt.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
            }
        }
Beispiel #16
0
        public bool Insert(List <ReturnNoteDetailModels> models, ref string msg)
        {
            bool result = true;

            using (NuWebContext cxt = new NuWebContext())
            {
                try
                {
                    List <I_Return_Note_Detail> listInsert = new List <I_Return_Note_Detail>();
                    I_Return_Note_Detail        item       = null;
                    foreach (var model in models)
                    {
                        item                     = new I_Return_Note_Detail();
                        item.Id                  = Guid.NewGuid().ToString();
                        item.ReturnNoteId        = model.ReturnNoteId;
                        item.ReceiptNoteDetailId = model.ReceiptNoteDetailId;
                        item.ReceivedQty         = model.ReceivedQty;
                        item.ReturnQty           = model.ReturnQty;
                        item.IsActived           = model.IsActived;

                        listInsert.Add(item);
                    }
                    cxt.I_Return_Note_Detail.AddRange(listInsert);
                    cxt.SaveChanges();
                }
                catch (Exception ex)
                {
                    _logger.Error(ex);
                    result = false;
                }
                finally
                {
                    if (cxt != null)
                    {
                        cxt.Dispose();
                    }
                }
            }
            return(result);
        }
Beispiel #17
0
        public bool Update(IngredientUOMModels model, ref string msg)
        {
            bool result = true;

            using (NuWebContext cxt = new NuWebContext())
            {
                try
                {
                    var itemUpdate = (from tb in cxt.I_Ingredient_UOM
                                      where tb.Id == model.Id
                                      select tb).FirstOrDefault();

                    itemUpdate.IngredientId = model.IngredientId;
                    itemUpdate.UOMId        = model.UOMId;
                    itemUpdate.BaseUOM      = model.BaseUOM;
                    itemUpdate.ReceivingQty = model.ReceivingQty;

                    itemUpdate.CreatedBy   = model.CreatedBy;
                    itemUpdate.CreatedDate = model.CreatedDate;
                    itemUpdate.UpdatedBy   = model.UpdatedBy;
                    itemUpdate.UpdatedDate = model.UpdatedDate;
                    itemUpdate.IsActived   = model.IsActived;

                    cxt.SaveChanges();
                }
                catch (Exception ex)
                {
                    _logger.Error(ex);
                    result = false;
                }
                finally
                {
                    if (cxt != null)
                    {
                        cxt.Dispose();
                    }
                }
            }
            return(result);
        }
Beispiel #18
0
        public bool Insert(List <DataEntryDetailModels> models, ref string msg)
        {
            bool result = true;

            using (NuWebContext cxt = new NuWebContext())
            {
                try
                {
                    List <I_DataEntryDetail> listInsert = new List <I_DataEntryDetail>();
                    I_DataEntryDetail        item       = null;
                    foreach (var model in models)
                    {
                        item              = new I_DataEntryDetail();
                        item.Id           = Guid.NewGuid().ToString();
                        item.DataEntryId  = model.DataEntryId;
                        item.IngredientId = model.IngredientId;
                        //item.CloseBal = 0;//model.CloseBal;

                        listInsert.Add(item);
                    }

                    cxt.I_DataEntryDetail.AddRange(listInsert);
                    cxt.SaveChanges();
                }
                catch (Exception ex)
                {
                    _logger.Error(ex);
                    result = false;
                }
                finally
                {
                    if (cxt != null)
                    {
                        cxt.Dispose();
                    }
                }
            }
            return(result);
        }
Beispiel #19
0
 public string ListRoleName(List <string> lstRoleId)
 {
     using (NuWebContext cxt = new NuWebContext())
     {
         try
         {
             var models = (from r in cxt.G_RoleOrganization
                           where r.IsActive && lstRoleId.Contains(r.Id)
                           select new RoleOrganizationModels()
             {
                 Name = r.Name
             }).ToList();
             string RoleName = string.Join(", ", models.Select(x => x.Name));
             return(RoleName);
         }
         catch (Exception ex)
         {
             _logger.Error(ex.Message);
             return("");
         }
     }
 }
Beispiel #20
0
 public List <DiscountAndMiscReportModels> GetMiscDiscount(List <string> listStoreId, List <string> listReceiptId, int mode)
 {
     using (var cxt = new NuWebContext())
     {
         var lstData = (from ps in cxt.R_PosSale
                        from psd in cxt.R_PosSaleDetail.Where(ww => ww.StoreId == ps.StoreId && ww.OrderId == ps.OrderId)
                        where listStoreId.Contains(ps.StoreId) &&
                        listReceiptId.Contains(ps.OrderId) &&
                        psd.Mode == mode &&
                        (psd.ItemTypeId == (int)Commons.EProductType.Misc || psd.IsDiscountTotal == true)
                        select new DiscountAndMiscReportModels
         {
             StoreId = ps.StoreId,
             CreatedDate = ps.ReceiptCreatedDate.Value,
             MiscValue = psd.Price,
             DiscountValue = psd.Discount,
             IsDiscountTotal = (psd.IsDiscountTotal.HasValue && psd.IsDiscountTotal.Value == true) ? true : false,
             ItemTypeId = psd.ItemTypeId
         }).ToList();
         return(lstData);
     }
 }
Beispiel #21
0
        public RecipeIngredientModels CheckInsertIngredient(RecipeIngredientModels model)
        {
            var item = new RecipeIngredientModels();

            using (var cxt = new NuWebContext())
            {
                RecipeIngredientModels itemDb = null;
                //Check MixtureIngredientId | IngredientId
                itemDb = cxt.I_Recipe_Ingredient.Where(s => s.MixtureIngredientId.Equals(model.MixtureIngredientId) &&
                                                       s.IngredientId.Equals(model.IngredientId) &&
                                                       s.Status == (byte)Commons.EStatus.Actived)
                         .Select(x => new RecipeIngredientModels
                {
                    Id = x.Id
                }).FirstOrDefault();
                if (itemDb != null)
                {
                    item = itemDb;
                }
                return(itemDb);
            }
        }
Beispiel #22
0
        private List <RecipeItemModel> GetRecipeModifier(string storeId, string ingredientId)
        {
            using (var cxt = new NuWebContext())
            {
                var lstResult = (from i in cxt.I_Recipe_Modifier
                                 join ing in cxt.I_Ingredient on i.IngredientId equals ing.Id
                                 where i.StoreId == storeId && i.IngredientId == ingredientId &&
                                 i.Status != (int)Commons.EStatus.Deleted
                                 select new RecipeItemModel()
                {
                    IngredientId = ing.Id,
                    ItemId = i.ModifierId,
                    IngredientCode = ing.Code,
                    IngredientName = ing.Name,
                    UOMName = ing.BaseUOMName,
                    Usage = 0,
                    BaseUsage = i.Usage
                }).ToList();

                return(lstResult);
            }
        }
Beispiel #23
0
        public List <RecipeProductModels> GetListRecipeProduct(string ProductId, string StoreId, int ProductType, List <string> ListStoreId)
        {
            List <RecipeProductModels> listResults = new List <RecipeProductModels>();

            using (NuWebContext cxt = new NuWebContext())
            {
                if (ProductType == (byte)Commons.EProductType.Dish)
                {
                    var query = (from p in cxt.I_Recipe_Item
                                 where p.ItemId.Equals(ProductId) && p.StoreId.Equals(StoreId) &&
                                 p.Status == (byte)Commons.EStatus.Actived &&
                                 ListStoreId.Contains(p.StoreId)
                                 select new RecipeProductModels
                    {
                        IngredientId = p.IngredientId,
                        Usage = p.Usage,
                        UOMId = p.UOMId,
                        BaseUsage = p.BaseUsage ?? 0
                    }).ToList().AsQueryable();
                    listResults = query.ToList();
                }
                else if (ProductType == (byte)Commons.EProductType.Modifier)
                {
                    var query = (from p in cxt.I_Recipe_Modifier
                                 where p.ModifierId.Equals(ProductId) && p.StoreId.Equals(StoreId) &&
                                 p.Status == (byte)Commons.EStatus.Actived &&
                                 ListStoreId.Contains(p.StoreId)
                                 select new RecipeProductModels
                    {
                        IngredientId = p.IngredientId,
                        Usage = p.Usage,
                        UOMId = p.UOMId,
                        BaseUsage = p.BaseUsage ?? 0
                    }).ToList().AsQueryable();
                    listResults = query.ToList();
                }
            }
            return(listResults);
        }
Beispiel #24
0
        public List <NoIncludeOnSaleDataReportModels> GetListCateNoIncludeSaleForDailyReceipt(List <string> lstStoreIds, DateTime dFrom, DateTime dTo, int mode)
        {
            using (var cxt = new NuWebContext())
            {
                var lstResults = cxt.R_NoIncludeOnSaleDataReport.Where(ww => lstStoreIds.Contains(ww.StoreId) &&
                                                                       ww.CreatedDate >= dFrom && ww.CreatedDate <= dTo && ww.Mode == mode)
                                 .Select(ss => new NoIncludeOnSaleDataReportModels()
                {
                    StoreId         = ss.StoreId,
                    CreatedDate     = ss.CreatedDate,
                    CategoryId      = ss.CategoryId,
                    CategoryName    = ss.CategoryName,
                    Amount          = ss.Amount,
                    Tax             = ss.Tax,
                    DiscountAmount  = ss.DiscountAmount,
                    PromotionAmount = ss.PromotionAmount,
                    OrderId         = ss.OrderId
                }).ToList();

                return(lstResults);
            }
        }
Beispiel #25
0
        public bool Delete(string Id, ref string msg)
        {
            bool result = true;

            using (NuWebContext cxt = new NuWebContext())
            {
                try
                {
                    if (IsCanDelete(Id))
                    {
                        var item = cxt.I_Supplier.Where(tb => tb.Id == Id).FirstOrDefault();
                        if (item != null)
                        {
                            item.Status = (int)Commons.EStatus.Deleted;
                            cxt.SaveChanges();
                        }
                    }
                    else
                    {
                        msg    = "This supplier has been in used. Please deactivate it only.";
                        result = false;
                    }
                }
                catch (Exception ex)
                {
                    _logger.Error(ex);
                    result = false;
                }
                finally
                {
                    if (cxt != null)
                    {
                        cxt.Dispose();
                    }
                }
            }
            return(result);
        }
Beispiel #26
0
        public List <ItemizedSalesAnalysisReportModels> GetItemsNoIncludeSale(List <string> listAllReceiptId, List <string> listStoreId, int mode)
        {
            using (var cxt = new NuWebContext())
            {
                List <ItemizedSalesAnalysisReportModels> lstData = new List <ItemizedSalesAnalysisReportModels>();

                lstData = (from ps in cxt.R_PosSale
                           from psd in cxt.R_PosSaleDetail.Where(ww => ww.StoreId == ps.StoreId && ww.OrderId == ps.OrderId)
                           where listStoreId.Contains(ps.StoreId) &&
                           listAllReceiptId.Contains(ps.OrderId) &&
                           psd.Mode == mode
                           select new ItemizedSalesAnalysisReportModels
                {
                    StoreId = ps.StoreId,
                    CreatedDate = ps.ReceiptCreatedDate.Value,
                    CategoryId = psd.CategoryId,
                    CategoryName = psd.CategoryName,
                    ExtraPrice = psd.ExtraPrice,
                    TotalPrice = psd.TotalAmount - (psd.IsDiscountTotal != true ? psd.Discount : 0) - psd.PromotionAmount,
                    GLAccountCode = psd.GLAccountCode,
                    IsIncludeSale = psd.IsIncludeSale,
                    BusinessId = psd.BusinessId,
                    ServiceCharge = psd.ServiceCharge,
                    Tax = psd.Tax,
                    //ExtraAmount = tb.ExtraAmount.HasValue ? tb.ExtraAmount.Value : 0,
                    TotalAmount = psd.TotalAmount,
                    TotalDiscount = psd.IsDiscountTotal != true ? psd.Discount : 0,
                    ItemTotal = psd.TotalAmount - (psd.IsDiscountTotal != true ? psd.Discount : 0) - psd.PromotionAmount + psd.ExtraPrice,
                    PromotionAmount = psd.PromotionAmount,
                    ReceiptId = psd.OrderId,
                    TaxType = psd.TaxType,
                    GiftCardId = psd.GiftCardId,
                    PoinsOrderId = psd.PoinsOrderId
                }).ToList();

                return(lstData);
            }
        }
Beispiel #27
0
        public bool Insert(ModuleModels model, ref string msg)
        {
            bool result = true;

            using (NuWebContext cxt = new NuWebContext())
            {
                try
                {
                    G_Module item = new G_Module();
                    item.Id = Guid.NewGuid().ToString();

                    item.Name         = model.Name;
                    item.Controller   = model.Controller;
                    item.ParentID     = model.ParentID == null ? "" : model.ParentID;
                    item.CreatedDate  = DateTime.Now;
                    item.CreatedUser  = model.CreatedUser;
                    item.ModifiedDate = DateTime.Now;
                    item.ModifiedUser = model.ModifiedUser;
                    item.IndexNum     = model.IndexNum;

                    cxt.G_Module.Add(item);
                    cxt.SaveChanges();
                }
                catch (Exception ex)
                {
                    _logger.Error(ex);
                    result = false;
                }
                finally
                {
                    if (cxt != null)
                    {
                        cxt.Dispose();
                    }
                }
            }
            return(result);
        }
Beispiel #28
0
        public bool Update(ReturnNoteModels model, ref string msg)
        {
            bool result = true;

            using (NuWebContext cxt = new NuWebContext())
            {
                try
                {
                    var itemUpdate = (from tb in cxt.I_Return_Note
                                      where tb.Id == model.Id
                                      select tb).FirstOrDefault();

                    itemUpdate.ReceiptNoteId = model.ReceiptNoteId;
                    itemUpdate.ReturnNoteNo  = model.ReturnNoteNo;

                    itemUpdate.CreatedBy    = model.CreatedBy;
                    itemUpdate.CreatedDate  = model.CreatedDate;
                    itemUpdate.ModifierBy   = model.ModifierBy;
                    itemUpdate.ModifierDate = model.ModifierDate;
                    itemUpdate.IsActived    = model.IsActived;

                    cxt.SaveChanges();
                }
                catch (Exception ex)
                {
                    _logger.Error(ex);
                    result = false;
                }
                finally
                {
                    if (cxt != null)
                    {
                        cxt.Dispose();
                    }
                }
            }
            return(result);
        }
Beispiel #29
0
        public async void InsertTrackingLog(string tableName, string info, string storeId, bool result)
        {
            try
            {
                using (var cxt = new NuWebContext())
                {
                    G_TrackingLog trackingLog = new G_TrackingLog();
                    trackingLog.Id          = Guid.NewGuid().ToString();
                    trackingLog.TableName   = tableName;
                    trackingLog.StoreId     = storeId;
                    trackingLog.CreatedDate = DateTime.Now;
                    trackingLog.JsonContent = info;
                    trackingLog.IsDone      = result;

                    cxt.G_TrackingLog.Add(trackingLog);
                    cxt.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
            }
        }
Beispiel #30
0
 public List <PaymentModels> GetDataPaymentItemsByGC(BaseReportModel model, List <string> lstGCId)
 {
     using (var cxt = new NuWebContext())
     {
         var lstData = (from tb in cxt.G_PaymentMenthod
                        where model.ListStores.Contains(tb.StoreId) &&
                        (tb.CreatedDate >= model.FromDate && tb.CreatedDate <= model.ToDate) &&
                        tb.Mode == model.Mode &&
                        (lstGCId.Contains(tb.PaymentId) || tb.PaymentCode == (int)Commons.EPaymentCode.GiftCard)
                        //&& (tb.IsInclude ==null ||(tb.IsInclude.HasValue && tb.IsInclude.Value))
                        select new PaymentModels
         {
             StoreId = tb.StoreId,
             CreatedDate = tb.CreatedDate,
             PaymentId = tb.PaymentId,
             PaymentName = tb.PaymentName,
             Amount = tb.Amount,
             OrderId = tb.OrderId,
             IsInclude = tb.IsInclude
         }).ToList();
         return(lstData);
     }
 }