Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 42 additions & 22 deletions Inventory_management/Controllers/LoginController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ public class LoginController : Controller
[HttpGet]
public ActionResult Login()
{


login userModel = new login();
userModel.status_ = "";
return View();
}

Expand All @@ -25,43 +29,59 @@ public ActionResult Verify(Inventory_management.Models.login userModel)

using (inventorymgtEntities dbModel = new inventorymgtEntities())
{
var pass = userModel.password_;
var userDetails = dbModel.users.Where(x => x.email == userModel.username).FirstOrDefault();
if (userDetails == null)
var pass = userModel.password_ != null ? userModel.password_.ToString() : "";
var usrname = userModel.username != null ? userModel.username.ToString(): "";
if (pass != null && usrname != null)
{
userModel.status_ = "Invalid User Credentials.";

return View("Login", userModel);

var userDetails = dbModel.users.Where(x => x.email == usrname && x.password_ == pass).FirstOrDefault();

if (userDetails != null && userDetails.email != null && userDetails.password_ != null && userDetails.email.Equals("akaamzain@hotmail.com") && userDetails.password_.Equals("1202"))
{
Session["userID"] = userDetails.regId;
Session["user"] = userDetails.fname;
Session["occupation"] = userDetails.ocp;

return RedirectToAction("Index", "Search");
}
else if (userDetails == null)
{
userModel.status_ = "Invalid User Credentials.";

return View("Login", userModel);
}
else
{
Session["userID"] = userDetails.regId;
Session["user"] = userDetails.fname;
Session["occupation"] = userDetails.ocp;
return View("Welcome");
}
}

else
if (userDetails.email.Equals("akaamzain@hotmail.com") && userDetails.password_.Equals("1202"))
{
userModel.status_ = "Invalid User Credentials.";

return View("~/Views/Search/Index.cshtml");
}

else
{
Session["userID"] = userDetails.regId;
Session["user"] = userDetails.fname;
return View("Welcome");
return View("Login", userModel);
}

}


}

public ActionResult LogOut()
public ActionResult Welcome()
{
return View("Welcome");
}

int userId = (int)Session["userID"];
Session.Abandon();
public ActionResult LogOut()
{
if (Session["userID"] != null)
{
int userId = (int)Session["userID"];
Session.Abandon();
}
return View("Login");


}


Expand Down
25 changes: 1 addition & 24 deletions Inventory_management/Controllers/ScheduleController.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using CrystalDecisions.CrystalReports.Engine;
using Inventory_management.Models;
using Inventory_management.Models;
using Inventory_management.Models;
using System;
using System.Collections.Generic;
Expand All @@ -17,8 +16,6 @@ namespace Inventory_management.Controllers
public class ScheduleController : Controller
{

//new Comment added

//DBMod dbs = new DBMod();
//public ActionResult New()
//{
Expand Down Expand Up @@ -198,26 +195,6 @@ public ActionResult Delete(int id, FormCollection collection)
}
}

public ActionResult ExportScheduleListing()
{
using (inventorymgtEntities mv = new inventorymgtEntities())
{
ReportDocument rd = new ReportDocument();
rd.Load(Path.Combine(Server.MapPath("~/Report/Schedule/ScheduleReport.rpt")));
rd.SetDataSource(mv.schedules.ToList());

Response.Buffer = false;
Response.ClearContent();
Response.ClearHeaders();

Stream str = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
str.Seek(0, SeekOrigin.Begin);

string savedFileName = string.Format("ScheduleReport_{0}", DateTime.Now);
return File(str, "applicationReport/pdf", savedFileName);
}
}



}
Expand Down
56 changes: 53 additions & 3 deletions Inventory_management/Controllers/SearchController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
using System;
using CrystalDecisions.CrystalReports.Engine;
using System.IO;


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
Expand All @@ -12,10 +16,18 @@ public class SearchController : Controller

public ActionResult Index()
{
return View();
inventorymgtEntities dbModel = new inventorymgtEntities();
return View(dbModel.users.OrderBy(model => model.fname).ToList());
}


//public ActionResult Index_Copy()
//{
// inventorymgtEntities dbModel = new inventorymgtEntities();
// return View(dbModel.users.OrderBy(model => model.fname).ToList());
//}



public ActionResult getUsers()
{
using(inventorymgtEntities dbModel = new inventorymgtEntities())
Expand Down Expand Up @@ -72,5 +84,43 @@ public ActionResult getUsers()

}

public ActionResult Report()
{
inventorymgtEntities db = new inventorymgtEntities();
ReportDocument rd = new ReportDocument();
rd.Load(Path.Combine(Server.MapPath("~/Report/Profile/ProfileReport.rpt")));

rd.SetDataSource(db.users.Select(p => new
{
regId = p.regId,
fname = p.fname != null ? p.fname : "",
lname = p.lname != null ? p.lname : "",
email = p.email != null ? p.email : "",
age = p.age != null ? p.age : 0,
ocp = p.ocp != null ? p.ocp : "",
weight_ = p.weight_ != null ? p.weight_ : 0,
height = p.height != null ? p.height : 0,
phone = p.phone != null ? p.phone : "",
address = p.address != null ? p.address : "",
shedule = p.shedule != null ? p.shedule : "",
d_plan = p.d_plan != null ? p.d_plan : "",
pay_type = p.pay_type != null ? p.pay_type : "",
gender = p.gender != null ? p.gender : ""


}).ToList()); ;

Response.Buffer = false;
Response.ClearContent();
Response.ClearHeaders();

Stream str = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
str.Seek(0, SeekOrigin.Begin);

string savedFileName = string.Format("OrderReport_{0}", DateTime.Now);
return File(str, "application/pdf", savedFileName+".pdf");
}


}
}
16 changes: 16 additions & 0 deletions Inventory_management/Controllers/UserController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public ActionResult addOrEdit(user userModel)

