Exemplo n.º 1
0
        public ActionResult GetStockInHand(int id)
        {
            var           settings  = new StockInHandSettingService(_unitOfWork).GetTrailBalanceSetting(User.Identity.Name);
            List <string> UserRoles = (List <string>)System.Web.HttpContext.Current.Session["Roles"];

            if (settings == null)
            {
                return(RedirectToAction("Create", "StockInHandSetting", new { ProductTypeId = id }).Warning("Please create Stock In Hand settings"));
            }

            string FromDate = settings.ToDate.HasValue ? settings.FromDate.Value.ToString("dd/MMM/yyyy") : "";
            string ToDate   = settings.ToDate.HasValue ? settings.ToDate.Value.ToString("dd/MMM/yyyy") : "";

            ViewBag.FilterRemark = "( From Date : " + FromDate + " To Date : " + ToDate + " )";

            Dimension1Types Dimension1Type = new ProductTypeService(_unitOfWork).GetProductTypeDimension1Types(id);
            Dimension2Types Dimension2Type = new ProductTypeService(_unitOfWork).GetProductTypeDimension2Types(id);


            if (Dimension1Type == null)
            {
                ViewBag.Dimension1TypeName = "Dimension1";
            }
            else
            {
                ViewBag.Dimension1TypeName = Dimension1Type.Dimension1TypeName;
            }

            if (Dimension2Type == null)
            {
                ViewBag.Dimension2TypeName = "Dimension2";
            }
            else
            {
                ViewBag.Dimension2TypeName = Dimension2Type.Dimension2TypeName;
            }

            ViewBag.id      = id;
            ViewBag.GroupOn = settings.GroupOn;
            //if(settings.DisplayType==DisplayTypeConstants.Balance)
            return(View("StockInHandIndex"));
            //else
            //    return View("StockInHandSummaryIndex");
        }
Exemplo n.º 2
0
        public ActionResult GetStockLedger(int?ProductId, int?Dim1, int?Dim2, int?Process, string LotNo, int?Godown)     //LedgerAccountId
        {
            var Name     = "";
            var TempName = "";

            ViewBag.ProductId = ProductId;
            Name = (from p in db.Product
                    where p.ProductId == ProductId
                    select p).AsNoTracking().FirstOrDefault().ProductName;

            if (Dim1 != null)
            {
                TempName = "";
                TempName = (from P in db.Dimension1
                            join PT in db.ProductTypes on P.ProductTypeId equals PT.ProductTypeId into tablePT
                            from tabPT in tablePT.DefaultIfEmpty()
                            join DT in db.Dimension1Types on tabPT.Dimension1TypeId equals DT.Dimension1TypeId into tableDT
                            from tabDT in tableDT.DefaultIfEmpty()
                            where P.Dimension1Id == Dim1
                            select ", " + tabDT.Dimension1TypeName + " : " + P.Dimension1Name
                            ).AsNoTracking().FirstOrDefault();

                if (TempName != "")
                {
                    Name = Name + TempName;
                }
            }

            if (Dim2 != null)
            {
                TempName = "";
                TempName = (from P in db.Dimension2
                            join PT in db.ProductTypes on P.ProductTypeId equals PT.ProductTypeId into tablePT
                            from tabPT in tablePT.DefaultIfEmpty()
                            join DT in db.Dimension2Types on tabPT.Dimension1TypeId equals DT.Dimension2TypeId into tableDT
                            from tabDT in tableDT.DefaultIfEmpty()
                            where P.Dimension2Id == Dim2
                            select ", " + tabDT.Dimension2TypeName + " : " + P.Dimension2Name
                            ).AsNoTracking().FirstOrDefault();

                if (TempName != "")
                {
                    Name = Name + TempName;
                }
            }

            if (LotNo != null && LotNo != "")
            {
                Name = Name + ", LotNo : " + LotNo;
            }



            ViewBag.Name    = Name;
            ViewBag.Dim1    = Dim1;
            ViewBag.Dim2    = Dim2;
            ViewBag.Process = Process;
            ViewBag.LotNo   = LotNo;
            ViewBag.Godown  = Godown;


            var settings = new StockInHandSettingService(_unitOfWork).GetTrailBalanceSetting(User.Identity.Name);

            ViewBag.GroupOn = settings.GroupOn;
            string FromDate = settings.ToDate.HasValue ? settings.FromDate.Value.ToString("dd/MMM/yyyy") : "";
            string ToDate   = settings.ToDate.HasValue ? settings.ToDate.Value.ToString("dd/MMM/yyyy") : "";

            ViewBag.FilterRemark = "( From Date : " + FromDate + " To Date : " + ToDate + " )";
            return(View("StockLedgerIndex"));
        }
Exemplo n.º 3
0
        public ActionResult GeneratePrints(string ActionName, int Id = 0)
        {
            string PrintProcedure = "";


            if (!string.IsNullOrEmpty(ActionName))
            {
                var Settings = new StockInHandSettingService(_unitOfWork).GetTrailBalanceSetting(User.Identity.Name);



                string SqlParameterGroupOn;
                string SqlParameterShowBalance;
                string SqlParameterProdType;



                string SqlParameterSiteId   = Settings.SiteIds;
                string DivisionId           = Settings.DivisionIds;
                string SqlParameterFromDate = Settings.FromDate.HasValue ? Settings.FromDate.Value.ToString("dd/MMM/yyyy") : "";
                string SqlParameterToDate   = Settings.ToDate.HasValue ? Settings.ToDate.Value.ToString("dd/MMM/yyyy") : "";


                SqlParameterProdType = Id.ToString();

                if (string.IsNullOrEmpty(Settings.GroupOn))
                {
                    SqlParameterGroupOn = "NULL";
                }
                else
                {
                    SqlParameterGroupOn = Settings.GroupOn.ToString();
                }

                if (string.IsNullOrEmpty(Settings.ShowBalance) || Settings.ShowBalance == StockInHandShowBalanceConstants.All)
                {
                    SqlParameterShowBalance = "NULL";
                }
                else
                {
                    SqlParameterShowBalance = Settings.ShowBalance.ToString();
                }


                if (ActionName == "StockInHand")
                {
                    PrintProcedure = "Web.spStockInHand  @ProductType ='" + SqlParameterProdType.ToString() + "', @Site='" + SqlParameterSiteId.ToString() + "', @FromDate='" + SqlParameterFromDate.ToString() + "', @ToDate='" + SqlParameterToDate.ToString() + "', @GroupOn='" + SqlParameterGroupOn.ToString() + "'";
                }



                try
                {
                    DataTable Dt = new DataTable();

                    List <byte[]>     PdfStream = new List <byte[]>();
                    DirectReportPrint drp       = new DirectReportPrint();
                    byte[]            Pdf;
                    Pdf = drp.DirectPrint(Dt, User.Identity.Name);
                    PdfStream.Add(Pdf);


                    PdfMerger pm = new PdfMerger();

                    byte[] Merge = pm.MergeFiles(PdfStream);

                    if (Merge != null)
                    {
                        return(File(Merge, "application/pdf"));
                    }
                }

                catch (Exception ex)
                {
                    string message = _exception.HandleException(ex);
                    return(Json(new { success = "Error", data = message }, JsonRequestBehavior.AllowGet));
                }


                return(Json(new { success = "Success" }, JsonRequestBehavior.AllowGet));
            }
            return(Json(new { success = "Error", data = "No Records Selected." }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult GetStockInHand(int id, string Routeid)
        {
            ProductTypeSettings ProductTypeSetting = new ProductTypeSettingsService(_unitOfWork).GetProductTypeSettings(id);

            if (ProductTypeSetting != null)
            {
                System.Web.HttpContext.Current.Session["Route"]         = Routeid;
                System.Web.HttpContext.Current.Session["ProductTypeId"] = id;
                var           settings  = new StockInHandSettingService(_unitOfWork).GetTrailBalanceSetting(User.Identity.Name, id, Routeid);
                List <string> UserRoles = (List <string>)System.Web.HttpContext.Current.Session["Roles"];
                //if (settings == null)
                //{
                //    return RedirectToAction("Create", "StockInHandSetting", new { ProductTypeId = id, ControllerName = "StockInHandDisplay" }).Warning("Please create Stock In Hand settings");
                //}

                if (settings == null)
                {
                    settings = new StockInHandSettingService(_unitOfWork).GetTrailBalanceSetting(id, Routeid);
                    if (settings == null)
                    {
                        return(RedirectToAction("Create", "StockInHandSetting", new { ProductTypeId = id, ControllerName = "StockInHandDisplay", Route = Routeid }).Warning("Please create Stock In Hand settings"));
                    }
                }

                string FromDate = settings.ToDate.HasValue ? settings.FromDate.Value.ToString("dd/MMM/yyyy") : "";
                string ToDate   = settings.ToDate.HasValue ? settings.ToDate.Value.ToString("dd/MMM/yyyy") : "";


                Dimension1Types Dimension1Type = new ProductTypeService(_unitOfWork).GetProductTypeDimension1Types(id);
                Dimension2Types Dimension2Type = new ProductTypeService(_unitOfWork).GetProductTypeDimension2Types(id);


                ProductType ProductType = new ProductTypeService(_unitOfWork).Find(id);

                if (ProductTypeSetting.Dimension1Caption == null)
                {
                    ViewBag.Dimension1Caption = "Dimension1";
                }
                else
                {
                    ViewBag.Dimension1Caption = ProductTypeSetting.Dimension1Caption;
                }

                if (ProductTypeSetting.Dimension2Caption == null)
                {
                    ViewBag.Dimension2Caption = "Dimension2";
                }
                else
                {
                    ViewBag.Dimension2Caption = ProductTypeSetting.Dimension2Caption;
                }

                if (ProductTypeSetting.Dimension3Caption == null)
                {
                    ViewBag.Dimension3Caption = "Dimension3";
                }
                else
                {
                    ViewBag.Dimension3Caption = ProductTypeSetting.Dimension3Caption;
                }

                if (ProductTypeSetting.Dimension4Caption == null)
                {
                    ViewBag.Dimension4Caption = "Dimension4";
                }
                else
                {
                    ViewBag.Dimension4Caption = ProductTypeSetting.Dimension4Caption;
                }

                if (ProductTypeSetting.ProductNameCaption == null)
                {
                    ViewBag.ProductNameCaption = "Product";
                }
                else
                {
                    ViewBag.ProductNameCaption = ProductTypeSetting.ProductNameCaption;
                }

                ViewBag.FilterRemark   = "( From Date : " + FromDate + " To Date : " + ToDate + " Product Type : " + ProductType.ProductTypeName + " )";
                ViewBag.id             = id;
                ViewBag.ControllerName = "StockInHandDisplay";
                ViewBag.GroupOn        = settings.GroupOn;
                int ShowOpening = (settings.ShowOpening == true ? 1 : 0);
                ViewBag.ShowOpening = ShowOpening;
                if (Routeid == "Stock")
                {
                    ViewBag.TitleName = "Stock In Hand Display";
                }
                else
                {
                    ViewBag.TitleName = "Stock Process Display";
                }
                ViewBag.Routeid = Routeid;
                //if(settings.DisplayType==DisplayTypeConstants.Balance)
                return(View("StockInHandIndex"));
            }
            else
            {
                throw new ApplicationException("Product Type settings Is not Define");
            }

            //else
            //    return View("StockInHandSummaryIndex");
        }