public ActionResult Detail(int?id)
        {
            DARSHANEntities2 db = new DARSHANEntities2();
            tblProduct       ViewResult_ById = db.tblProducts.Where(x => x.iProductId == id).FirstOrDefault();

            return(View(ViewResult_ById));
        }
Exemple #2
0
        public ActionResult LoginUser()
        {
            DARSHANEntities2 db = new DARSHANEntities2();
            var list            = db.tblProducts.ToList();

            return(View(list));
        }
        public ActionResult Index()
        {
            DARSHANEntities2  db         = new DARSHANEntities2();
            List <tblProduct> ViewResult = db.tblProducts.ToList();

            return(View(ViewResult));
        }
        public void Reports()
        {
            DARSHANEntities2  db         = new DARSHANEntities2();
            List <tblProduct> ViewResult = db.tblProducts.ToList();

            var memoryStream = new MemoryStream();

            using (ExcelPackage EP = new ExcelPackage(memoryStream))
            {
                ExcelWorksheet EWS = EP.Workbook.Worksheets.Add("Report");

                EWS.Cells["A1"].Value = "Product Details";
                EWS.Cells["A2"].Value = "Date:- ";
                EWS.Cells["B2"].Value = string.Format("{0: dd MMMM yyyy}", DateTime.Now);

                EWS.Cells["A6"].Value = "Product Id";
                EWS.Cells["B6"].Value = "Product Name";
                EWS.Cells["C6"].Value = "Product Category";
                EWS.Cells["D6"].Value = "Product price";
                EWS.Cells["E6"].Value = "Product Date";

                int RowBegin = 7;

                foreach (var item in ViewResult)
                {
                    EWS.Cells[string.Format("A{0}", RowBegin)].Value = item.iProductId;
                    EWS.Cells[string.Format("B{0}", RowBegin)].Value = item.vchProductName;
                    EWS.Cells[string.Format("C{0}", RowBegin)].Value = item.vchProductCategory;
                    EWS.Cells[string.Format("D{0}", RowBegin)].Value = item.decproductPrice;
                    EWS.Cells[string.Format("E{0}", RowBegin)].Value = item.dtPurchaseDate;

                    RowBegin++;
                }

                EWS.Cells["A:AZ"].AutoFitColumns();
                Response.Clear();
                Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
                Response.AddHeader("content-disposition", "attachment: filename=" + "ExcelReport.xlsx");
                Response.BinaryWrite(EP.GetAsByteArray());
                Response.End();
            }
        }
Exemple #5
0
        public ActionResult VerifyUser(tblUserLoginDetail UserDetail, string buttonSubmit)
        {
            if (buttonSubmit == null)
            {
                ModelState.Clear();
            }

            if (ModelState.IsValid && buttonSubmit != null)
            {
                using (DARSHANEntities2 db = new DARSHANEntities2())
                {
                    var Details = db.Proc_UserLogin(UserDetail.vchUserName).FirstOrDefault();

                    if (Details != null)
                    {
                        var hash = GenerateHash(Details.vchUserPassword);

                        if (hash == UserDetail.vchUserPassword && Details.vchUserRole == "User")
                        {
                            FormsAuthentication.SetAuthCookie(UserDetail.vchUserName, false);
                            return(RedirectToAction("LoginUser"));
                        }
                        else
                        {
                            ViewBag.Error = "Invalid Credentials, Re-Enter password";
                        }
                    }
                    else
                    {
                        ViewBag.Error = "Invalid Credential, Please give correct Username";
                    }
                }
            }


            return(View());
        }