using (inventorymgtEntities dbModel = new inventorymgtEntities())
{

if (dbModel.users.Any(x => x.email == userModel.email)) {

ViewBag.DuplicateMsg = "Your Email is already exist.";
Expand All @@ -44,6 +45,21 @@ public ActionResult addOrEdit(user userModel)
dbModel.users.Add(userModel);
dbModel.SaveChanges();

attendance atnModel = new attendance();


var initialUser = dbModel.users.Where(x => x.email == userModel.email).FirstOrDefault();



atnModel.user_ = initialUser.regId;
atnModel.no_of_days = 0;
atnModel.status_ = "false";
atnModel.date_ = DateTime.Now.Date.ToString();
//atnModel.date_ = DateTime.Now.ToString("MM-dd-yyyy");

dbModel.attendances.Add(atnModel);
dbModel.SaveChanges();
}

ViewBag.SuccessMessage = "Registration Successful.";
Expand Down
87 changes: 74 additions & 13 deletions Inventory_management/Controllers/proifleController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ public ActionResult Edit(user user)
var atndDetails = dbModel.attendances.Where(x => x.user_ == id).FirstOrDefault();

//if (DateTime.Now.Date > atndDetails.date_)



DateTime dt = DateTime.Parse(atndDetails.date_);
if (DateTime.Now.Date.CompareTo(dt)>0) {
Expand All @@ -143,11 +145,29 @@ public ActionResult Edit(user user)
}

int cdays = (int)atndDetails.no_of_days;
int sPlan = 0;
if(userDetails != null && userDetails.shedule != null)
{
if(userDetails.shedule.ToString() == "D30")
{
sPlan = 30;
}else if (userDetails.shedule.ToString() == "D40")
{
sPlan = 40;
}else if (userDetails.shedule.ToString() == "D45")
{
sPlan = 45;
}
else
{
sPlan = 50;
}
}

Session["username"] = userDetails.fname+" "+userDetails.lname;
Session["userId"] = userDetails.regId;
Session["progress"] = (100 / 45) * cdays;
Session["rDays"] = 45 - cdays;
Session["progress"] = ((double)cdays / (double)sPlan )* 100 /*/(100 / 45) * cdays*/;
Session["rDays"] = sPlan - cdays;

return View(dbModel.attendances.Where(x => x.user_ == id).FirstOrDefault());
}
Expand All @@ -160,33 +180,74 @@ public ActionResult Attendance(attendance atd)
{
try
{
int rdays = 45, cdays=0;

int rdays = 0, cdays=0;
int userId= (int)Session["userId"];
atd.user_ = userId;

using ( inventorymgtEntities dbModel = new inventorymgtEntities())
{
var userDetails = dbModel.users.Where(x => x.regId == userId).FirstOrDefault();
if (userDetails != null && userDetails.shedule != null)
{
if (userDetails.shedule.ToString() == "D30")
{
rdays = 30;
}
else if (userDetails.shedule.ToString() == "D40")
{
rdays = 40;
}
else if (userDetails.shedule.ToString() == "D45")
{
rdays = 45;
}
else
{
rdays = 50;
}
}



cdays = (int)atd.no_of_days + 1;
if (cdays <= 45)
if (cdays <= rdays)
{
atd.status_ = "true";
atd.date_ = DateTime.Now.Date.ToString();
atd.no_of_days = cdays;
}else
} else if (cdays > rdays) {
atd.no_of_days = 1;
cdays = rdays - 1;


} else
{
atd.no_of_days = 1;
cdays = 1;
}
atd.user_ = (int)Session["userId"];
dbModel.Entry(atd).State = EntityState.Modified;
dbModel.SaveChanges();

rdays = rdays - cdays;
var atdDetails = dbModel.attendances.Where(x => x.user_ == userId).FirstOrDefault();

if (DateTime.Now.Date.CompareTo(DateTime.Parse(atdDetails.date_)) > 0)
{

atdDetails.no_of_days = atd.no_of_days;
atdDetails.date_ = atd.date_;
dbModel.Entry(atdDetails).State = EntityState.Modified;
dbModel.SaveChanges();
rdays = rdays - cdays;

Session["progress"] = (100 / 45) * cdays;
Session["rDays"] = rdays;
}


}

Session["progress"] = (100/45)*cdays;
Session["rDays"] = rdays;


return View(atd);
return RedirectToAction("Attendance", "proifle", new {id = userId });
//return View(atd);
}
catch(Exception e)
{
Expand Down
Loading