Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- enter code here
- public List<TblEmpAttendance> EmpAttendances { get; set; } //get all EmpAttendance Detail list
- public TblEmpAttendance SelectedEmpAttendance { get; set; } //display details of selected EmpAttendance Detail
- public string DisplayEmpAttendance { get; set; } //EmpAttendance Detail area
- public partial class TblEmpAttendance
- {
- public int Emp_Attendance_Id { get; set; }
- public string Session { get; set; }
- public int Emp_Type_Id { get; set; }
- public string Emp_Type { get; set; }
- public int Emp_Dept_Id { get; set; }
- public string Emp_Deptartment { get; set; }
- public System.DateTime Date { get; set; }
- public int Emp_Official_Id { get; set; }
- public string Emp_Code { get; set; }
- public string Emp_Name { get; set; }
- public int Status_Id { get; set; }
- public string Status { get; set; }
- [ScriptIgnore]
- public TblDepartment TblDepartment { get; set; }
- [ScriptIgnore]
- public TblEmployeeOfficialDetail TblEmployeeOfficialDetail { get; set; }
- [ScriptIgnore]
- public TblEmployeeType TblEmployeeType { get; set; }
- }
- }
- #**my controller:** #
- public class EmployeeController : Controller
- {
- SMS_dbEntities db = new SMS_dbEntities();
- EmployeeFullDetailModel empattendancemodel = new EmployeeFullDetailModel();
- public ActionResult Attendance()
- {
- EmployeeFullDetailModel model = new EmployeeFullDetailModel();
- model.EmpAttendances = db.TblEmpAttendances.OrderBy(m => m.Emp_Attendance_Id).ToList();
- model.SelectedEmpAttendance = null;
- return View(model);
- }
- [HttpGet]
- public JsonResult GetDepartment(string TypeId = "")
- {
- int TID = 0;
- if (int.TryParse(TypeId, out TID))
- {
- }
- if (Request.IsAjaxRequest())
- {
- var department = db.TblDepartments.Where(m => m.Type_Id.Equals(TID)).OrderBy(m => m.Department_Id).ToList();
- return new JsonResult
- {
- Data = department,
- JsonRequestBehavior = JsonRequestBehavior.AllowGet
- };
- }
- else
- {
- return new JsonResult
- {
- Data = "NOT A VALID REQUEST",
- };
- }
- }
- [HttpGet]
- public JsonResult GetEMPDetails(string DeptId = "")
- {
- int DID = 0;
- if (int.TryParse(DeptId, out DID))
- {
- }
- if (Request.IsAjaxRequest())
- {
- var empdetails = db.TblEmployeeOfficialDetails.Where(m => m.Employee_Department_Id.Equals(DID)).OrderBy(m => m.Employee_Official_Id).ToList();
- return new JsonResult
- {
- Data = empdetails,
- JsonRequestBehavior = JsonRequestBehavior.AllowGet
- };
- }
- else
- {
- return new JsonResult
- {
- Data = "NOT A VALID REQUEST",
- };
- }
- }
- [HttpPost]
- public ActionResult NewEmpAttendanceAction()
- {
- ViewBag.code_IdList = new SelectList(db.TblEmployeeOfficialDetails, "Employee_Code", "Employee_Name");
- ViewBag.Status_IdList = new SelectList(db.TblAttendanceStatus, "Attendance_Status_Id", "Attendance_Status_Long");
- ViewBag.Type_IdList = new SelectList(db.TblEmployeeTypes, "EmployeeType_Id", "EmployeeType_Description");
- ViewBag.Department_IdList = new SelectList(db.TblDepartments, "Department_Id", "Department_Name");
- empattendancemodel.EmpAttendances = db.TblEmpAttendances.OrderBy(m => m.Emp_Attendance_Id).ToList();
- empattendancemodel.SelectedEmpAttendance = null;
- empattendancemodel.DisplayEmpAttendance = "WriteOnly";
- return View("Attendance", empattendancemodel);
- }
- [HttpPost]
- public ActionResult InsertEmpAttendanceAction(TblEmpAttendance empattendanceobj, *List<TblEmpAttendance> attendance*)//returns null always
- {
- //AND WHAT TO DO HERE
- }
- #**My INSERT PARTIAL VIEW IS:** #
- foreach(var item in Model)
- {
- <div>
- <div class="form-group" style="width :50%; float:left; padding-right:10px">
- <label>SESSION</label> <br />
- <input type="text" class="form-control font" id="ses" name="ses" value="2015-2016" readonly>
- </div>
- <div class="form-group" style="width: 50%; float: right; padding-right: 10px">
- <label>DATE</label> <br />
- <input type="text" class="form-control font" id="Date" name="Date" value="@item.Date.ToShortDateString()">
- </div>
- </div>
- <div>
- <div class="form-group" style="width :50%; float:left">
- <label>EMPLOYEE TYPE</label> <br />
- @foreach (var type in ViewBag.Type_IdList)
- {
- <input type="radio" name="type" value="@type.Value" style="font:bold 16px verdana" /> <label>@type.Text</label> <br />
- }
- </div>
- <div class="form-group" style="width :50%; float:right">
- <label>EMPLOYEE DEPARTMENT</label> <br />
- @Html.DropDownList("DDLDepartment", ViewBag.Department_IdList as SelectList,"--SELECT DEPARTMENT--", new { @class = "ddlfont" })
- </div>
- </div>
- <div id="original" hidden>
- @Html.DropDownList("DDLStatus", ViewBag.Status_IdList as SelectList, new {@class = "ddlfont" })
- </div>
- <div class="form-group font" id="attend">
- <table>
- <tr>
- <th>EMPLOYEE CODE</th>
- <th>EMPLOYEE NAME</th>
- <th>ATTENDANCE</th>
- </tr>
- <tr>
- </tr>
- </table>
- </div>
- <div>
- <input type="text" id="Session" name="Session" value="@item.Session">
- <input type="text" id="Emp_Official_Id" name="Emp_Official_Id" value="@item.Emp_Official_Id">
- <input type="text" id="Emp_Type_Id" name="Emp_Type_Id" value="@item.Emp_Type_Id">
- <input type="text" id="Emp_Type" name="Emp_Type" value="@item.Emp_Type">
- <input type="text" id="Emp_Dept_Id" name="Emp_Dept_Id" value="@item.Emp_Dept_Id">
- <input type="text" id="Emp_Deptartment" name="Emp_Deptartment" value="@item.Emp_Deptartment">
- <input type="text" id="Emp_Code" name="Emp_Code" value="@item.Emp_Code">
- <input type="text" id="Emp_Name" name="Emp_Name" value="@item.Emp_Name">
- <input type="text" id="Status_Id" name="Status_Id" value="@item.Status_Id">
- <input type="text" id="Status" name="Status" value="@item.Status">
- </div>
- <div>
- <input type="submit" value="SAVE" class="btnsave"
- formaction="/Employee/InsertEmpAttendanceAction" />
- <input type="submit" value="CANCEL" class="btncancel"
- formaction="/Employee/Attendance" />
- </div>
- **AND MY ATTENDANCE PARTIAL VIEW**
- <div class="box-body">
- <button type="submit" class="btn btn-primary" formaction="/Employee/NewEmpAttendanceAction">ADD NEW ATTENDANCE</button>
- @{
- if (Model.SelectedEmpAttendance != null)
- {
- if (Model.DisplayEmpAttendance == "ReadOnly")
- {
- Html.RenderPartial("Attendance/ShowAttendance", Model.SelectedEmpAttendance);
- }
- if (Model.DisplayEmpAttendance == "ReadWrite")
- {
- Html.RenderPartial("Attendance/EditAttendance", Model.SelectedEmpAttendance);
- }
- }
- if (Model.DisplayEmpAttendance == "WriteOnly")
- {
- Html.RenderPartial("Attendance/InsertAttendance", new List<SchoolManagementSystem.EFModel.TblEmpAttendance> {new SchoolManagementSystem.EFModel.TblEmpAttendance()});
- }
- }
- <div class="box-header">
- <i class="fa fa-envelope"></i>
- <h3 class="box-title">VIEW ATTENDANCE DETAILS</h3>
- <!-- tools box -->
- <div class="pull-right box-tools">
- <button class="btn btn-info btn-sm" data-widget="collapse" id="collapseview"><i class="fa fa-arrow-circle-right"></i></button>
- </div>
- </div>
- <div class="box-body">
- <table border="1" cellpadding="10">
- <tr class="form-group">
- <th>SESSION</th>
- <th>TYPE</th>
- <th>DATE</th>
- <th>EMPLOYEE CODE</th>
- <th>NAME</th>
- <th>STATUS</th>
- <th colspan="2" class="hd">Actions</th>
- </tr>
- @if (Model.EmpAttendances != null)
- {
- foreach (var empattendance in Model.EmpAttendances)
- {
- if (Model.SelectedEmpAttendance != null)
- {
- if (empattendance.Emp_Attendance_Id == Model.SelectedEmpAttendance.Emp_Attendance_Id)
- {
- @:
- <tr></tr>
- }
- else
- {
- @:
- <tr></tr>
- }
- }
- else
- {
- @:
- <tr></tr>
- }
- @:
- <tr>
- <td>@empattendance.Session</td>
- <td>@empattendance.Emp_Type</td>
- <td>@empattendance.Date</td>
- <td>@empattendance.Emp_Code</td>
- <td>@empattendance.Emp_Name</td>
- <td>@empattendance.Status</td>
- <td><input type="submit" id="btnselect" formaction="~/Employee/SelectEmpAttendanceAction/@empattendance.Emp_Attendance_Id" value="SELECT" class="btnselect" /></td>
- <td><input type="submit" id="btndelete" formaction="~/Employee/DeleteEmpAttendanceAction/@empattendance.Emp_Attendance_Id" value="DELETE" class="btndelete" /></td>
- </tr>
- }
- }
- </table>
- </div>
- </div>
- </div>
- </form>
- </section>
- </div><!-- /.content-wrapper -->
- #**MY JQUERY IS:** #
- $(document).ready(function () {
- $("#Session").val($('#ses').val());
- $('#DDLDepartment').attr('disabled', true);
- $("input[type='radio']").change(function () {
- if ($(this).select = true) {
- $('#Emp_Type').val($(this).next('label').text());
- $("#Emp_Type_Id").val($(this).val());
- var typeid = parseInt($(this).val());
- console.log(typeid);
- var ddldept = $('#DDLDepartment');
- ddldept.empty();
- ddldept.append($("<option></option").val("").html("--SELECT DEPARTMENT--"));
- //console.log(ddldept);
- $.ajax({
- url: "@Url.Action("GetDepartment", "Employee")",
- type: "GET",
- data: { TypeId: typeid },
- dataType: "json",
- contentType: "application/json",
- processdata: true,
- success: function (data) {
- $.each(data, function (i, valdept) {
- console.log(valdept);
- //console.log(ddldept);
- ddldept.append(
- $("<option value='" + valdept.Department_Id + "'>" + valdept.Department_Name + "</option>")
- );
- $('#DDLDepartment').attr('disabled', false)
- });
- },
- error: function () {
- },
- });
- }
- else {
- alert("SELECT VALID TYPE")
- $('#DDLDepartment').empty();
- $('#DDLDepartment').attr('disabled', true);
- }
- });
- });
- $(document).ready(function () {
- $("#DDLDepartment").click(function () {
- $("#Emp_Deptartment").val($("#DDLDepartment option:selected").text());
- $("#Emp_Dept_Id").val($("#DDLDepartment option:selected").val());
- $('#attend table tr:not(:first)').remove();
- var deptid = parseInt($('#DDLDepartment').val());
- console.log(deptid);
- if ($('#DDLDepartment').val() != "--SELECT DEPARTMENT--") {
- $.ajax({
- url: "@Url.Action("GetEMPDetails", "Employee")",
- type: "GET",
- data: { DeptId: deptid },
- dataType: "json",
- contentType: "application/json",
- processdata: true,
- success: function (data) {
- var dropdown = $('#DDLStatus').clone();
- $.each(data, function (i, empdetail) {
- console.log(empdetail);
- $('#attend table').append("<tr><td>" + empdetail.Employee_Code + "</td><td>" + empdetail.Employee_Name + "</td><td>" + "<span class='abc'></span>" + "</td></tr>");
- $('.abc').html(dropdown);
- //$("#Emp_Official_Id").val(empdetail.Employee_Official_Id);
- });
- },
- });
- }
- else {
- alert(" PLEASE SELECT VALID DEPARTMENT ")
- }
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement