Ejemplo n.º 1
0
        // GET: Auth/studentdatas/Edit/5
        public ActionResult Edit(int?id)
        {
            Helper help = new Helper();
            string a    = User.IsInRole("Franchisee") ? help.Franchisee() : help.Receptionist();

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tblstudentdata tblstudentdata = db.tblstudentdata.Find(id);

            //if (tblstudentdata.password != null)
            //{
            //    tblstudentdata.password = help.DecryptData(tblstudentdata.password);
            //}
            img            = tblstudentdata.image;
            ViewBag.UserId = new SelectList(db.tblreceptionists.Where(x => x.franchid == a && x.Type == "Teacher"), "Id", "Name", tblstudentdata.UserId);
            ViewBag.Time   = new SelectList(db.Timings.Where(x => x.franchid == a), "Tid", "BatchTime", tblstudentdata.Time);

            if (tblstudentdata == null)
            {
                return(HttpNotFound());
            }
            return(View(tblstudentdata));
        }
Ejemplo n.º 2
0
        public ActionResult TeacherReport([Bind(Include = "UserId,From,To")] tblstudentdata student)
        {
            SQLHelper objsql = new SQLHelper();

            dd = objsql.GetTable("select r.rollno,r.date,s.name,r.CourseId,r.amount from recipt_details r,tblstudentdatas s where r.date between '" + student.From + "' and '" + student.To + "' and r.rollno=s.rollno and s.status='1' and s.userid='" + student.UserId + "'");
            return(View(dd));
        }
        public ActionResult Edit([Bind(Include = "Id,name,dob,fathername,address,phone,fatherphn,language,board,qualification,coaching,institutename,type,refferedby,image,uid,Status,username,password,gender,remarks,email,discount,date")] tblstudentdata tblstudentdata, HttpPostedFileBase file, Helper Help)
        {
            if (ModelState.IsValid)
            {
                tblstudentdata.image = file != null?Help.uploadfile(file) : img;

                #region delete file
                string fullPath = Request.MapPath("~/UploadedFiles/" + img);
                if (img == tblstudentdata.image)
                {
                }
                else
                {
                    if (System.IO.File.Exists(fullPath))
                    {
                        System.IO.File.Delete(fullPath);
                    }
                }
                #endregion
                db.Entry(tblstudentdata).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(tblstudentdata));
        }
Ejemplo n.º 4
0
        public ActionResult DeleteConfirmed(int id)
        {
            if (User.IsInRole("Receptionist"))
            {
                roles = help.Receptionist();
            }
            else
            {
                roles = help.Franchisee();
            }

            tblstudentdata tblstudentdata = db.tblstudentdata.Find(id);
            int            roll           = tblstudentdata.rollno;

            ViewBag.CourseId = new SelectList(db.Courses, "CourseId", "CourseName");
            img = tblstudentdata.image;
            if (tblstudentdata.password != null)
            {
                tblstudentdata.password = help.DecryptData(tblstudentdata.password);
            }
            #region delete file
            string fullPath = Request.MapPath("~/UploadedFiles/" + img);
            if (img == tblstudentdata.image)
            {
            }
            else
            {
                if (System.IO.File.Exists(fullPath))
                {
                    System.IO.File.Delete(fullPath);
                }
            }
            #endregion
            db.tblstudentdata.Remove(tblstudentdata);
            db.SaveChanges();

            Fees_Master feemaster = new Fees_Master();
            feemaster = db.Fees_Master.Where(x => x.RollNo == roll && x.franchid == roles).FirstOrDefault();
            if (feemaster != null)
            {
                db.Fees_Master.Remove(feemaster);
                db.SaveChanges();
            }
            StudentCourse studentcourse = new StudentCourse();
            studentcourse = db.StudentCourses.Where(x => x.RollNo == roll && x.Uid == roles).FirstOrDefault();
            if (studentcourse != null)
            {
                db.StudentCourses.Remove(studentcourse);
                db.SaveChanges();
            }
            Recipt_Details rr = db.Recipt_Details.Where(x => x.RollNo == roll && x.franchid == roles).FirstOrDefault();
            if (rr != null)
            {
                db.Recipt_Details.Remove(rr);
                db.SaveChanges();
            }
            TempData["Success"] = "Deleted Successfully";
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 5
0
        public ActionResult AttendenceReport([Bind(Include = "UserId,From")] tblstudentdata student)
        {
            // MorningAttendence ma=db.MorningAttendeces.Where()
            string date = student.From.ToString("MM/dd/yyyy");
            string id   = student.UserId.ToString();

            return(View(db.MorningAttendeces.Where(x => x.Date == date && x.Role == id)));
        }
Ejemplo n.º 6
0
        // GET: Auth/studentdatas/Create
        public ActionResult Create()
        {
            tblstudentdata student = new tblstudentdata();

            student.date     = System.DateTime.Now;
            ViewBag.CourseId = new SelectList(db.Courses, "CourseId", "CourseName");
            ViewBag.RoomId   = new SelectList(db.tblrooms, "RoomId", "room");

            return(View(student));
        }
Ejemplo n.º 7
0
        public ActionResult Create()
        {
            string         a       = User.IsInRole("Franchisee") ? help.Franchisee() : help.Receptionist();
            tblstudentdata student = new tblstudentdata();

            student.date     = System.DateTime.Now;
            ViewBag.CourseId = new SelectList(db.Courses.Where(x => x.franchid == a), "CourseId", "CourseName");
            ViewBag.UserId   = new SelectList(db.tblreceptionists.Where(x => x.franchid == a && x.Type == "Teacher"), "Id", "Name");
            ViewBag.Time     = new SelectList(db.Timings.Where(x => x.franchid == a), "Tid", "BatchTime");
            return(View(student));
        }
Ejemplo n.º 8
0
        public ActionResult Logs(int roll)
        {
            tblstudentdata ss = db.tblstudentdata.FirstOrDefault(x => x.rollno == roll);

            TempData["roll"]  = roll;
            Session["roll"]   = roll;
            Session["franch"] = ss.uid;
            var recp = db.Recipt_Details.Where(x => x.RollNo == roll && x.franchid == ss.uid).ToList();

            return(View(recp));
        }
Ejemplo n.º 9
0
        public ActionResult Create([Bind(Include = "Id,rollno,name,dob,fathername,address,phone,fatherphn,language,board,qualification,coaching,institutename,type,refferedby,image,uid,Status,username,password,gender,remarks,email,discount,date")] tblstudentdata tblstudentdata, HttpPostedFileBase file, Helper Help, DateTime joining, DateTime enddate, string addmission, int CourseId, int RoomId)
        {
            if (ModelState.IsValid)
            {
                tblstudentdata studentdata = db.tblstudentdata.FirstOrDefault();
                if (studentdata == null)
                {
                    tblstudentdata.rollno = 1;
                }
                else
                {
                    var ab = db.tblstudentdata.Max(x => x.rollno);
                    tblstudentdata.rollno = Convert.ToInt32(ab) + 1;
                }
                tblstudentdata.uid   = User.Identity.Name;
                tblstudentdata.image = Help.uploadfile(file);
                if (tblstudentdata.password != null)
                {
                    tblstudentdata.password = Help.EncryptData(tblstudentdata.password);
                }
                db.tblstudentdata.Add(tblstudentdata);
                db.SaveChanges();

                //Recipt_Details receiptdetail = new Recipt_Details();
                //receiptdetail.RollNo = tblstudentdata.rollno;
                Fees_Master feemaster = new Fees_Master();
                feemaster.RollNo = tblstudentdata.rollno;
                feemaster.Date   = tblstudentdata.date;
                //feemaster.CourseId = CourseId;
                feemaster.AlertDate = System.DateTime.Now.AddDays(2);
                feemaster.discount  = tblstudentdata.discount;
                feemaster.Status    = tblstudentdata.Status;
                feemaster.TotalFees = Convert.ToInt32(addmission);
                db.Fees_Master.Add(feemaster);
                db.SaveChanges();

                StudentCourse studentcourse = new StudentCourse();
                studentcourse.RollNo    = tblstudentdata.rollno;
                studentcourse.RoomId    = RoomId;
                studentcourse.CourseId  = CourseId;
                studentcourse.Admitdate = joining;
                studentcourse.enddate   = enddate;
                studentcourse.Fees      = addmission;
                studentcourse.Uid       = Session["User"].ToString();
                studentcourse.Status    = tblstudentdata.Status;
                db.StudentCourses.Add(studentcourse);
                db.SaveChanges();
                TempData["Success"] = "Saved Successfully";
                return(RedirectToAction("Index"));
            }

            return(View(tblstudentdata));
        }
Ejemplo n.º 10
0
        // GET: Auth/studentdatas/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tblstudentdata tblstudentdata = db.tblstudentdata.Find(id);

            ViewBag.CourseId = new SelectList(db.Courses, "CourseId", "CourseName");
            if (tblstudentdata == null)
            {
                return(HttpNotFound());
            }
            return(View(tblstudentdata));
        }
        // GET: Auth/studentdatas/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tblstudentdata tblstudentdata = db.tblstudentdata.Find(id);

            img = tblstudentdata.image;
            if (tblstudentdata == null)
            {
                return(HttpNotFound());
            }
            return(View(tblstudentdata));
        }
Ejemplo n.º 12
0
        public ActionResult Edit([Bind(Include = "Id,rollno,name,dob,fathername,address,phone,fatherphn,language,board,qualification,coaching,institutename,type,refferedby,image,uid,Status,username,password,gender,remarks,email,discount,date,UserId,Time,Material")] tblstudentdata tblstudentdata, HttpPostedFileBase file, Helper Help)
        {
            if (ModelState.IsValid)
            {
                string a = User.IsInRole("Franchisee") ? help.Franchisee() : help.Receptionist();

                tblstudentdata.image = file != null?Help.uploadfile(file) : img;

                if (tblstudentdata.password != null)
                {
                    tblstudentdata.password = Help.EncryptData(tblstudentdata.password);
                }
                #region delete file
                string fullPath = Request.MapPath("~/UploadedFiles/" + img);
                if (img == tblstudentdata.image)
                {
                }
                else
                {
                    if (System.IO.File.Exists(fullPath))
                    {
                        System.IO.File.Delete(fullPath);
                    }
                }
                ViewBag.TimeId   = new SelectList(db.Timings.Where(x => x.franchid == a), "Tid", "BatchTime");
                ViewBag.CourseId = new SelectList(db.tblreceptionists.Where(x => x.franchid == a && x.Type == "Teacher"), "Id", "Name");
                #endregion
                db.Entry(tblstudentdata).State = EntityState.Modified;
                db.SaveChanges();

                //  objsql.ExecuteNonQuery("update fees_master set status='0' where rollno='" + tblstudentdata.rollno + "' and franchid='" + a + "'");
                // objsql.ExecuteNonQuery("update studentcourses set status='0' where rollno='" + tblstudentdata.rollno + "' and uid='" + a + "'");

                //Fees_Master feemaster = db.Fees_Master.FirstOrDefault(x => x.RollNo == tblstudentdata.rollno && x.franchid==a);
                //feemaster.Status = tblstudentdata.Status;
                //db.Entry(feemaster).State = EntityState.Modified;
                //db.SaveChanges();

                //StudentCourse studentcourse = db.StudentCourses.FirstOrDefault(x => x.RollNo == tblstudentdata.rollno && x.Uid==a);
                //    studentcourse.Status = tblstudentdata.Status;
                //    db.Entry(studentcourse).State = EntityState.Modified;
                //    db.SaveChanges();

                TempData["Success"] = "Updated Successfully";
                return(RedirectToAction("Index"));
            }
            return(View(tblstudentdata));
        }
        public ActionResult SMS(int id, Helper Help)
        {
            tblstudentdata ss      = db.tblstudentdata.FirstOrDefault(x => x.rollno == id);
            Fees_Master    fm      = db.Fees_Master.FirstOrDefault(x => x.RollNo == id);
            tblsms         sms     = db.tblsms.FirstOrDefault();
            float          pending = fm.TotalFees - fm.PaidFees;

            if (ss.phone != null)
            {
                string msg    = "Dear, " + Convert.ToString(ss.name) + ". Reminder That Your Course Fee is still Due Rs." + pending + ". Thanks for Joining Us. visit www.englishtreemoga.com.";
                string result = Help.apicall("http://sms.officialsolutions.in/sendSMS?username="******"&message=" + msg + "&sendername=" + sms.Senderid + "&smstype=TRANS&numbers=" + ss.phone + "&apikey=" + sms.Api + "");

                TempData["Success"] = "SMS Send Successfully";
            }
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 14
0
        public ActionResult Edit([Bind(Include = "Id,rollno,name,dob,fathername,address,phone,fatherphn,language,board,qualification,coaching,institutename,type,refferedby,image,uid,Status,username,password,gender,remarks,email,discount,date")] tblstudentdata tblstudentdata, HttpPostedFileBase file, Helper Help)
        {
            if (ModelState.IsValid)
            {
                tblstudentdata.image = file != null?Help.uploadfile(file) : img;

                if (tblstudentdata.password != null)
                {
                    tblstudentdata.password = Help.EncryptData(tblstudentdata.password);
                }
                #region delete file
                string fullPath = Request.MapPath("~/UploadedFiles/" + img);
                if (img == tblstudentdata.image)
                {
                }
                else
                {
                    if (System.IO.File.Exists(fullPath))
                    {
                        System.IO.File.Delete(fullPath);
                    }
                }
                #endregion
                db.Entry(tblstudentdata).State = EntityState.Modified;
                db.SaveChanges();

                Fees_Master feemaster = db.Fees_Master.FirstOrDefault(x => x.RollNo == tblstudentdata.rollno);
                feemaster.Status          = tblstudentdata.Status;
                db.Entry(feemaster).State = EntityState.Modified;
                db.SaveChanges();

                StudentCourse studentcourse = db.StudentCourses.FirstOrDefault(x => x.RollNo == tblstudentdata.rollno);
                studentcourse.Status          = tblstudentdata.Status;
                db.Entry(studentcourse).State = EntityState.Modified;
                db.SaveChanges();

                TempData["Success"] = "Updated Successfully";
                return(RedirectToAction("Index"));
            }
            return(View(tblstudentdata));
        }
Ejemplo n.º 15
0
        public ActionResult Delete(int?id)
        {
            Helper help = new Helper();

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tblstudentdata tblstudentdata = db.tblstudentdata.Find(id);

            if (tblstudentdata.password != null)
            {
                tblstudentdata.password = help.DecryptData(tblstudentdata.password);
            }
            ViewBag.CourseId = new SelectList(db.Courses, "CourseId", "CourseName");
            if (tblstudentdata == null)
            {
                return(HttpNotFound());
            }
            return(View(tblstudentdata));
        }
Ejemplo n.º 16
0
        // GET: Auth/studentdatas/Edit/5
        public ActionResult Edit(int?id)
        {
            Helper help = new Helper();

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tblstudentdata tblstudentdata = db.tblstudentdata.Find(id);

            if (tblstudentdata.password != null)
            {
                tblstudentdata.password = help.DecryptData(tblstudentdata.password);
            }
            img = tblstudentdata.image;
            if (tblstudentdata == null)
            {
                return(HttpNotFound());
            }
            return(View(tblstudentdata));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            tblstudentdata tblstudentdata = db.tblstudentdata.Find(id);

            ViewBag.CourseId = new SelectList(db.Courses, "CourseId", "CourseName");
            img = tblstudentdata.image;
            #region delete file
            string fullPath = Request.MapPath("~/UploadedFiles/" + img);
            if (img == tblstudentdata.image)
            {
            }
            else
            {
                if (System.IO.File.Exists(fullPath))
                {
                    System.IO.File.Delete(fullPath);
                }
            }
            #endregion
            db.tblstudentdata.Remove(tblstudentdata);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 18
0
        public ActionResult Create([Bind(Include = "Id,rollno,name,dob,fathername,address,phone,fatherphn,language,board,qualification,coaching,institutename,type,refferedby,image,uid,Status,username,password,gender,remarks,email,discount,date,Time,UserId,Material,By")] tblstudentdata tblstudentdata, HttpPostedFileBase file, Helper Help, [Bind(Include = "CourseId,AdmitDate,Fees,enddate,Days,FixedFee,Reason")] StudentCourse scourse, int CourseId)
        {
            using (var transaction = db.Database.BeginTransaction())
            {
                try
                {
                    if (ModelState.IsValid)
                    {
                        if (User.IsInRole("Receptionists"))
                        {
                            DataTable dd2 = objsql.GetTable("select * from tblstudentdatas where name='" + tblstudentdata.name + "' and fathername='" + tblstudentdata.fathername + "' and phone='" + tblstudentdata.phone + "'");
                            if (dd2.Rows.Count > 0)
                            {
                                goto xx;
                            }
                            else
                            {
                                transaction.Rollback();
                                TempData["danger"] = "Student Not Exist";
                                return(View());
                            }
                        }
xx:
                        scourse.CourseId = CourseId;
                        Course        co            = db.Courses.FirstOrDefault(x => x.CourseId == scourse.CourseId);
                        int           alter         = Convert.ToInt32(co.Days);
                        string        a             = help.Permission();
                        StudentCourse studentcourse = new StudentCourse();
                        #region insert student table
                        tblstudentdata studentdata = db.tblstudentdata.FirstOrDefault(x => x.uid == a && x.Status == true);
                        #region Create Rollno
                        if (studentdata == null)
                        {
                            tblstudentdata.rollno = 1;
                        }
                        else
                        {
                            var ab = db.tblstudentdata.Where(x => x.uid == a).Max(x => x.rollno);
                            tblstudentdata.rollno = Convert.ToInt32(ab) + 1;
                        }
                        #endregion
                        tblstudentdata.uid   = help.Permission(); //franchid Detail
                        tblstudentdata.image = Help.uploadfile(file);
                        tblstudentdata.role  = HttpContext.User.Identity.Name;

                        db.tblstudentdata.Add(tblstudentdata);
                        db.SaveChanges();
                        #endregion

                        #region Insert Fee table and studentcourse
                        var token = db.Fees_Master.Where(x => x.franchid == a && x.Status == true).Max(x => x.Token);
                        if (token != null)
                        {
                            if (scourse.FixedFee == 0)
                            {
                                studentcourse.FixedFee = studentcourse.FixedFee;
                            }
                            else
                            {
                                if (scourse.Reason == null)
                                {
                                    TempData["danger"] = "Please Update Reason";
                                    transaction.Rollback();
                                    ViewBag.CourseId = new SelectList(db.Courses.Where(x => x.franchid == a), "CourseId", "CourseName", scourse.CourseId);
                                    ViewBag.UserId   = new SelectList(db.tblreceptionists.Where(x => x.franchid == a && x.Type == "Teacher"), "Id", "Name", studentdata.UserId);
                                    ViewBag.Time     = new SelectList(db.Timings.Where(x => x.franchid == a), "Tid", "BatchTime", studentdata.Time);
                                    return(View(tblstudentdata));
                                }
                                studentcourse.FixedFee = scourse.FixedFee;
                                studentcourse.Reason   = scourse.Reason;
                            }
                            token += 1;
                            Fees_Master feemaster = new Fees_Master();
                            feemaster.RollNo   = tblstudentdata.rollno;
                            feemaster.role     = HttpContext.User.Identity.Name;
                            feemaster.Date     = tblstudentdata.date;
                            feemaster.CourseId = scourse.CourseId;
                            //feemaster.CourseId = CourseId;

                            feemaster.AlertDate = System.DateTime.Now.AddDays(alter);
                            feemaster.discount  = tblstudentdata.discount;
                            feemaster.Status    = tblstudentdata.Status;
                            feemaster.TotalFees = Convert.ToInt32(scourse.Fees);
                            feemaster.franchid  = help.Permission();
                            feemaster.Token     = token;

                            db.Fees_Master.Add(feemaster);
                            db.SaveChanges();


                            studentcourse.RollNo    = tblstudentdata.rollno;
                            studentcourse.CourseId  = scourse.CourseId;
                            studentcourse.Admitdate = studentdata.date;
                            studentcourse.enddate   = Convert.ToDateTime(studentdata.date).AddDays(Convert.ToInt32(co.Days));
                            studentcourse.Fees      = Convert.ToInt32(scourse.Fees).ToString();
                            studentcourse.Uid       = help.Permission();
                            studentcourse.Token     = token;
                            studentcourse.role      = HttpContext.User.Identity.Name;
                            studentcourse.Status    = tblstudentdata.Status;


                            db.StudentCourses.Add(studentcourse);
                            db.SaveChanges();
                        }
                        else
                        {
                            token = 1;
                            if (studentcourse.FixedFee != 0)
                            {
                                studentcourse.FixedFee = studentcourse.FixedFee;
                            }
                            else
                            {
                                if (studentcourse.Reason == null)
                                {
                                    TempData["danger"] = "Please Update Reason";
                                    transaction.Rollback();
                                    ViewBag.CourseId = new SelectList(db.Courses.Where(x => x.franchid == a), "CourseId", "CourseName", scourse.CourseId);
                                    return(View(tblstudentdata));
                                }
                            }
                            Fees_Master feemaster = new Fees_Master();
                            feemaster.RollNo   = tblstudentdata.rollno;
                            feemaster.Date     = tblstudentdata.date;
                            feemaster.CourseId = scourse.CourseId;
                            feemaster.role     = HttpContext.User.Identity.Name;
                            //feemaster.CourseId = CourseId;
                            feemaster.AlertDate = System.DateTime.Now.AddDays(alter);
                            feemaster.discount  = tblstudentdata.discount;
                            feemaster.Status    = tblstudentdata.Status;
                            feemaster.TotalFees = Convert.ToInt32(scourse.Fees);
                            feemaster.franchid  = help.Permission();
                            feemaster.Token     = token;

                            db.Fees_Master.Add(feemaster);
                            db.SaveChanges();


                            studentcourse.RollNo    = tblstudentdata.rollno;
                            studentcourse.CourseId  = scourse.CourseId;
                            studentcourse.Admitdate = studentdata.date;
                            studentcourse.role      = HttpContext.User.Identity.Name;
                            studentcourse.enddate   = Convert.ToDateTime(studentdata.date).AddDays(Convert.ToInt32(co.Days));
                            studentcourse.Fees      = Convert.ToInt32(scourse.Fees).ToString();
                            studentcourse.Uid       = help.Permission();
                            studentcourse.Token     = token;

                            studentcourse.Status = tblstudentdata.Status;
                            db.StudentCourses.Add(studentcourse);
                            db.SaveChanges();
                        }
                        #endregion
                        #region Send Message To Student
                        tbldetail dd = db.tbldetails.FirstOrDefault();
                        //  help.sendsms(studentdata.phone, "Dear " + Convert.ToString(tblstudentdata.name) + ". Welcome to " + dd.name + " . Your Course EndDate is (" + Convert.ToString(studentcourse.enddate) + "). Thanks for Joining Us.");
                        TempData["Success"] = "Saved Successfully";
                        ViewBag.CourseId    = new SelectList(db.Courses.Where(x => x.franchid == help.Permission()), "CourseId", "CourseName", scourse.CourseId);
                        // ViewBag.UserId = new SelectList(db.tblreceptionists.Where(x => x.franchid == help.Permission() && x.Type == "Teacher"), "Id", "Name", studentdata.UserId);
                        //  ViewBag.Time = new SelectList(db.Timings.Where(x => x.franchid == help.Permission()), "Tid", "BatchTime", studentdata.Time);
                        transaction.Commit();
                        return(RedirectToAction("Index"));

                        #endregion
                    }

                    return(View(tblstudentdata));
                }
                catch (Exception e)
                {
                    var mesaage = e.Message;
                    transaction.Rollback();
                    TempData["danger"] = "Error Occur ! " + mesaage;
                    throw;
                }
            }
        }
Ejemplo n.º 19
0
        public ActionResult StudentReport(tblstudentdata stu)
        {
            DataTable d1 = objsql.GetTable("select  * from tblstudentdatas where date>='" + stu.To + "' and date<='" + stu.From + "'");

            return(View(d1));
        }
        public ActionResult Create([Bind(Include = "Type")]  Recipt_Details receiptdetail, int Amount, int Discount, int CourseId, DateTime?Alert, DateTime date, Helper Help)
        {
            using (TransactionScope ts = new TransactionScope())
            {
                try
                {
                    DateTime  today = System.DateTime.Now;
                    DataTable dt    = objsql.GetTable("select * from expenselocks where lockdate='" + today + "'");

                    if (dt.Rows.Count > 0)
                    {
                        TempData["danger"] = "Sorry DayEnd";
                        return(View());
                    }
                    else
                    {
                        string          franchid = help.Permission();
                        tblreceptionist re       = db.tblreceptionists.FirstOrDefault(x => x.rid == franchid);
                        if (re.StartTime != null || re.EndTime != null)
                        {
                            if (help.Checklock() == true)
                            {
                                #region data
                                string a = User.IsInRole("Franchisee") ? help.Franchisee() : help.Receptionist();
                                // TODO: Add insert logic here
                                Fees_Master feesmaster = db.Fees_Master.FirstOrDefault(x => x.RollNo == rollno && x.franchid == a && x.Status == true && x.CourseId == CourseId);
                                int         pending    = (Convert.ToInt32(feesmaster.TotalFees) - Convert.ToInt32(feesmaster.PaidFees));
                                if (feesmaster.PaidFees < feesmaster.TotalFees)
                                {
                                    #region condition greater than
                                    feesmaster.discount        = (Convert.ToInt32(feesmaster.discount) + Convert.ToInt32(Discount));
                                    feesmaster.Date            = date;
                                    feesmaster.AlertDate       = Alert;
                                    feesmaster.PaidFees       += Amount;
                                    feesmaster.Status          = true;
                                    db.Entry(feesmaster).State = EntityState.Modified;
                                    db.SaveChanges();

                                    receiptdetail.RollNo   = rollno;
                                    receiptdetail.ReciptNo = receiptno;
                                    receiptdetail.discount = Discount;
                                    receiptdetail.CourseId = CourseId;
                                    receiptdetail.Date     = date;
                                    receiptdetail.role     = HttpContext.User.Identity.Name;
                                    receiptdetail.Amount   = Amount;
                                    receiptdetail.Active   = true;
                                    receiptdetail.franchid = User.IsInRole("Franchisee") ? Help.Franchisee() : Help.Receptionist();
                                    db.Recipt_Details.Add(receiptdetail);
                                    db.SaveChanges();
                                    TempData["roll"]    = rollno;
                                    ViewData["Receipt"] = recp1;
                                    TempData["Success"] = "Saved Successfully";
                                    tblsms         sms = db.tblsms.FirstOrDefault();
                                    tblstudentdata ss  = db.tblstudentdata.FirstOrDefault(x => x.rollno == rollno);

                                    if (ss.phone != null)
                                    {
                                        if (sms != null)
                                        {
                                            string msg    = "Dear, " + Convert.ToString(ss.name) + ". Thank You for Deposit Rs." + Amount + ". Thanks for Joining Us.";
                                            string result = Help.apicall("http://sms.sms.officialsolutions.in/sendSMS?username="******"&message=" + msg + "&sendername=" + sms.Senderid + "&smstype=TRANS&numbers=" + ss.phone + "&apikey=" + sms.Api + "");
                                        }
                                        TempData["Success"] = "SMS Send Successfully";
                                    }
                                    StudentCourse course  = db.StudentCourses.Where(x => x.RollNo == rollno && x.Status == true).FirstOrDefault();
                                    var           courses = db.Courses.Where(x => x.CourseId == course.CourseId);

                                    ViewBag.CourseId = new SelectList(courses, "CourseId", "CourseName");
                                    ts.Complete();
                                    ts.Dispose();
                                    return(RedirectToAction("invoice", new { id = receiptno }));

                                    #endregion
                                }
                                else
                                {
                                    TempData["danger"] = "Please Check Amount First";
                                    return(View());
                                }
                                #endregion
                            }
                            else
                            {
                                TempData["danger"] = "Sorry DayEnd";
                                return(View());
                            }
                        }
                        else
                        {
                            #region data
                            string a = User.IsInRole("Franchisee") ? help.Franchisee() : help.Receptionist();
                            // TODO: Add insert logic here
                            Fees_Master feesmaster = db.Fees_Master.FirstOrDefault(x => x.RollNo == rollno && x.franchid == a && x.Status == true && x.CourseId == CourseId);
                            int         pending    = (Convert.ToInt32(feesmaster.TotalFees) - Convert.ToInt32(feesmaster.PaidFees));
                            if (feesmaster.PaidFees < feesmaster.TotalFees)
                            {
                                #region condition greater than
                                feesmaster.discount        = (Convert.ToInt32(feesmaster.discount) + Convert.ToInt32(Discount));
                                feesmaster.Date            = date;
                                feesmaster.AlertDate       = Alert;
                                feesmaster.PaidFees       += Amount;
                                feesmaster.Status          = true;
                                db.Entry(feesmaster).State = EntityState.Modified;
                                db.SaveChanges();

                                receiptdetail.RollNo   = rollno;
                                receiptdetail.ReciptNo = receiptno;
                                receiptdetail.discount = Discount;
                                receiptdetail.CourseId = CourseId;
                                receiptdetail.Date     = date;
                                receiptdetail.Amount   = Amount;
                                receiptdetail.Active   = true;
                                receiptdetail.franchid = User.IsInRole("Franchisee") ? Help.Franchisee() : Help.Receptionist();
                                db.Recipt_Details.Add(receiptdetail);
                                db.SaveChanges();
                                TempData["roll"]    = rollno;
                                ViewData["Receipt"] = recp1;
                                TempData["Success"] = "Saved Successfully";
                                tblsms         sms = db.tblsms.FirstOrDefault();
                                tblstudentdata ss  = db.tblstudentdata.FirstOrDefault(x => x.rollno == rollno);

                                if (ss.phone != null)
                                {
                                    if (sms != null)
                                    {
                                        string msg    = "Dear " + Convert.ToString(ss.name) + ". Thank You for Deposit Rs." + Amount + ". Thanks for Joining Us.";
                                        string result = Help.apicall("http://sms.sms.officialsolutions.in/sendSMS?username="******"&message=" + msg + "&sendername=" + sms.Senderid + "&smstype=TRANS&numbers=" + ss.phone + "&apikey=" + sms.Api + "");
                                    }
                                    TempData["Success"] = "SMS Send Successfully";
                                }
                                StudentCourse course  = db.StudentCourses.Where(x => x.RollNo == rollno && x.Status == true).FirstOrDefault();
                                var           courses = db.Courses.Where(x => x.CourseId == course.CourseId);

                                ViewBag.CourseId = new SelectList(courses, "CourseId", "CourseName");
                                ts.Complete();
                                ts.Dispose();
                                return(RedirectToAction("invoice", new { id = receiptno }));

                                #endregion
                            }
                            else
                            {
                                TempData["danger"] = "Please Check Amount First";
                                return(View());
                            }
                            #endregion
                        }
                    }
                }
                catch (Exception a)
                {
                    return(View());
                }
            }
        }