How can Convert Data in to Excel directly in MVC4.Nazmul Badsha9yAsked Sep 13, 2017, 9:35 PM EDT4 answersShareLinkedInXCopy linkSave....... I want to Convert Data in to Excel directly in MVC4 What is the code that conver my data in to excel directly. Actualy is it possible ?? Thanks In Advance. Nazmul
How can Convert Data in to Excel directly in MVC4.Nazmul Badsha9yAsked Sep 13, 2017, 9:35 PM EDT4 answersShareLinkedInXCopy linkSave....... I want to Convert Data in to Excel directly in MVC4 What is the code that conver my data in to excel directly. Actualy is it possible ?? Thanks In Advance. Nazmul
Manas MohapatraRank #182 · 13.2K reputation9y agoPosted Sep 13, 2017, 11:13 PM EDT+1can you explain why it will not work. If you have different scenario describe that.+1
Manas MohapatraRank #182 · 13.2K reputation9y agoPosted Sep 13, 2017, 10:32 PM EDT0Yes, it is possible. Follow below links that may help you: http://www.c-sharpcorner.com/article/export-to-excel-in-asp-net-mvc/http://www.c-sharpcorner.com/UploadFile/9c6206/export-data-from-database-table-to-excel-file-in-Asp-Net-mvc/ http://www.c-sharpcorner.com/UploadFile/rahul4_saxena/export-data-table-to-excel-in-Asp-Net-mvc-4/ http://mvc4beginner.com/Sample-Code/ImportExportExcelData/MVC4-Export-Data-to-Excel.html 0
Nazmul BadshaRank #6,279 · 271 reputation9y agoPosted Sep 13, 2017, 11:02 PM EDT0Those code not work in my project. 0
Nazmul BadshaRank #6,279 · 271 reputation9y agoPosted Sep 14, 2017, 2:01 AM EDT0I want to see employee details only in Excel sheet. my Controller code:using Fluentx.Mvc;using FTSWeb.Models.HouseKeeping;using FTSWeb.Models;using System;using System.Collections.Generic;using System.Data;using System.Linq;using System.Net;using System.Web;using System.Web.Mvc;using System.Collections;using Microsoft.Ajax.Utilities;using FTSWeb;namespace FTSWeb.Controllers{ public class EmployeeController : Controller { #region Actions Employee Employee = new Employee(); public ActionResult Index() { if (Session["DisplayName"] == null) { return RedirectToRoute("Acsol"); } DataSet dsList = new DataSet(); dsList = Employee.prcGetData("", "0"); ViewBag.Desig = dsList.Tables[0]; //ViewBag.Dept = dsList.Tables[1]; return View(); } public ActionResult Load() { if (Session["DisplayName"] == null) { return RedirectToRoute("Acsol"); } DataSet dsList = new DataSet(); dsList = Employee.prcGetData("", "0"); ViewBag.Desig = dsList.Tables[0]; return View(); } [HttpPost] public ActionResult Index(Employee model) { Dictionary postData = new Dictionary(); postData.Add("rptCode", "4"); postData.Add("sqlQuery", "Exec FTSHRIS_AL_AMIN.dbo.rptAttendSumTest '2','15-May-2016','Section'"); postData.Add("rptFormat", "PDF"); //return RedirectAndPostActionResult.RedirectAndPost("http://103.4.67.93/acs.mis/frmGeneratingReport.aspx", postData); //return (frmGeneratingReport , postData); return RedirectAndPostActionResult.RedirectAndPost("frmGeneratingReport.aspx", postData); //return Redirect(Url.Action("frmGeneratingReport.aspx", postData)); return View(); } //add by nazmul //public PartialViewResult SucceesMesg() //{ // return PartialView("Create"); //} public ActionResult Create() { if (Session["DisplayName"] == null) { ////return RedirectToRoute("Acsol"); ; return RedirectToAction("Create"); ; } prcLoadCombo(); return View(); } [HttpPost] [ValidateAntiForgeryToken] public ActionResult Create(Employee model) { try { if (ModelState.IsValid) { System.Threading.Thread.Sleep(700); var values = prcSaveData(model); if (values == "Data save sucessfully") { ModelState.Clear(); //return View(model); //return RedirectToAction("Index"); //model.CardNo = String.Empty; //model.empCode = String.Empty; //model.GS = String.Empty; //model.empName = String.Empty; //model.dtJoin = String.Empty; //model.dtBirth = String.Empty; //prcLoadCombo(); prcLoadCombo(); //Add By Nazmul TempData["message"] = "Added Successfully!"; return RedirectToAction("Create"); //return View("Create"); //prcLoadCombo(); } ModelState.AddModelError("CustomError",values); prcLoadCombo(); return View(model); } prcLoadCombo(); return View(model); } catch (Exception ex) { ModelState.AddModelError("CustomError",ex.Message); return View(model); } } public ActionResult Details(Int32 id) { if (Session["DisplayName"] == null) { return RedirectToRoute("Acsol"); ; } if (id == 0) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } prcLoadCombo(); Employee model = new Employee(); DataSet dsList = new DataSet(); dsList = Employee.prcGetData("",id.ToString()); ViewBag.employee = dsList.Tables[0].Rows[0]; if (model == null) { return HttpNotFound(); } return View(model); } public ActionResult Edit(Int32 id) { if (id == 0) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } prcLoadCombo(); Employee model = new Employee(); model = Employee.prcGetData(id); if (model == null) { return HttpNotFound(); } return View(model); } [HttpPost] [ValidateAntiForgeryToken] public ActionResult Edit(Employee model) { try { if (ModelState.IsValid) { var values = prcUpdateData(model); if (values == "Data updated sucessfully") { return RedirectToAction("Index"); } ModelState.AddModelError("CustomError", values); prcLoadCombo(); return View(model); } prcLoadCombo(); return View(model); } catch (Exception ex) { ModelState.AddModelError("CustomError", ex.Message); return View(model); } } public ActionResult Delete(Int32 id) { if (Session["DisplayName"] == null) { return RedirectToRoute("Acsol"); ; } if (id == 0) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } Employee = Employee.prcGetData(id); DataSet dsList = new DataSet(); dsList = Employee.prcGetData("",id.ToString()); ViewBag.employee = dsList.Tables[0].Rows[0]; if (Employee == null) { return HttpNotFound(); } return View(Employee); } [HttpPost] [ValidateAntiForgeryToken] public ActionResult Delete(Employee model) { prcDeleteData(model); return RedirectToAction("Index"); } #endregion Actions #region procedures public void prcLoadCombo() { DataSet dsList = new DataSet(); clsConnection clsCon = new clsConnection(); try { const string sqlQuery = "Exec prcGetEmployee_WebBased 'Initial' "; clsCon.FTSFillDatasetWithSQLCommand(ref dsList, sqlQuery); dsList.Tables[0].TableName = "Desig"; dsList.Tables[1].TableName = "Dept"; dsList.Tables[2].TableName = "Line"; dsList.Tables[3].TableName = "Floor"; dsList.Tables[4].TableName = "Type"; dsList.Tables[5].TableName = "Religion"; dsList.Tables[6].TableName = "Grade"; dsList.Tables[7].TableName = "Sex"; dsList.Tables[8].TableName = "Shift"; dsList.Tables[9].TableName = "Week"; dsList.Tables[10].TableName = "Blood"; dsList.Tables[11].TableName = "Paymode"; //Designation List Desig = new List(); for (int i = 0; i < dsList.Tables["Desig"].Rows.Count; i++) { clsCommon.clsCombo2 item = new clsCommon.clsCombo2(); item.Id = Int32.Parse(dsList.Tables["Desig"].Rows[i][0].ToString()); item.Name = dsList.Tables["Desig"].Rows[i][1].ToString(); Desig.Add(item); } //Department List Dept = new List(); for (int i = 0; i < dsList.Tables["Dept"].Rows.Count; i++) { clsCommon.clsCombo2 item = new clsCommon.clsCombo2(); item.Id = Int32.Parse(dsList.Tables["Dept"].Rows[i][0].ToString()); item.Name = dsList.Tables["Dept"].Rows[i][1].ToString(); Dept.Add(item); } //Department List Line = new List(); for (int i = 0; i < dsList.Tables["Line"].Rows.Count; i++) { clsCommon.clsCombo2 item = new clsCommon.clsCombo2(); item.Id = Int32.Parse(dsList.Tables["Line"].Rows[i][0].ToString()); item.Name = dsList.Tables["Line"].Rows[i][1].ToString(); Line.Add(item); } //Department List Floor = new List(); for (int i = 0; i < dsList.Tables["Floor"].Rows.Count; i++) { clsCommon.clsCombo2 item = new clsCommon.clsCombo2(); item.Id = Int32.Parse(dsList.Tables["Floor"].Rows[i][0].ToString()); item.Name = dsList.Tables["Floor"].Rows[i][1].ToString(); Floor.Add(item); } //Department List Type = new List(); for (int i = 0; i < dsList.Tables["Type"].Rows.Count; i++) { clsCommon.clsCombo2 item = new clsCommon.clsCombo2(); item.Id = Int32.Parse(dsList.Tables["Type"].Rows[i][0].ToString()); item.Name = dsList.Tables["Type"].Rows[i][1].ToString(); Type.Add(item); } //Department List Religion = new List(); for (int i = 0; i < dsList.Tables["Religion"].Rows.Count; i++) { clsCommon.clsCombo2 item = new clsCommon.clsCombo2(); item.Id = Int32.Parse(dsList.Tables["Religion"].Rows[i][0].ToString()); item.Name = dsList.Tables["Religion"].Rows[i][1].ToString(); Religion.Add(item); } //Department List Grade = new List(); for (int i = 0; i < dsList.Tables["Grade"].Rows.Count; i++) { clsCommon.clsCombo2 item = new clsCommon.clsCombo2(); item.Id = Int32.Parse(dsList.Tables["Grade"].Rows[i][0].ToString()); item.Name = dsList.Tables["Grade"].Rows[i][1].ToString(); Grade.Add(item); } //Department List Sex = new List(); for (int i = 0; i < dsList.Tables["Sex"].Rows.Count; i++) { clsCommon.clsCombo2 item = new clsCommon.clsCombo2(); item.Id = Int32.Parse(dsList.Tables["Sex"].Rows[i][0].ToString()); item.Name = dsList.Tables["Sex"].Rows[i][1].ToString(); Sex.Add(item); } //Department List Shift = new List(); for (int i = 0; i < dsList.Tables["Shift"].Rows.Count; i++) { clsCommon.clsCombo2 item = new clsCommon.clsCombo2(); item.Id = Int32.Parse(dsList.Tables["Shift"].Rows[i][0].ToString()); item.Name = dsList.Tables["Shift"].Rows[i][1].ToString(); Shift.Add(item); } //Department List Week = new List(); for (int i = 0; i < dsList.Tables["Week"].Rows.Count; i++) { clsCommon.clsCombo2 item = new clsCommon.clsCombo2(); item.Id = Int32.Parse(dsList.Tables["Week"].Rows[i][0].ToString()); item.Name = dsList.Tables["Week"].Rows[i][1].ToString(); Week.Add(item); } //Department List Blood = new List(); for (int i = 0; i < dsList.Tables["Blood"].Rows.Count; i++) { clsCommon.clsCombo2 item = new clsCommon.clsCombo2(); item.Id = Int32.Parse(dsList.Tables["Blood"].Rows[i][0].ToString()); item.Name = dsList.Tables["Blood"].Rows[i][1].ToString(); Blood.Add(item); } //Department List Paymode = new List(); for (int i = 0; i < dsList.Tables["Paymode"].Rows.Count; i++) { clsCommon.clsCombo2 item = new clsCommon.clsCombo2(); item.Id = Int32.Parse(dsList.Tables["Paymode"].Rows[i][0].ToString()); item.Name = dsList.Tables["Paymode"].Rows[i][1].ToString(); Paymode.Add(item); } ViewBag.Desig = Desig; ViewBag.Dept = Dept; ViewBag.Line = Line; ViewBag.Floor = Floor; ViewBag.Type = Type; ViewBag.Religion = Religion; ViewBag.Grade = Grade; ViewBag.Sex = Sex; ViewBag.Shift = Shift; ViewBag.Week = Week; ViewBag.Blood = Blood; ViewBag.Paymode = Paymode; } catch (Exception ex) { throw (ex); } finally { clsCon = null; } } public String prcSaveData(Employee model) { ArrayList arQuery = new ArrayList(); clsProcedure clsProc = new clsProcedure(); clsConnection clsCon = new clsConnection(); try { var sqlQuery = "Select Isnull(MAX(empID),0) + 1 As newId From tblEmp_info"; Int64 NewId = clsCon.FTSCountingDataLarge(sqlQuery); int isInactive = 0; if (model.isInactive == true) { isInactive = 1; } int isAllowOT = 0; if (model.IsAllowOT == true) { isAllowOT = 1; } int isAllowPF = 0; if (model.IsAllowPF == true) { isAllowPF = 1; } int IsAllowAttBns = 0; if (model.isAttBonus == true) { IsAllowAttBns = 1; } int isConfirm = 0; if (model.isConfirm == true) { isConfirm = 1; } int IsTranUse = 0; if (model.isTransportUse == true) { IsTranUse = 1; } sqlQuery = "Insert into tblEmp_info(ComId,empID,aEmpID, empCode, empName, Cardno, desigId,SectIdSal,BloodGroupID,PaymodeID,WeekDayID, deptId,Sectid,LineID,dtJoin,dtbirth,FloorID,EmpTypeID,ReligionID,GradeID,GenderID,ShiftID, GS, isInactive,isAllowOT,isAllowPF,IsAllowAttBns,isConfirm,IsTranUse,PCName, LUserId) Values('" + Session["ComId"] + "','" + NewId + "','" + NewId + "','" + clsProc.FTSSingleQuoteAvoid(model.empCode) + "','" + clsProc.FTSSingleQuoteAvoid(model.empName) + "','" + clsProc.FTSSingleQuoteAvoid(model.CardNo) + "','" + clsProc.FTSSingleQuoteAvoid(model.desigId.ToString()) + "','" + clsProc.FTSSingleQuoteAvoid(model.deptId.ToString()) + "','" + clsProc.FTSSingleQuoteAvoid(model.BloodId.ToString()) + "','" + clsProc.FTSSingleQuoteAvoid(model.PayId.ToString()) + "','" + clsProc.FTSSingleQuoteAvoid(model.WeekId.ToString()) + "','" + clsProc.FTSSingleQuoteAvoid(model.deptId.ToString()) + "','" + clsProc.FTSSingleQuoteAvoid(model.deptId.ToString()) + "','" + clsProc.FTSSingleQuoteAvoid(model.LineId.ToString()) + "','" + Convert.ToDateTime(clsProc.FTSSingleQuoteAvoid(model.dtJoin.ToString())) + "','" + Convert.ToDateTime(clsProc.FTSSingleQuoteAvoid(model.dtBirth.ToString())) + "','" + clsProc.FTSSingleQuoteAvoid(model.FloorId.ToString()) + "','" + clsProc.FTSSingleQuoteAvoid(model.TypeId.ToString()) + "','" + clsProc.FTSSingleQuoteAvoid(model.ReligionId.ToString()) + "','" + clsProc.FTSSingleQuoteAvoid(model.GradeId.ToString()) + "','" + clsProc.FTSSingleQuoteAvoid(model.SexId.ToString()) + "','" + clsProc.FTSSingleQuoteAvoid(model.ShiftId.ToString()) + "', '" + clsProc.FTSSingleQuoteAvoid(model.GS.ToString()) + "','"+isInactive+ "','" + isAllowOT + "','" + isAllowPF + "','" + IsAllowAttBns + "','" + isConfirm + "','" + IsTranUse + "',' " + clsProc.FTSGetComputerNameWeb(Request.UserHostAddress) + " ','" + Session["UserId"] + "')"; //" + clsProc.FTSGetComputerNameWeb(Request.UserHostAddress) + " arQuery.Add(sqlQuery); clsCon.FTSSaveDataWithSQLCommand(arQuery); return "Data save sucessfully"; } catch (Exception ex) { return ex.Message.ToString(); } finally { clsCon = null; } } public String prcUpdateData(Employee model) { ArrayList arQuery = new ArrayList(); clsProcedure clsProc = new clsProcedure(); clsConnection clsCon = new clsConnection(); try { int isInactive = 0; if (model.isInactive == true) { isInactive = 1; } int isAllowOT = 0; if (model.IsAllowOT == true) { isAllowOT = 1; } int isAllowPF = 0; if (model.IsAllowPF == true) { isAllowPF = 1; } int IsAllowAttBns = 0; if (model.isAttBonus == true) { IsAllowAttBns = 1; } int isConfirm = 0; if (model.isConfirm == true) { isConfirm = 1; } int IsTranUse = 0; if (model.isTransportUse == true) { IsTranUse = 1; } var sqlQuery = "Update tblEmp_info Set empCode = '" + clsProc.FTSSingleQuoteAvoid(model.empCode) + "', empName = '" + clsProc.FTSSingleQuoteAvoid(model.empName) + "', Cardno = '" + clsProc.FTSSingleQuoteAvoid(model.CardNo) + "', SectIdSal = '" + clsProc.FTSSingleQuoteAvoid(model.deptId.ToString()) + "', BloodGroupID = '" + clsProc.FTSSingleQuoteAvoid(model.BloodId.ToString()) + "', PaymodeID = '" + clsProc.FTSSingleQuoteAvoid(model.PayId.ToString()) + "', WeekDayID = '" + clsProc.FTSSingleQuoteAvoid(model.WeekId.ToString()) + "', Sectid = '" + clsProc.FTSSingleQuoteAvoid(model.deptId.ToString()) + "', desigId = '" + clsProc.FTSSingleQuoteAvoid(model.desigId.ToString()) + "', LineID = '" + clsProc.FTSSingleQuoteAvoid(model.LineId.ToString()) + "', FloorID = '" + clsProc.FTSSingleQuoteAvoid(model.FloorId.ToString()) + "', EmpTypeID = '" + clsProc.FTSSingleQuoteAvoid(model.TypeId.ToString()) + "', ReligionID = '" + clsProc.FTSSingleQuoteAvoid(model.ReligionId.ToString()) + "', GradeID = '" + clsProc.FTSSingleQuoteAvoid(model.GradeId.ToString()) + "', GenderID = '" + clsProc.FTSSingleQuoteAvoid(model.SexId.ToString()) + "', ShiftID = '" + clsProc.FTSSingleQuoteAvoid(model.ShiftId.ToString()) + "', deptId = '" + clsProc.FTSSingleQuoteAvoid(model.deptId.ToString()) + "', GS = '" + clsProc.FTSSingleQuoteAvoid(model.GS) + "',dtJoin = '" + Convert.ToDateTime(clsProc.FTSSingleQuoteAvoid(model.dtJoin.ToString())) + "',dtbirth = '" + Convert.ToDateTime(clsProc.FTSSingleQuoteAvoid(model.dtBirth.ToString())) + "', isInactive = '"+isInactive+ "', isAllowOT = '" + isAllowOT + "', isAllowPF = '" + isAllowPF + "', IsAllowAttBns = '" + IsAllowAttBns + "', isConfirm = '" + isConfirm + "', IsTranUse = '" + IsTranUse + "' Where empID = '" + clsProc.FTSSingleQuoteAvoid(model.empID.ToString()) + "' "; arQuery.Add(sqlQuery); clsCon.FTSSaveDataWithSQLCommand(arQuery); return "Data updated sucessfully"; } catch (Exception ex) { return ex.Message.ToString(); } finally { clsCon = null; } } public String prcDeleteData(Employee model) { clsConnection clsCon = new clsConnection(); clsProcedure clsProc = new clsProcedure(); try { var sqlQuery = "Delete From tblEmp_info Where empID = '" + clsProc.FTSSingleQuoteAvoid(model.empID.ToString()) + "' "; clsCon.FTSSaveDataWithSQLCommand(sqlQuery); return "Sucessfully Deleted."; } catch (Exception ex) { throw (ex); } finally { clsProc = null; clsCon = null; } } #endregion procedures }} My View Code: @model FTSWeb.Models.HouseKeeping.Employee@{ ViewBag.Title = "Create";}@using (Html.BeginForm()){ @* @Html.ValidationMessage("CustomError") *@ @Html.AntiForgeryToken() @Html.ValidationSummary(true) @Html.ValidationMessage("CustomError") @*×*@ Employee - Create @**@ @Html.LabelFor(model => model.empCode, new { @class = "control-label pull-right small" }) @Html.TextBoxFor(model => model.empCode, "", new { @class = "form-control btn-block", @id = "empCode" }) @Html.ValidationMessageFor(model => model.empCode) @Html.LabelFor(model => model.empName, new { @class = "control-label pull-right small" }) @*@Html.TextBoxFor(model => model.empName, "", new { @class = "form-control btn-block", @id = "empName" }) @Html.ValidationMessageFor(model => model.empName)*@ @**@ @**@ @Html.LabelFor(model => model.CardNo, new { @class = "control-label pull-right small" }) @Html.TextBoxFor(model => model.CardNo, "", new { @class = "form-control", @onkeypress = "return isNumberKey(event);", @id = "CardNo" }) @Html.ValidationMessageFor(model => model.CardNo) @*@Html.LabelFor(model => model.RPId, new { @class = "control-label pull-right" })*@ Designation : @Html.DropDownList("desigId", new SelectList(ViewBag.Desig, "Id", "Name"), new { @class = "form-control btn-block" }) @Html.ValidationMessageFor(model => model.desigId) @**@ @**@ Department : @Html.DropDownList("deptId", new SelectList(ViewBag.Dept, "Id", "Name"), new { @class = "form-control btn-block" }) @Html.ValidationMessageFor(model => model.deptId) @Html.LabelFor(model => model.GS, new { @class = "control-label pull-right small" }) @Html.TextBoxFor(model => model.GS, "", new { @class = "form-control", @onkeypress = "return isNumberKey(event);", @id = "GS" }) @Html.ValidationMessageFor(model => model.GS) @* *@ Line : @Html.DropDownList("LineId", new SelectList(ViewBag.Line, "Id", "Name"), new { @class = "form-control btn-block" }) @Html.ValidationMessageFor(model => model.LineId) Floor : @Html.DropDownList("FloorId", new SelectList(ViewBag.Floor, "Id", "Name"), new { @class = "form-control btn-block" }) @Html.ValidationMessageFor(model => model.FloorId) @* *@ Employee Type : @Html.DropDownList("TypeId", new SelectList(ViewBag.Type, "Id", "Name"), new { @class = "form-control btn-block" }) @Html.ValidationMessageFor(model => model.TypeId) Religion : @Html.DropDownList("ReligionId", new SelectList(ViewBag.Religion, "Id", "Name"), new { @class = "form-control btn-block" }) @Html.ValidationMessageFor(model => model.ReligionId) @* *@ Grade : @Html.DropDownList("GradeId", new SelectList(ViewBag.Grade, "Id", "Name"), new { @class = "form-control btn-block" }) @Html.ValidationMessageFor(model => model.GradeId) Sex : @Html.DropDownList("SexId", new SelectList(ViewBag.Sex, "Id", "Name"), new { @class = "form-control btn-block" }) @Html.ValidationMessageFor(model => model.SexId) @* *@ @**@ Shift Type : @Html.DropDownList("ShiftId", new SelectList(ViewBag.Shift, "Id", "Name"), new { @class = "form-control btn-block" }) @Html.ValidationMessageFor(model => model.ShiftId) Weekly OffDay : @Html.DropDownList("WeekId", new SelectList(ViewBag.Week, "Id", "Name"), new { @class = "form-control btn-block" }) @Html.ValidationMessageFor(model => model.WeekId) @**@ @* *@ Blood Group : @Html.DropDownList("BloodId", new SelectList(ViewBag.Blood, "Id", "Name"), new { @class = "form-control btn-block" }) @Html.ValidationMessageFor(model => model.BloodId) Salary Paymode : @Html.DropDownList("PayId", new SelectList(ViewBag.Paymode, "Id", "Name"), new { @class = "form-control btn-block" }) @Html.ValidationMessageFor(model => model.PayId) @**@ @**@ Joining Date : @*@Html.TextBoxFor(model => model.dtJoin, new { @placeholder = "Joining Date", @class = "form-control", @id = "datepicker" }) @Html.ValidationMessageFor(model => model.dtJoin)*@ @Html.TextBoxFor(model => model.dtJoin, new { @placeholder = "Joining Date", @class = "form-control", @id = "datepicker" }) @Html.ValidationMessageFor(model => model.dtJoin) Birth Date : @Html.TextBoxFor(model => model.dtBirth, new { @placeholder = "Birth Date", @class = "form-control", @id = "datepicker1" }) @Html.ValidationMessageFor(model => model.dtBirth) @* @**@ @**@ @*@Html.LabelFor(model => model.IsAllowOT, new { @class = "control-label pull-right small" })*@ IsAllowOT : @*@Html.CheckBoxFor(model => model.IsAllowOT, new { @class = "checkbox form-control" }) @Html.ValidationMessageFor(model => model.IsAllowOT)*@ Inactive : @*@Html.LabelFor(model => model.isInactive, new { @class = "control-label pull-right small" })*@ @**@ @*@Html.CheckBoxFor(model => model.isInactive, new { @class = "checkbox form-control" }) @Html.ValidationMessageFor(model => model.isInactive)*@ @**@ @**@ @**@ @**@ @*@Html.LabelFor(model => model.IsAllowPF, new { @class = "control-label pull-right small" })*@ IsAllowPF : @*@Html.CheckBoxFor(model => model.IsAllowPF, new { @class = "checkbox form-control" }) @Html.ValidationMessageFor(model => model.IsAllowPF)*@ @*@Html.LabelFor(model => model.isAttBonus, new { @class = "control-label pull-right small" })*@ isAttBonus : @*@Html.CheckBoxFor(model => model.isAttBonus, new { @class = "checkbox form-control" }) @Html.ValidationMessageFor(model => model.isAttBonus)*@ @**@ @**@ @**@ @**@ top: 0px; width: 100%; height: 100%; background-color: #666666; z-index: 30001; opacity: .8; filter: alpha(opacity=70);display:none"> @*@Html.LabelFor(model => model.isConfirm, new { @class = "control-label pull-right small" })*@ isConfirm : @**@ @*@Html.CheckBoxFor(model => model.isConfirm, new { @class = "checkbox form-control" }) @Html.ValidationMessageFor(model => model.isConfirm)*@ isTransportUse : @*@Html.LabelFor(model => model.isTransportUse, new { @class = "control-label pull-right small" })*@ @**@ @*@Html.CheckBoxFor(model => model.isTransportUse, new { @class = "checkbox form-control" }) @Html.ValidationMessageFor(model => model.isTransportUse)*@ @**@ @Html.ActionLink("Back to List", "Index", "", new { @class = "btn btn-info btn-block" }) @* Close *@ } $(document).ready(function () { $("#datepicker").datepicker({ dateFormat: 'dd-MM-yy' }); $("#datepicker1").datepicker({ dateFormat: 'dd-MM-yy' }); }); function fncValidate() { if ($('#empCode').val().length == 0) { alert("Please provide container No."); return false; } if ($('#empName').val().length == 0) { alert("Please provide security seal No."); return false; } if ($('#CardNo').val().length == 0) { alert("Please provide container condition."); return false; } if ($('#GS').val().length == 0) { alert("Please provide weather condition."); return false; } } function JavascriptFunction() { var url = '@Url.Action("PostMethod", "Home")'; $("#divLoading").show(); $.post(url, null, function (data) { $("#PID")[0].innerHTML = data; $("#divLoading").hide(); }); } function isNumberKey(evt) { var charCode = (evt.which) ? evt.which : event.keyCode; if (charCode != 46 && charCode > 31 && (charCode < 48 || charCode > 57)) return false; return true; } $("#m").on('click', function () { $(this).closest(".modal").modal('hide'); }); $(".display tr").click(function () { $(this).find(".foo").each(function () { //alert($(this).val()); }); });My Model Code: using System;using System.Collections.Generic;using System.ComponentModel.DataAnnotations;using System.Data;using System.Linq;using System.Web;namespace FTSWeb.Models.HouseKeeping{ public class Employee { //empID, empCode, empName, CardNo, A.desigId, DesigName, A.deptId,deptName,GS, LineId,FloorId,TypeId,ReligionId //,GradeId,SexId,ShiftId,WeekId,BloodId,PayId,IsAllowOT, isInactive,IsAllowPF,isAttBonus,isConfirm,isTransportUse [Key] [Display(Name = "Id")] public int empID { get; set; } [Display(Name = "Employee Code :")] [Required(ErrorMessage = "Please, provide employee code")] public string empCode { get; set; } [Display(Name = "Name :")] [Required(ErrorMessage = "Please, provide employee name")] public string empName { get; set; } [Display(Name = "Card No :")] [DisplayFormat(ConvertEmptyStringToNull = false)] public string CardNo { get; set; } [Display(Name = "Designation :")] [Required(ErrorMessage = "Please, provide designation.")] public Int32 desigId { get; set; } [Display(Name = "Department :")] [Required(ErrorMessage = "Please, provide department.")] public Int32 deptId { get; set; } [Display(Name = "GS :")] [DisplayFormat(ConvertEmptyStringToNull = false)] public string GS { get; set; } [Display(Name = "Line :")] [Required(ErrorMessage = "Please, provide Line.")] public Int32 LineId { get; set; } //public string LineName { get; set; } [Display(Name = "Floor :")] [Required(ErrorMessage = "Please, provide Floor.")] public Int32 FloorId { get; set; } //public string FloorName { get; set; } [Display(Name = "Type :")] [Required(ErrorMessage = "Please, provide Type.")] public Int32 TypeId { get; set; } [Display(Name = "Religion :")] [Required(ErrorMessage = "Please, provide Religion.")] public Int32 ReligionId { get; set; } [Display(Name = "Grade :")] [Required(ErrorMessage = "Please, provide Grade.")] public Int32 GradeId { get; set; } [Display(Name = "Sex :")] [Required(ErrorMessage = "Please, provide Male-Female - Type.")] public Int32 SexId { get; set; } [Display(Name = "Shift :")] [Required(ErrorMessage = "Please, provide Shift-Type.")] public Int32 ShiftId { get; set; } [Display(Name = "Weekly OFF day :")] [Required(ErrorMessage = "Please, provide Weekly Day.")] public Int32 WeekId { get; set; } [Display(Name = "Blood Group :")] [Required(ErrorMessage = "Please, provide Blood Group.")] public Int32 BloodId { get; set; } [Display(Name = "Paymode :")] [Required(ErrorMessage = "Please, provide Paymode.")] public Int32 PayId { get; set; } [Required(ErrorMessage = "Please, provide Joining Date.")] [Display(Name = "Join Date :")] [DataType(DataType.Date)] public string dtJoin { get; set; } [Required(ErrorMessage = "Please, provide Birth Date.")] [Display(Name = "Birth Date :")] [DataType(DataType.Date)] public string dtBirth { get; set; } //[Display(Name = "Email :")] //[DisplayFormat(ConvertEmptyStringToNull = false)] //public string email { get; set; } [Display(Name = "Is-Inactive : ")] public Boolean isInactive { get; set; } [Display(Name = "Is-Allow-OT : ")] public Boolean IsAllowOT { get; set; } [Display(Name = "Is-Allow-PF : ")] public Boolean IsAllowPF { get; set; } [Display(Name = "Is-Att-Bonus : ")] public Boolean isAttBonus { get; set; } [Display(Name = "Is-Confirm : ")] public Boolean isConfirm { get; set; } [Display(Name = "Is-Transport-Use : ")] public Boolean isTransportUse { get; set; } private void prcSetData(IDataRecord reader) { empID = Int32.Parse(reader["empID"].ToString()); empCode = reader["empCode"].ToString(); empName = reader["empName"].ToString(); CardNo = reader["CardNo"].ToString(); desigId = Int32.Parse(reader["desigId"].ToString()); deptId = Int32.Parse(reader["deptId"].ToString()); GS = reader["GS"].ToString(); dtJoin = reader["dtJoin"].ToString(); LineId = Int32.Parse(reader["LineId"].ToString()); FloorId = Int32.Parse(reader["FloorId"].ToString()); ReligionId = Int32.Parse(reader["ReligionId"].ToString()); GradeId = Int32.Parse(reader["GradeId"].ToString()); SexId = Int32.Parse(reader["SexId"].ToString()); ShiftId = Int32.Parse(reader["ShiftId"].ToString()); WeekId = Int32.Parse(reader["WeekId"].ToString()); BloodId = Int32.Parse(reader["BloodId"].ToString()); PayId = Int32.Parse(reader["PayId"].ToString()); dtBirth = reader["dtBirth"].ToString(); //email = reader["email"].ToString(); isInactive = (Int32.Parse(reader["isInactive"].ToString()) == 0) ? false : true; IsAllowOT = (Int32.Parse(reader["IsAllowOT"].ToString()) == 0) ? false : true; IsAllowPF = (Int32.Parse(reader["IsAllowPF"].ToString()) == 0) ? false : true; isAttBonus = (Int32.Parse(reader["isAttBonus"].ToString()) == 0) ? false : true; isConfirm = (Int32.Parse(reader["isConfirm"].ToString()) == 0) ? false : true; isTransportUse = (Int32.Parse(reader["isTransportUse"].ToString()) == 0) ? false : true; } public static List prcGetData() { IDataReader reader = null; List list = new List(); clsConnection clsCon = new clsConnection(); try { const string sqlQuery = "Exec prcGetEmployee_WebBased '', 0"; reader = clsCon.GetReader(sqlQuery); while (reader.Read()) { Employee item = new Employee(); item.prcSetData(reader); list.Add(item); } return list; } catch (Exception ex) { throw (ex); } finally { clsCon = null; } } public static Employee prcGetData(Int32 Id) { IDataReader reader = null; Employee resPerson = new Employee(); clsConnection clsCon = new clsConnection(); try { string sqlQuery = "Exec prcGetEmployee_WebBased '', " + Id + ""; reader = clsCon.GetReader(sqlQuery); while (reader.Read()) { resPerson.prcSetData(reader); break; } return resPerson; } catch (Exception ex) { throw (ex); } finally { clsCon = null; } } public static DataSet prcGetData(string flag,string i) { DataSet dsList = new DataSet(); clsConnection clsCon = new clsConnection(); try { string sqlQuery = "Exec prcGetEmployee_WebBased '', '" + i + "'"; clsCon.FTSFillDatasetWithSQLCommand(ref dsList, sqlQuery); return dsList; } catch (Exception ex) { throw (ex); } finally { clsCon = null; } } }} Where should the code should be posted..@Manas Mohapatra ? 0Join to answer this questionEvery answer you publish earns 20 SHARP.Create free accountSign inKnow the answer?Answer a question in the forums and earn +20 SHARP for every answer.See unanswered questionsForumsTop experts01Arun PottiAnswers in the forums20answers02Tahir AnsariAnswers in the forums5answers03Kamlesh KumarAnswers in the forums5answers04Sam HobbsAnswers in the forums4answers05Željko PerićAnswers in the forums3answers?YouYour name goes here.Every answer: 20 SHARP.JoinFull leaderboard →2026DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Manas MohapatraRank #182 · 13.2K reputationPosted Sep 13, 2017, 11:13 PM EDT
Manas MohapatraRank #182 · 13.2K reputationPosted Sep 13, 2017, 10:32 PM EDT
Nazmul BadshaRank #6,279 · 271 reputationPosted Sep 13, 2017, 11:02 PM EDT
Nazmul BadshaRank #6,279 · 271 reputationPosted Sep 14, 2017, 2:01 AM EDT
Employee - Create
*@
*@
*@
*@
*@
*@
*@
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts