Ejemplo n.º 1
0
        public ActionResult SaveUpdateBill(Com_Bill_DTO billData)
        {
            Com_Bill_DTO item = new Com_Bill_DTO();

            CustomerMst cust;

            if (User.IsInRole("Admin"))
            {
                cust = _db.CustomerMsts.FirstOrDefault(a => a.pk_Custid == billData.CustomerMst.pk_Custid);
            }
            else
            {
                cust = _db.CustomerMsts.FirstOrDefault(a => a.pk_Custid == billData.CustomerMst.pk_Custid && a.Username == User.Identity.Name);
            }

            billData.CustomerMst = cust;

            ProductListForBill productDetail = new ProductListForBill();

            productDetail.username        = User.Identity.Name;
            productDetail.fk_custId       = billData.CustomerMst.pk_Custid;
            productDetail.Fk_ProductId    = billData.Fk_ProductId;
            productDetail.productQuantity = billData.prodQuantity;
            productDetail.price           = billData.price;
            _db.ProductListForBills.Add(productDetail);
            _db.SaveChanges();
            item = GetPageData();
            billData.ProductList = item.ProductList;
            return(View(billData));
        }
Ejemplo n.º 2
0
        public Com_Bill_DTO GetPageData()
        {
            Com_Bill_DTO comBill = new Com_Bill_DTO();

            if (User.IsInRole("Admin"))
            {
                var prodList = from productList in _db.ProductMsts
                               select new ProductDDD_DTO
                {
                    productId   = productList.pk_ProductId,
                    ProductName = productList.ProductName
                };
                comBill.ProductList = prodList.ToList();
            }
            else
            {
                var prodList = from productList in _db.ProductMsts
                               where productList.username == User.Identity.Name
                               select new ProductDDD_DTO
                {
                    productId   = productList.pk_ProductId,
                    ProductName = productList.ProductName
                };
                comBill.ProductList = prodList.ToList();
            }

            return(comBill);
        }
Ejemplo n.º 3
0
        public ActionResult SaveUpdateBill(Com_Bill_DTO billData)
        {
            ProductListForBill productDetail = new ProductListForBill();

            productDetail.username        = User.Identity.Name;
            productDetail.fk_custId       = billData.CustomerMst.pk_Custid;
            productDetail.Fk_ProductId    = billData.Fk_ProductId;
            productDetail.productQuantity = billData.prodQuantity;
            productDetail.price           = billData.price;
            _db.ProductListForBills.Add(productDetail);
            _db.SaveChanges();
            return(View());
        }
Ejemplo n.º 4
0
        public ActionResult SaveUpdateBill(int id)
        {
            Com_Bill_DTO item = new Com_Bill_DTO();
            CustomerMst  cust;

            if (User.IsInRole("Admin"))
            {
                cust = _db.CustomerMsts.FirstOrDefault(a => a.pk_Custid == id);
            }
            else
            {
                cust = _db.CustomerMsts.FirstOrDefault(a => a.pk_Custid == id && a.Username == User.Identity.Name);
            }
            item             = GetPageData();
            item.CustomerMst = cust;
            return(View(item));
        }
Ejemplo n.º 5
0
        public Com_Bill_DTO GetPageData()
        {
            Com_Bill_DTO comBill = new Com_Bill_DTO();

            IEnumerable <ProductListDTO> ProductList;
            var products = Session["PRODUCTMSTS"];

            //var paymentTypesList = new List<PaymentTypes>();
            if (products != null)
            {
                ProductList = (IEnumerable <ProductListDTO>)products;
            }
            else
            {
                ProductList = from a in _db.ProductMsts
                              join b in _db.ProductTypeMsts on a.fk_prodtypeid equals b.pk_prodtypeid
                              select new ProductListDTO
                {
                    pk_ProductId  = a.pk_ProductId,
                    ProductName   = a.ProductName,
                    productTypeId = a.fk_prodtypeid,
                };
                Session["PRODUCTMSTS"] = ProductList;
            }
            var prodList = from productList in ProductList
                           select new ProductDDD_DTO
            {
                productId     = productList.pk_ProductId,
                ProductName   = productList.ProductName,
                ProductTypeId = productList.productTypeId
            };

            comBill.ProductList = prodList.ToList();

            var paymentTypes = _db.PaymentTypes;

            comBill.PaymentTypes = paymentTypes.ToList();


            return(comBill);
        }
Ejemplo n.º 6
0
        public Com_Bill_DTO GetPageData()
        {
            Com_Bill_DTO comBill = new Com_Bill_DTO();
            ProductMst   pmst;

            if (User.IsInRole("Admin"))
            {
                var prodList = from productList in _db.ProductMsts
                               select new ProductDDL_DTO
                {
                    productId   = productList.pk_ProductId,
                    ProductName = productList.ProductName
                };
                comBill.ProductList = prodList.ToList();
            }
            else if (User.IsInRole("General Store"))
            {
                var prodList = from productList in _db.ProductMsts.Where(a => a.username == User.Identity.Name)
                               select new ProductDDL_DTO
                {
                    productId   = productList.pk_ProductId,
                    ProductName = productList.ProductName
                };
                comBill.ProductList = prodList.ToList();
            }
            else
            {
                var prodList = from productList in _db.ProductMsts.Where(a => a.username == User.Identity.Name)
                               select new ProductDDL_DTO
                {
                    productId   = productList.pk_ProductId,
                    ProductName = productList.ProductName
                };
                comBill.ProductList = prodList.ToList();
            }


            return(comBill);
        }