示例#1
0
 public ActionResult Index(string?userName, string?password)
 {
     try
     {
         if (!String.IsNullOrEmpty(userName))
         {
             LoginModel loginModel = new LoginModel();
             loginModel = _iLoginService.GetLogin(userName, password);
             if (loginModel != null)
             {
                 List <UserPageRolePermissionModel> userPageRolePermissionModels = _iLoginService.GetUserPageRolePermission(loginModel.WebRoleId);
                 if (userPageRolePermissionModels.Count > 0)
                 {
                     MergeRolePermission(userPageRolePermissionModels);
                 }
                 MergeLogin(loginModel);
                 return(RedirectToAction("Index", "Home"));
             }
             else
             {
                 ViewBag.Message  = "";
                 ViewBag.Validate = "Invalid Username or Password!!!";
             }
         }
         SystemLogs.Register("Login.Index method called!!!");
     }
     catch (Exception ex)
     {
         SystemLogs.Register(ex.Message);
     }
     return(View());
 }
        public async Task <IActionResult> ExportAssetItem(int storeId, int categoryId)
        {
            List <InventoryOpenigStockImport> inventoryOpenigStockImports = new List <InventoryOpenigStockImport>();

            string   sWebRootFolder = _hostingEnvironment.WebRootPath;
            string   sFileName      = @"AssetItem_OpeningStock.xlsx";
            string   URL            = string.Format("{0}://{1}/{2}", Request.Scheme, Request.Host, sFileName);
            FileInfo file           = new FileInfo(Path.Combine(sWebRootFolder, sFileName));
            var      memory         = new MemoryStream();

            try
            {
                using (var fs = new FileStream(Path.Combine(sWebRootFolder, sFileName), FileMode.Create, FileAccess.Write))
                {
                    IWorkbook workbook;
                    workbook = new XSSFWorkbook();
                    ISheet excelSheet = workbook.CreateSheet("AssetItem_OpeningStock");
                    IRow   row        = excelSheet.CreateRow(0);
                    row.CreateCell(0).SetCellValue("Asset Item Id");
                    row.CreateCell(1).SetCellValue("Asset Item Category");
                    row.CreateCell(2).SetCellValue("Asset Item");
                    row.CreateCell(3).SetCellValue("Physical Stock");
                    //    row.CreateCell(4).SetCellValue("Physical Stock Date");

                    inventoryOpenigStockImports = _iInventoryService.GetInventoryOpeningStockByStore(storeId, categoryId, 2);

                    int intRow = 1;
                    foreach (var item in inventoryOpenigStockImports)
                    {
                        row = excelSheet.CreateRow(intRow);
                        row.CreateCell(0).SetCellValue(item.FoodmenuId);
                        row.CreateCell(1).SetCellValue(item.FoodmenuCategoryname);
                        row.CreateCell(2).SetCellValue(item.Foodmenuname);
                        row.CreateCell(3).SetCellValue(item.PhysicalStockQty.ToString());
                        //  row.CreateCell(4).SetCellValue(item.PhysicalDatetime.ToString("dd/mm/yyyy"));
                        // row.CreateCell(4).SetCellValue("");
                        intRow = intRow + 1;
                    }
                    workbook.Write(fs);
                }
                using (var stream = new FileStream(Path.Combine(sWebRootFolder, sFileName), FileMode.Open))
                {
                    await stream.CopyToAsync(memory);
                }
                memory.Position = 0;
            }
            catch (Exception ex)
            {
                SystemLogs.Register(ex.Message);
            }
            return(File(memory, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", sFileName));
        }
示例#3
0
 public void MergeLogin(LoginModel loginModel)
 {
     try
     {
         LoginInfo.Userid             = loginModel.Id;
         LoginInfo.Username           = loginModel.Username;
         LoginInfo.RoleTypeId         = loginModel.RoleTypeId;
         LoginInfo.ClientName         = loginModel.ClientName;
         LoginInfo.Address1           = loginModel.Address1;
         LoginInfo.Address2           = loginModel.Address2;
         LoginInfo.Email              = loginModel.Email;
         LoginInfo.Phone              = loginModel.Phone;
         LoginInfo.Logo               = loginModel.Logo;
         LoginInfo.WebSite            = loginModel.WebSite;
         LoginInfo.ReceiptPrefix      = loginModel.ReceiptPrefix;
         LoginInfo.OrderPrefix        = loginModel.OrderPrefix;
         LoginInfo.TimeZone           = loginModel.TimeZone;
         LoginInfo.Header             = loginModel.Header;
         LoginInfo.Footer             = loginModel.Footer;
         LoginInfo.Footer1            = loginModel.Footer1;
         LoginInfo.Footer2            = loginModel.Footer2;
         LoginInfo.Footer3            = loginModel.Footer3;
         LoginInfo.Footer4            = loginModel.Footer4;
         LoginInfo.MainWindowSettings = loginModel.MainWindowSettings;
         LoginInfo.HeaderMarqueeText  = loginModel.HeaderMarqueeText;
         LoginInfo.DeliveryList       = loginModel.DeliveryList;
         LoginInfo.DiscountList       = loginModel.DiscountList;
         LoginInfo.Powerby            = loginModel.Powerby;
         LoginInfo.Lastname           = loginModel.Lastname;
         LoginInfo.Firstname          = loginModel.Firstname;
         LoginInfo.TaxInclusive       = loginModel.TaxInclusive;
         LoginInfo.IsItemOverright    = loginModel.IsItemOverright;
         LoginInfo.VATLabel           = loginModel.VATLabel;
         LoginInfo.PINLabel           = loginModel.PINLabel;
         LoginInfo.FromEmailAddress   = loginModel.FromEmailAddress;
         LoginInfo.EmailDisplayName   = loginModel.EmailDisplayName;
         LoginInfo.FromEmailPassword  = loginModel.FromEmailPassword;
         LoginInfo.WebRoleId          = loginModel.WebRoleId;
         LoginInfo.FromDate           = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).ToString("dd/MM/yyyy");
         LoginInfo.ToDate             = DateTime.Now.ToString("dd/MM/yyyy");
         LoginInfo.FoodMenuId         = -1;
         LoginInfo.CategoryId         = -1;
         LoginInfo.OutletId           = -1;
         LoginInfo.InvoiceTerms       = loginModel.InvoiceTerms;
     }
     catch (Exception ex)
     {
         SystemLogs.Register(ex.Message);
     }
 }
        public ActionResult ImportData(int storeId, int itemType)
        {
            InventoryOpenigStockImport        item     = new InventoryOpenigStockImport();
            List <InventoryOpenigStockImport> ItemList = new List <InventoryOpenigStockImport>();
            Random        _random = new Random();
            StringBuilder sb      = new StringBuilder();

            try
            {
                IFormFile file            = Request.Form.Files[0];
                string    folderName      = "Upload";
                string    webRootPath     = _hostingEnvironment.WebRootPath;
                string    contentRootPath = _hostingEnvironment.ContentRootPath;

                string newPath = Path.Combine(webRootPath, folderName);
                string BatchId = DateTime.UtcNow.AddMinutes(LoginInfo.Timeoffset).ToString("MM/dd/yyyy HH:mm").Replace("/", "").Replace(" ", "").Replace(":", "").ToString() + _random.Next(1000).ToString();
                if (!Directory.Exists(newPath))
                {
                    Directory.CreateDirectory(newPath);
                }
                if (file.Length > 0)
                {
                    string sFileExtension = Path.GetExtension(file.FileName).ToLower();
                    ISheet sheet;
                    string fullPath = Path.Combine(newPath, file.FileName);
                    using (var stream = new FileStream(fullPath, FileMode.Create))
                    {
                        file.CopyTo(stream);
                        stream.Position = 0;
                        if (sFileExtension == ".xls")
                        {
                            HSSFWorkbook hssfwb = new HSSFWorkbook(stream); //This will read the Excel 97-2000 formats
                            sheet = hssfwb.GetSheetAt(0);                   //get first sheet from workbook
                        }
                        else
                        {
                            XSSFWorkbook hssfwb = new XSSFWorkbook(stream); //This will read 2007 Excel format
                            sheet = hssfwb.GetSheetAt(0);                   //get first sheet from workbook
                        }
                        IRow headerRow = sheet.GetRow(0);                   //Get Header Row
                        int  cellCount = headerRow.LastCellNum;
                        sb.Append("<p>Process completed successfully</p>");
                        sb.Append("<table class='table table-bordered'><tr>");
                        for (int j = 0; j < cellCount; j++)
                        {
                            NPOI.SS.UserModel.ICell cell = headerRow.GetCell(j);
                            if (cell == null || string.IsNullOrWhiteSpace(cell.ToString()))
                            {
                                continue;
                            }
                            sb.Append("<th>" + cell.ToString() + "</th>");
                        }
                        sb.Append("</tr>");
                        sb.AppendLine("<tr>");
                        for (int i = (sheet.FirstRowNum + 1); i <= sheet.LastRowNum; i++) //Read Excel File
                        {
                            IRow row = sheet.GetRow(i);
                            if (row == null)
                            {
                                continue;
                            }
                            if (row.Cells.All(d => d.CellType == CellType.Blank))
                            {
                                continue;
                            }
                            for (int j = row.FirstCellNum; j < cellCount; j++)
                            {
                                if (row.GetCell(j) != null)
                                {
                                    if (j == 0)
                                    {
                                        item.FoodmenuId = Convert.ToInt32(row.GetCell(j).ToString());
                                        sb.Append("<td class=\"text-right\">" + row.GetCell(j).ToString() + "</td>");
                                    }
                                    else if (j == 3)
                                    {
                                        item.PhysicalStockQty = Convert.ToDecimal(row.GetCell(j).ToString());
                                        sb.Append("<td  class=\"text-right\">" + row.GetCell(j).ToString() + "</td>");
                                    }
                                    else
                                    {
                                        sb.Append("<td>" + row.GetCell(j).ToString() + "</td>");
                                    }
                                }
                            }
                            sb.AppendLine("</tr>");
                            ItemList.Add(new InventoryOpenigStockImport {
                                ItemType = itemType, ImportBatch = BatchId, StoreId = storeId, FoodmenuId = item.FoodmenuId, PhysicalStockQty = item.PhysicalStockQty
                            });
                        }
                        sb.Append("</table>");
                        _inventoryOpenigStockImports = ItemList;
                        int Result = _iInventoryService.BulkImport(_inventoryOpenigStockImports);
                    }
                }
            }
            catch (Exception ex)
            {
                SystemLogs.Register(ex.Message);
            }
            return(this.Content(sb.ToString()));
        }