示例#1
0
        public async Task <IHttpActionResult> DeletetblBank(int id)
        {
            tblBank tblBank = await db.tblBanks.FindAsync(id);

            if (tblBank == null)
            {
                return(NotFound());
            }

            db.tblBanks.Remove(tblBank);
            await db.SaveChangesAsync();

            return(Ok(tblBank));
        }
示例#2
0
        // GET: /Users/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tblBank tblBank = db.tblBank.Find(id);

            ViewBag.RoleID   = new SelectList(db.tblRoles, "RoleID", "RoleName", tblBank.BankID);
            ViewBag.SchoolID = new SelectList(db.tblSchool, "SchoolID", "SchoolName", tblBank.SchoolID);
            if (tblBank == null)
            {
                return(HttpNotFound());
            }
            return(View(tblBank));
        }
示例#3
0
        public async Task <IHttpActionResult> PosttblBank(tblBank tblBank)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (CheckBankUniqueness(tblBank.Name))
            {
                return(Conflict());
            }

            db.tblBanks.Add(tblBank);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = tblBank.BankId }, tblBank));
        }
示例#4
0
 public ActionResult DeleteBanks(int id)
 {
     if (ClsCheckRole.CheckQuyen(11, 3, int.Parse(Request.Cookies["Username"].Values["UserID"])) == true)
     {
         tblBank tblbank = db.tblBanks.Find(id);
         var     result  = string.Empty;
         db.tblBanks.Remove(tblbank);
         db.SaveChanges();
         result = "Bạn đã xóa thành công.";
         return(Json(new { result = result }));
     }
     else
     {
         var result = string.Empty;
         result = "Bạn không có quyền thay đổi tính năng này";
         return(Json(new { result = result }));
     }
 }
示例#5
0
 public ActionResult Edit(int id = 0)
 {
     if ((Request.Cookies["Username"] == null))
     {
         return(RedirectToAction("LoginIndex", "Login"));
     }
     if (ClsCheckRole.CheckQuyen(11, 2, int.Parse(Request.Cookies["Username"].Values["UserID"])) == true)
     {
         tblBank tblbank = db.tblBanks.Find(id);
         if (tblbank == null)
         {
             return(HttpNotFound());
         }
         return(View(tblbank));
     }
     else
     {
         return(Redirect("/Users/Erro"));
     }
 }
示例#6
0
        public ActionResult Create(tblBank tblbank, FormCollection collection)
        {
            db.tblBanks.Add(tblbank);
            db.SaveChanges();
            #region [Updatehistory]
            Updatehistoty.UpdateHistory("Add Bank", Request.Cookies["Username"].Values["FullName"].ToString(), Request.Cookies["Username"].Values["UserID"].ToString());
            #endregion
            if (collection["btnSave"] != null)
            {
                Session["Thongbao"] = "<div  class=\"alert alert-info alert1\">Bạn đã thêm thành công !<button class=\"close\" data-dismiss=\"alert\">×</button></div>";

                return(Redirect("/Banks/Index"));
            }
            if (collection["btnSaveCreate"] != null)
            {
                Session["Thongbao"] = "<div  class=\"alert alert-info\">Bạn đã thêm thành công, mời bạn thêm danh mục  mới !<button class=\"close\" data-dismiss=\"alert\">×</button></div>";
                return(Redirect("/Banks/Create"));
            }
            return(Redirect("Index"));
        }
示例#7
0
        public ActionResult Edit(tblBank tblbank, int id, FormCollection collection)
        {
            if (ModelState.IsValid)
            {
                db.Entry(tblbank).State = EntityState.Modified;

                db.SaveChanges();
                #region [Updatehistory]
                Updatehistoty.UpdateHistory("Edit tblbank", Request.Cookies["Username"].Values["FullName"].ToString(), Request.Cookies["Username"].Values["UserID"].ToString());
                #endregion
                if (collection["btnSave"] != null)
                {
                    Session["Thongbao"] = "<div  class=\"alert alert-info alert1\">Bạn đã sửa  thành công !<button class=\"close\" data-dismiss=\"alert\">×</button></div>";

                    return(Redirect("/Banks/Index"));
                }
                if (collection["btnSaveCreate"] != null)
                {
                    Session["Thongbao"] = "<div  class=\"alert alert-info\">Bạn đã thêm thành công, mời bạn thêm mới !<button class=\"close\" data-dismiss=\"alert\">×</button></div>";
                    return(Redirect("/Banks/Create"));
                }
            }
            return(View(tblbank));
        }
示例#8
0
        public async Task <IHttpActionResult> PuttblBank(int id, tblBank tblBank)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != tblBank.BankId)
            {
                return(BadRequest());
            }
            if (CheckBankUniqueness(tblBank.Name, id))
            {
                return(Conflict());
            }

            db.Entry(tblBank).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!tblBankExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
示例#9
0
        public ActionResult Index(int?page, string id, FormCollection collection)
        {
            if ((Request.Cookies["Username"] == null))
            {
                return(RedirectToAction("LoginIndex", "Login"));
            }
            if (ClsCheckRole.CheckQuyen(11, 0, int.Parse(Request.Cookies["Username"].Values["UserID"])) == true)
            {
                var ListBank = db.tblBanks.ToList();

                const int pageSize   = 20;
                var       pageNumber = (page ?? 1);
                // Thiết lập phân trang
                var ship = new PagedListRenderOptions
                {
                    DisplayLinkToFirstPage                      = PagedListDisplayMode.Always,
                    DisplayLinkToLastPage                       = PagedListDisplayMode.Always,
                    DisplayLinkToPreviousPage                   = PagedListDisplayMode.Always,
                    DisplayLinkToNextPage                       = PagedListDisplayMode.Always,
                    DisplayLinkToIndividualPages                = true,
                    DisplayPageCountAndCurrentLocation          = false,
                    MaximumPageNumbersToDisplay                 = 5,
                    DisplayEllipsesWhenNotShowingAllPageNumbers = true,
                    EllipsesFormat                     = "&#8230;",
                    LinkToFirstPageFormat              = "Trang đầu",
                    LinkToPreviousPageFormat           = "«",
                    LinkToIndividualPageFormat         = "{0}",
                    LinkToNextPageFormat               = "»",
                    LinkToLastPageFormat               = "Trang cuối",
                    PageCountAndCurrentLocationFormat  = "Page {0} of {1}.",
                    ItemSliceAndTotalFormat            = "Showing items {0} through {1} of {2}.",
                    FunctionToDisplayEachPageNumber    = null,
                    ClassToApplyToFirstListItemInPager = null,
                    ClassToApplyToLastListItemInPager  = null,
                    ContainerDivClasses                = new[] { "pagination-container" },
                    UlElementClasses                   = new[] { "pagination" },
                    LiElementClasses                   = Enumerable.Empty <string>()
                };
                ViewBag.ship = ship;
                if (Session["Thongbao"] != null && Session["Thongbao"] != "")
                {
                    ViewBag.thongbao    = Session["Thongbao"].ToString();
                    Session["Thongbao"] = "";
                }
                if (collection["btnDelete"] != null)
                {
                    foreach (string key in Request.Form.Keys)
                    {
                        var checkbox = "";
                        if (key.StartsWith("chk_"))
                        {
                            checkbox = Request.Form["" + key];
                            if (checkbox != "false")
                            {
                                if (ClsCheckRole.CheckQuyen(11, 3, int.Parse(Request.Cookies["Username"].Values["UserID"])) == true)
                                {
                                    int     ids     = Convert.ToInt32(key.Remove(0, 4));
                                    tblBank tblbank = db.tblBanks.Find(ids);
                                    db.tblBanks.Remove(tblbank);
                                    db.SaveChanges();
                                    return(RedirectToAction("Index"));
                                }
                                else
                                {
                                    return(Redirect("/Users/Erro"));
                                }
                            }
                        }
                    }
                }
                return(View(ListBank.ToPagedList(pageNumber, pageSize)));
            }
            else
            {
                return(Redirect("/Users/Erro"));
            }
        }
        public IHttpActionResult WayTwo()
        {
            string imageName  = "";
            string imageName1 = "";

            string Qty         = "";
            var    httpRequest = HttpContext.Current.Request;
            //Upload Image
            var postedFile  = httpRequest.Files["Image"];
            var postedFile1 = httpRequest.Files["Image1"];

            //Create custom filename
            imageName = new String(Path.GetFileNameWithoutExtension(postedFile.FileName).Take(10).ToArray()).Replace(" ", "-");
            imageName = imageName + DateTime.Now.ToString("yymmssfff") + Path.GetExtension(postedFile.FileName);
            var filePath = HttpContext.Current.Server.MapPath("~/Image/" + imageName);

            postedFile.SaveAs(filePath);

            imageName1 = new String(Path.GetFileNameWithoutExtension(postedFile1.FileName).Take(10).ToArray()).Replace(" ", "-");
            imageName1 = imageName1 + DateTime.Now.ToString("yymmssfff") + Path.GetExtension(postedFile1.FileName);
            var filePath1 = HttpContext.Current.Server.MapPath("~/Image/" + imageName1);

            //var filePath1 = HttpContext.Current.Server.MapPath("D:/Project_Angular/AgriFarmProj/src/assets/uploadeddocs/" + imageName1);
            postedFile1.SaveAs(filePath1);


            tblFarmer fmr = new tblFarmer();

            //Save to DB
            using (dbProjectEntities db = new dbProjectEntities())
            {
                #region saving data into db
                List <tblFarmer> farmers = db.tblFarmers.ToList();
                List <tblBank>   banks   = db.tblBanks.ToList();

                foreach (tblFarmer tblFarmer1 in farmers)
                {
                    if (tblFarmer1.FarmerEmail == httpRequest["FarmerEmail"])
                    {
                        return(Ok("Email"));
                    }
                }

                foreach (tblBank tblBank1 in banks)
                {
                    if (tblBank1.AccountNo == httpRequest["AccountNo"])
                    {
                        return(Ok("Account"));
                    }
                }
                try
                {
                    fmr.FarmerAadhar      = imageName;
                    fmr.FarmerCertificate = imageName1;

                    fmr.FarmerName      = httpRequest["FarmerName"];
                    fmr.FarmerContactNo = httpRequest["FarmerContactNo"];
                    fmr.FarmerAddress   = httpRequest["FarmerAddress"];
                    fmr.FarmerCity      = httpRequest["FarmerCity"];
                    fmr.FarmerState     = httpRequest["FarmerState"];
                    fmr.FarmerPincocde  = httpRequest["FarmerPincocde"];
                    fmr.FarmerEmail     = httpRequest["FarmerEmail"];
                    fmr.FarmerPassword  = httpRequest["FarmerPassword"];
                    fmr.FarmerApproved  = false;
                    byte[] encData_byte = new byte[fmr.FarmerPassword.Length];
                    encData_byte = System.Text.Encoding.UTF8.GetBytes(fmr.FarmerPassword);
                    string encodedpassword = Convert.ToBase64String(encData_byte);
                    fmr.FarmerPassword = encodedpassword;
                    db.tblFarmers.Add(fmr);
                    db.SaveChanges();


                    // db.SaveChanges();

                    /*
                     *          }*/
                    List <tblFarmer> res = db.tblFarmers.ToList();

                    foreach (tblFarmer item in res)
                    {
                        if (item.FarmerEmail == fmr.FarmerEmail)
                        {
                            fid = item.FarmerId;
                            break;
                        }
                    }

                    tblBank tb1 = new tblBank();

                    using (dbProjectEntities db1 = new dbProjectEntities())
                    {
                        tb1.FarmerId  = fid;
                        tb1.AccountNo = httpRequest["AccountNo"];
                        tb1.IFSC_Code = httpRequest["IFSC_Code"];
                        tb1.BidderId  = null;

                        db1.tblBanks.Add(tb1);
                        db1.SaveChanges();

                        // db.SaveChanges();
                    }

                    tblFarmLand tb2 = new tblFarmLand();

                    using (dbProjectEntities db1 = new dbProjectEntities())
                    {
                        tb2.FarmerId = fid;

                        tb2.FarmerLandArea    = httpRequest["FarmerLandArea"];
                        tb2.FarmerLandAddress = httpRequest["FarmerLandAddress"];
                        tb2.FarmerLandPincode = httpRequest["FarmerLandPincode"];
                        db1.tblFarmLands.Add(tb2);
                        db1.SaveChanges();
                    }
                    #endregion
                }
                catch (Exception)
                {
                    return(Ok("Error"));
                }
            }
            return(Ok("OK"));
        }
        public IHttpActionResult WayTwo()
        {
            string imageName  = "";
            string imageName1 = "";

            string Qty         = "";
            var    httpRequest = HttpContext.Current.Request;
            //Upload Image
            var postedFile  = httpRequest.Files["Image"];
            var postedFile1 = httpRequest.Files["Image1"];

            //Create custom filename
            imageName = new String(Path.GetFileNameWithoutExtension(postedFile.FileName).Take(10).ToArray()).Replace(" ", "-");
            imageName = imageName + DateTime.Now.ToString("yymmssfff") + Path.GetExtension(postedFile.FileName);
            var filePath = HttpContext.Current.Server.MapPath("~/Image/" + imageName);

            postedFile.SaveAs(filePath);

            imageName1 = new String(Path.GetFileNameWithoutExtension(postedFile1.FileName).Take(10).ToArray()).Replace(" ", "-");
            imageName1 = imageName1 + DateTime.Now.ToString("yymmssfff") + Path.GetExtension(postedFile1.FileName);
            var filePath1 = HttpContext.Current.Server.MapPath("~/Image/" + imageName1);

            postedFile1.SaveAs(filePath1);


            tblBidder br = new tblBidder();

            //Save to DB
            using (dbProjectEntities1 db = new dbProjectEntities1())
            {
                List <tblBidder> bidders = db.tblBidders.ToList();
                List <tblBank>   banks   = db.tblBanks.ToList();

                foreach (tblBidder tblBidder1 in bidders)
                {
                    if (tblBidder1.BidderEmail == httpRequest["BidderEmail"])
                    {
                        return(Ok("Email"));
                    }
                }

                foreach (tblBank tblBank1 in banks)
                {
                    if (tblBank1.AccountNo == httpRequest["AccountNo"])
                    {
                        return(Ok("Account"));
                    }
                }

                try
                {
                    #region saving details into db
                    br.BidderAadhar       = imageName;
                    br.BidderTradeLicense = imageName1;

                    br.BidderName      = httpRequest["BidderName"];
                    br.BidderEmail     = httpRequest["BidderEmail"];
                    br.BidderContactNo = httpRequest["BidderContactNo"];
                    br.BidderAddress   = httpRequest["BidderAddress"];
                    br.BidderCity      = httpRequest["BidderCity"];
                    br.BidderState     = httpRequest["BidderState"];
                    br.BidderPincocde  = httpRequest["BidderPincocde"];
                    br.BidderPassword  = httpRequest["BidderPassword"];
                    byte[] encData_byte = new byte[br.BidderPassword.Length];
                    encData_byte = System.Text.Encoding.UTF8.GetBytes(br.BidderPassword);
                    string encodedpassword = Convert.ToBase64String(encData_byte);
                    br.BidderPassword = encodedpassword;

                    br.BidderApproved = false;
                    db.tblBidders.Add(br);
                    db.SaveChanges();

                    List <tblBidder> res = db.tblBidders.ToList();
                    foreach (tblBidder item in res)
                    {
                        if (item.BidderEmail == br.BidderEmail)
                        {
                            bid = item.Bidderid;
                            break;
                        }
                    }

                    tblBank tb1 = new tblBank();
                    tb1.Farmerid  = null;
                    tb1.AccountNo = httpRequest["AccountNo"];
                    tb1.IFSC_Code = httpRequest["IFSC_Code"];
                    tb1.Bidderid  = bid;

                    db.tblBanks.Add(tb1);
                    db.SaveChanges();
                    #endregion
                }
                catch
                {
                    return(Ok("Error"));
                }
            }
            return(Ok("OK"));
        }