public ActionResult PrabhagEntry(tbl_Prabhag_Masterss model) { try { if (model.pkid == 0) { tbl_Prabhag_Master abc = new tbl_Prabhag_Master(); abc.Prabhag_Name = model.Prabhag_Name; abc.Address = model.Address; abc.Description = model.Description; abc.adddate = DateTime.Now; _prabhag.Add(abc); } else { int _id = Convert.ToInt32(model.pkid); tbl_Prabhag_Master abc = _prabhag.Get(_id); abc.pkid = model.pkid; abc.Prabhag_Name = model.Prabhag_Name; abc.Address = model.Address; abc.Description = model.Description; abc.adddate = DateTime.Now; _prabhag.Update(abc); } return(RedirectToAction("PrabhagEntry", "SystemMaster")); } catch (Exception e) { Commonfunction.LogError(e, Server.MapPath("~/Log.txt")); ViewBag.Exception = e.Message; return(View()); } }
public ActionResult EditUserDetails(tbl_UserDetailsss model, HttpPostedFileBase pic) { try { tbl_UserDetails abc = _user.Get(model.pkid); abc.FullName = model.FullName; abc.ContactNumber = model.ContactNumber; abc.AddressLine1 = model.AddressLine1; abc.RoleName = model.RoleName; abc.EmailId = model.EmailId; abc.LastModifiedDate = DateTime.Now; if (pic != null) { string path = System.Web.HttpContext.Current.Server.MapPath(model.ProdilePic); if (System.IO.File.Exists(path)) { System.IO.File.Delete(path); } WebFunction web = new WebFunction(); model.ProdilePic = web.Storefile(pic, 4); } _user.Update(abc); return(RedirectToAction("Register", "Account")); } catch (Exception e) { Commonfunction.LogError(e, Server.MapPath("~/Log.txt")); ViewBag.Exception = e.Message; return(View()); } }
public ActionResult TourismSubcate(tbl_Tourism_SubCategoryss model) { ViewBag.catList = new SelectList(_catTourism.GetAll(), "pkid", "Category_Name"); try { if (model.pkid == 0) { tbl_Tourism_SubCategory abc = new tbl_Tourism_SubCategory(); abc.SubCategory_Name = model.SubCategory_Name; abc.SubCategory_Description = model.SubCategory_Description; abc.Category_fkid = model.Category_fkid; abc.LastModifiedDate = DateTime.Now; _subcatTourism.Add(abc); } else { int _id = Convert.ToInt32(model.pkid); tbl_Tourism_SubCategory abc = _subcatTourism.Get(_id); abc.pkid = model.pkid; abc.SubCategory_Name = model.SubCategory_Name; abc.Category_fkid = model.Category_fkid; abc.SubCategory_Description = model.SubCategory_Description; abc.LastModifiedDate = DateTime.Now; _subcatTourism.Update(abc); } return(RedirectToAction("TourismSubcate", "SystemMaster")); } catch (Exception e) { Commonfunction.LogError(e, Server.MapPath("~/Log.txt")); ViewBag.Exception = e.Message; return(View()); } }
public ActionResult GetResultExcel(int id) { try { var v = (from a in _examresult.GetAll() select new { pkid = a.pkid, examid = a.Exam_fkid, sname = _student.Get(a.Student_fkid).FullName, ename = _Exam.Get(a.Exam_fkid).Exam_Name, emark = a.TotalMarks, smark = a.TotalGainMarks, Result = a.Result, examdt = a.AttemptExamDate }); if (id > 0) { v = (from b in v.Where(x => x.examid == id) select b); } DataTable _table = new DataTable(); _table.TableName = "ResultReport"; _table.Columns.Add("S.No.", typeof(string)); _table.Columns.Add("Exam Name", typeof(string)); _table.Columns.Add("Student Name", typeof(string)); _table.Columns.Add("Total Exam Marks", typeof(string)); _table.Columns.Add("Student Score Marks", typeof(string)); _table.Columns.Add("Result", typeof(string)); _table.Columns.Add("Exam Date", typeof(string)); long srno = 1; foreach (var item in v.ToList()) { _table.Rows.Add(srno, item.ename, item.sname, item.emark, item.smark, item.Result, item.examdt.HasValue ? item.examdt.Value.ToString("dd-MM-yyyy") : ""); srno++; } GridView gv = new GridView(); gv.DataSource = _table; gv.DataBind(); Response.ClearContent(); Response.Buffer = true; Response.AddHeader("content-disposition", "attachment; filename=StudentResult.xls"); Response.ContentType = "application/ms-excel"; StringWriter sw = new StringWriter(); HtmlTextWriter htw = new HtmlTextWriter(sw); gv.RenderControl(htw); Response.Output.Write(sw.ToString()); Response.Flush(); Response.End(); } catch (Exception e) { ViewBag.Exception = e.Message; Commonfunction.LogError(e, Server.MapPath("~/ErrorLog.txt")); } return(View()); }
public ActionResult ComplaintCat(tbl_Category_Complaintss model) { try { if (model.pkid == 0) { tbl_Category_Complaint abc = new tbl_Category_Complaint(); abc.CategoryName = model.CategoryName; abc.Description = model.Description; abc.LastModifedDate = DateTime.Now; _catComplaint.Add(abc); } else { int _id = Convert.ToInt32(model.pkid); tbl_Category_Complaint abc = _catComplaint.Get(_id); abc.pkid = model.pkid; abc.CategoryName = model.CategoryName; abc.Description = model.Description; abc.LastModifedDate = DateTime.Now; _catComplaint.Update(abc); } return(RedirectToAction("ComplaintCat", "SystemMaster")); } catch (Exception e) { Commonfunction.LogError(e, Server.MapPath("~/Log.txt")); ViewBag.Exception = e.Message; return(View()); } }
public ActionResult WardMemberEntry(tbl_wardMember_Masterss model, HttpPostedFileBase Pic) { ViewBag.ward = new SelectList(_ward.GetAll(), "pkid", "ward_Name"); try { WebFunction web = new WebFunction(); if (model.pkid == 0) { tbl_wardMember_Master abc = new tbl_wardMember_Master(); abc.Ward_fkid = model.Ward_fkid; abc.Member_Name = model.Member_Name; abc.Description = model.Description; abc.adddate = DateTime.Now; abc.status = model.status; abc.Address = model.Address; abc.MobileNo = model.MobileNo; if (Pic != null) { string path = System.Web.HttpContext.Current.Server.MapPath(model.ProfilePic); if (System.IO.File.Exists(path)) { System.IO.File.Delete(path); } model.ProfilePic = web.Storefile(Pic, 5); } _wardmember.Add(abc); } else { int _id = Convert.ToInt32(model.pkid); tbl_wardMember_Master abc = _wardmember.Get(_id); abc.pkid = model.pkid; abc.Ward_fkid = model.Ward_fkid; abc.Member_Name = model.Member_Name; abc.Description = model.Description; abc.adddate = DateTime.Now; abc.status = model.status; abc.Address = model.Address; abc.MobileNo = model.MobileNo; if (Pic != null) { string path = System.Web.HttpContext.Current.Server.MapPath(model.ProfilePic); if (System.IO.File.Exists(path)) { System.IO.File.Delete(path); } model.ProfilePic = web.Storefile(Pic, 5); } _wardmember.Update(abc); } return(RedirectToAction("WardMemberEntry", "SystemMaster")); } catch (Exception e) { Commonfunction.LogError(e, Server.MapPath("~/Log.txt")); ViewBag.Exception = e.Message; return(View()); } }
public ActionResult NewsAndUpdated(tbl_NewsAndUpdatedss model, HttpPostedFileBase files) { try { if (model.pkid == 0) { tbl_NewsAndUpdated abc = new tbl_NewsAndUpdated(); abc.Title = model.Title; abc.Description = model.Description; abc.status = model.status; abc.ProfilePic = model.ProfilePic; abc.Addate = DateTime.Now; abc.lastModified = DateTime.Now; if (files != null) { string path = System.Web.HttpContext.Current.Server.MapPath(model.ProfilePic); if (System.IO.File.Exists(path)) { System.IO.File.Delete(path); } WebFunction web = new WebFunction(); abc.ProfilePic = web.Storefile(files, 6); } _news.Add(abc); } else { int _id = Convert.ToInt32(model.pkid); tbl_NewsAndUpdated abc = _news.Get(_id); abc.Title = model.Title; abc.status = model.status; abc.Description = model.Description; abc.ProfilePic = model.ProfilePic; abc.lastModified = DateTime.Now; if (files != null) { string path = System.Web.HttpContext.Current.Server.MapPath(model.ProfilePic); if (System.IO.File.Exists(path)) { System.IO.File.Delete(path); } WebFunction web = new WebFunction(); abc.ProfilePic = web.Storefile(files, 6); } _news.Update(abc); } return(RedirectToAction("NewsAndUpdated", "Administration")); } catch (Exception e) { Commonfunction.LogError(e, Server.MapPath("~/Log.txt")); ViewBag.Exception = e.Message; return(View()); } }
public ActionResult Addnotice(tbl_NoticeBoardMasterss model, HttpPostedFileBase image) { try { if (model.pkid == 0) { tbl_NoticeBoardMaster abc = new tbl_NoticeBoardMaster(); if (image != null) { WebFunction web = new WebFunction(); model.Image_Path = web.Storefile(image, 2); } abc.NoticeName = model.NoticeName; abc.NoticeDescription = model.NoticeDescription; abc.Image_Path = model.Image_Path; abc.AddedDate = DateTime.Now; abc.RequiredDays = model.RequiredDays; abc.Active = model.Active; abc.LastModifiedDate = DateTime.Now; _notice.Add(abc); } else { int _id = Convert.ToInt32(model.pkid); tbl_NoticeBoardMaster abc = _notice.Get(_id); if (image != null) { string path = System.Web.HttpContext.Current.Server.MapPath(model.Image_Path); if (System.IO.File.Exists(path)) { System.IO.File.Delete(path); } WebFunction web = new WebFunction(); model.Image_Path = web.Storefile(image, 2); } abc.pkid = model.pkid; abc.NoticeName = model.NoticeName; abc.NoticeDescription = model.NoticeDescription; abc.Image_Path = model.Image_Path; abc.AddedDate = model.AddedDate; abc.RequiredDays = model.RequiredDays; abc.Active = model.Active; abc.LastModifiedDate = DateTime.Now; _notice.Update(abc); } return(RedirectToAction("Addnotice", "Administration")); } catch (Exception e) { Commonfunction.LogError(e, Server.MapPath("~/Log.txt")); ViewBag.Exception = e.Message; return(View()); } }
public ActionResult DbConfiguration(tbl_RemoteConnection model) { string connectionstring = "Data Source=" + model.serverName + ";Initial Catalog=" + model.dataBaseName + ";User ID=" + model.userName + ";Password="******";"; weighingcontrolSystemEntities _db = new weighingcontrolSystemEntities(); if (model.pkid > 0) { try { using (SqlConnection con = new SqlConnection(connectionstring)) { con.Open(); _db.Entry(model).State = System.Data.EntityState.Modified; _db.SaveChanges(); con.Close(); } ViewBag.alert = "Connection Modified ...."; ModelState.Clear(); return(View()); } catch (Exception ex) { Commonfunction.LogError(ex, HttpContext.Server.MapPath("~/ErrorLog.txt")); ViewBag.alert = ex.Message; return(View()); } } else { try { using (SqlConnection con = new SqlConnection(connectionstring)) { con.Open(); con.Close(); _db.tbl_RemoteConnection.Add(model); _db.SaveChanges(); ViewBag.alert = "Connection Saved ...."; ModelState.Clear(); return(View()); } } catch (Exception ex) { Commonfunction.LogError(ex, HttpContext.Server.MapPath("~/ErrorLog.txt")); ViewBag.alert = ex.Message; return(View()); } } return(View()); }
public ActionResult shiftList() { weighingcontrolSystemEntities _db = new weighingcontrolSystemEntities(); var search = Request.Form.GetValues("search[value]")[0]; var draw = Request.Form.GetValues("draw").FirstOrDefault(); var start = Request.Form.GetValues("start").FirstOrDefault(); var length = Request.Form.GetValues("length").FirstOrDefault(); //Find Order Column string sortColumn = Request.Form.GetValues("columns[" + Request.Form.GetValues("order[0][column]").FirstOrDefault() + "][name]").FirstOrDefault(); string sortColumnDir = Request.Form.GetValues("order[0][dir]").FirstOrDefault(); int pageSize = length != null?Convert.ToInt32(length) : 0; int skip = start != null?Convert.ToInt32(start) : 0; int recordsTotal = 0; try { //dc.Configuration.LazyLoadingEnabled = false; // if your table is relational, contain foreign key var v = (from a in _db.tbl_operatorshift.Select(x => new { x.pkid, x.shiftname, x.shiftstsrtTime, x.shiftEndTime }) select a); //SORT if (!string.IsNullOrEmpty(search) && !string.IsNullOrWhiteSpace(search)) { v = (from b in _db.tbl_operatorshift.Where(x => x.shiftname.Contains(search)).Select(x => new { x.pkid, x.shiftname, x.shiftstsrtTime, x.shiftEndTime }) select b); } if (!(string.IsNullOrEmpty(sortColumn) && string.IsNullOrEmpty(sortColumnDir))) { v = v.OrderBy(sortColumn, sortColumnDir); //v = v.OrderBy(x=>x.orderfkid); } recordsTotal = v.Count(); var data = v.Skip(skip).Take(pageSize).ToList(); List <Shift> newList = new List <Shift>(); foreach (var item in data) { Shift obj = new Shift(); obj.pkid = item.pkid; obj.shiftname = item.shiftname; TimeSpan ts = new TimeSpan(); ts = (TimeSpan)item.shiftstsrtTime; obj.shiftstsrtTime = ts.Hours + ":" + ts.Minutes + ":" + ts.Milliseconds; ts = new TimeSpan(); ts = (TimeSpan)item.shiftEndTime; obj.shiftEndTime = ts.Hours + ":" + ts.Minutes + ":" + ts.Milliseconds; newList.Add(obj); } return(Json(new { draw = draw, recordsFiltered = recordsTotal, recordsTotal = recordsTotal, data = newList }, JsonRequestBehavior.AllowGet)); } catch (Exception e) { Commonfunction.LogError(e, HttpContext.Server.MapPath("~/ErrorLog.txt")); return(Json(new { draw = draw, recordsFiltered = recordsTotal, recordsTotal = recordsTotal, data = "" }, JsonRequestBehavior.AllowGet)); } }
public async Task <ActionResult> Register(string Exceptionmsg, string id, string uname) { try { int culture = 0; if (this.Session == null || this.Session["CurrentCulture"] == null) { int.TryParse(System.Configuration.ConfigurationManager.AppSettings["Culture"], out culture); this.Session["CurrentCulture"] = culture; } else { culture = (int)this.Session["CurrentCulture"]; } // calling CultureHelper class properties for setting CultureHelper.CurrentCulture = culture; var roleManager = new RoleManager <Microsoft.AspNet.Identity.EntityFramework.IdentityRole>(new RoleStore <IdentityRole>(new ApplicationDbContext())); ViewBag.rolelist = new SelectList(roleManager.Roles.ToList(), "Name", "Name"); ViewBag.Exception = Exceptionmsg; ViewBag.name = uname; if (!string.IsNullOrWhiteSpace(Exceptionmsg)) { var user = await UserManager.FindByIdAsync(id); var rolesForUser = await UserManager.GetRolesAsync(id); if (rolesForUser.Count() > 0) { foreach (var item in rolesForUser.ToList()) { // item should be the name of the role var result = await UserManager.RemoveFromRoleAsync(user.Id, item); } } await UserManager.DeleteAsync(user); } return(View()); } catch (Exception e) { Commonfunction.LogError(e, Server.MapPath("~/Log.txt")); ViewBag.Exception = e.Message; return(View()); } }
public async Task <ActionResult> AdminLogin(LoginViewModel model, string returnUrl) { try { if (!ModelState.IsValid) { ModelState.AddModelError("", "Model State Is Invalid."); return(View(model)); } // This doesn't count login failures towards account lockout // To enable password failures to trigger account lockout, change to shouldLockout: true string UserName = ""; try { UserName = db.tbl_User_Profile.Where(x => x.EmailAddress == model.Email || x.MobileNumber == model.Email).FirstOrDefault().UserName; } catch { } var result = await SignInManager.PasswordSignInAsync(UserName, model.Password, model.RememberMe, shouldLockout : false); switch (result) { case SignInStatus.Success: return(RedirectToLocal(returnUrl)); case SignInStatus.LockedOut: return(View("Lockout")); case SignInStatus.RequiresVerification: return(RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe })); case SignInStatus.Failure: default: ModelState.AddModelError("", "Invalid login attempt."); return(View(model)); } } catch (Exception e) { Commonfunction.LogError(e, Server.MapPath("~/Log.txt")); ViewBag.Exception = e.Message; return(RedirectToAction("AdminLogin", "Account")); } }
public ActionResult EditUserDetails(tbl_User_Profiless model) { string exception = ""; try { if (!string.IsNullOrEmpty(model.EmailAddress)) { int mobdt = _user.GetAll().Where(x => x.EmailAddress == model.EmailAddress && x.pkid != model.pkid).Count(); if (mobdt > 0) { exception = "User Email Already Taken."; return(RedirectToAction("AdminUserRegister", "Account", new { Exceptionmsg = exception })); } } if (!string.IsNullOrEmpty(model.MobileNumber)) { int mobdt = _user.GetAll().Where(x => x.MobileNumber == model.MobileNumber && x.pkid != model.pkid).Count(); if (mobdt > 0) { exception = "User Mobile Number Already Taken."; return(RedirectToAction("AdminUserRegister", "Account", new { Exceptionmsg = exception })); } } tbl_User_Profile abc = _user.Get(model.pkid); abc.FirstName = model.FirstName; abc.UserName = model.UserName; abc.MobileNumber = model.MobileNumber; abc.AddressLine1 = model.AddressLine1; abc.RoleName = model.RoleName; abc.AddressLine1 = model.AddressLine1; abc.AddressLine2 = model.AddressLine2; abc.EmailAddress = model.EmailAddress; abc.LastModifiedDate = DateTime.Now; _user.Update(abc); return(RedirectToAction("AdminUserRegister", "Account")); } catch (Exception e) { Commonfunction.LogError(e, Server.MapPath("~/Log.txt")); ViewBag.Exception = e.Message; return(RedirectToAction("AdminUserRegister", "Account")); } }
public ActionResult DeleteQuestion(int id) { string exception = ""; try { tbl_QuestionMaster QUE = _question.Get(id); tbl_AnswerMaster ANS = _answer.GetAll().Where(x => x.Ques_fkid == QUE.pkid).FirstOrDefault(); _answer.Remove(ANS, true); _question.Remove(QUE, true); exception = "Deleted Successfully."; return(Json(exception, JsonRequestBehavior.AllowGet)); } catch (Exception e) { Commonfunction.LogError(e, Server.MapPath("~/Log.txt")); exception = e.Message; return(Json(exception, JsonRequestBehavior.AllowGet)); } }
public ActionResult SaveCustomer() { string userid = ""; try { userid = TempData["id"].ToString(); string ro = TempData["role"].ToString(); string Uname = null; try { Uname = TempData["username"].ToString(); } catch { } string email = null; try { email = TempData["ema"].ToString(); } catch { } string pas = TempData["passwo"].ToString(); string funame = null; try { funame = TempData["fname"].ToString(); } catch { } string mobino = null; try { mobino = TempData["mobi"].ToString(); } catch { } tbl_UserDetails abc = new tbl_UserDetails(); abc.User_fkid = userid; abc.UserName = Uname; abc.RoleName = ro; abc.EmailId = email; abc.FullName = funame; abc.ContactNumber = mobino; abc.RegisteredDate = DateTime.Now; abc.LastModifiedDate = DateTime.Now; _user.Add(abc); return(RedirectToAction("Register", "Account")); } catch (Exception e) { Commonfunction.LogError(e, Server.MapPath("~/Log.txt")); return(RedirectToAction("Register", "Account", new { Exceptionmsg = e.Message, id = userid })); } }
public async Task <ActionResult> ForgotPassword(ForgotPasswordViewModel model) { try { if (ModelState.IsValid) { string UserName = ""; try { UserName = db.tbl_User_Profile.Where(x => x.EmailAddress == model.Email || x.MobileNumber == model.Email).FirstOrDefault().UserName; } catch { } var user = await UserManager.FindByNameAsync(UserName); if (user == null) { // Don't reveal that the user does not exist or is not confirmed return(View("ForgotPasswordConfirmation")); } // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link string token = await UserManager.GeneratePasswordResetTokenAsync(user.Id); var result = await UserManager.ResetPasswordAsync(user.Id, token, "123456"); // await UserManager.SendEmailAsync(user.Id, "Reset Password", "Please reset your password by clicking <a href=\"" + callbackUrl + "\">here</a>"); return(RedirectToAction("AdminLogin", "Account")); } } catch (Exception e) { Commonfunction.LogError(e, Server.MapPath("~/Log.txt")); ViewBag.Exception = e.Message; return(View(model)); } return(View(model)); }
// Test Database connection public ActionResult testDbConnection(string serverName, string dataBaseName, string userName, string password) { string connectionstring = "Data Source=" + serverName + ";Initial Catalog=" + dataBaseName + ";User ID=" + userName + ";Password="******";"; try { using (SqlConnection con = new SqlConnection(connectionstring)) { con.Open(); con.Close(); return(Json("Connection successful...", JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { Commonfunction.LogError(ex, HttpContext.Server.MapPath("~/ErrorLog.txt")); return(Json(ex.Message, JsonRequestBehavior.AllowGet)); } return(Json("Connection successfull...", JsonRequestBehavior.AllowGet)); }
public ActionResult AddGroup(tbl_GroupMasterss model) { string exception = ""; try { if (model.pkid == 0) { tbl_GroupMaster abc = new tbl_GroupMaster(); abc.pkid = model.pkid; abc.GroupName = model.GroupName; abc.description = model.description; abc.adddate = DateTime.Now; abc.lastdatemodified = DateTime.Now; _group.Add(abc); exception = "Save Successfully"; } else { int _id = Convert.ToInt32(model.pkid); tbl_GroupMaster abc = _group.Get(_id); abc.pkid = model.pkid; abc.GroupName = model.GroupName; abc.description = model.description; abc.lastdatemodified = DateTime.Now; _group.Update(abc); exception = "Updated Successfully"; } return(RedirectToAction("GroupMaster", "SubjectGroup", new { Exception = exception })); } catch (Exception e) { Commonfunction.LogError(e, Server.MapPath("~/Log.txt")); exception = e.Message; return(RedirectToAction("GroupMaster", "SubjectGroup", new { Exception = exception })); } }
public ActionResult truckMappingList() { weighingcontrolSystemEntities _db = new weighingcontrolSystemEntities(); var search = Request.Form.GetValues("search[value]")[0]; var draw = Request.Form.GetValues("draw").FirstOrDefault(); var start = Request.Form.GetValues("start").FirstOrDefault(); var length = Request.Form.GetValues("length").FirstOrDefault(); //Find Order Column string sortColumn = Request.Form.GetValues("columns[" + Request.Form.GetValues("order[0][column]").FirstOrDefault() + "][name]").FirstOrDefault(); string sortColumnDir = Request.Form.GetValues("order[0][dir]").FirstOrDefault(); int pageSize = length != null?Convert.ToInt32(length) : 0; int skip = start != null?Convert.ToInt32(start) : 0; int recordsTotal = 0; try { //dc.Configuration.LazyLoadingEnabled = false; // if your table is relational, contain foreign key var v = (from a in _db.tbl_truckMapping.Select(x => new { x.pkid, x.truckNo, x.truckRFID, x.comments }) select a); //SORT if (!string.IsNullOrEmpty(search) && !string.IsNullOrWhiteSpace(search)) { v = (from b in _db.tbl_truckMapping.Where(x => x.truckNo.Contains(search) || x.truckRFID.Contains(search)).Select(x => new { x.pkid, x.truckNo, x.truckRFID, x.comments }) select b); } if (!(string.IsNullOrEmpty(sortColumn) && string.IsNullOrEmpty(sortColumnDir))) { v = v.OrderBy(sortColumn, sortColumnDir); //v = v.OrderBy(x=>x.orderfkid); } recordsTotal = v.Count(); var data = v.Skip(skip).Take(pageSize).ToList(); return(Json(new { draw = draw, recordsFiltered = recordsTotal, recordsTotal = recordsTotal, data = data }, JsonRequestBehavior.AllowGet)); } catch (Exception e) { Commonfunction.LogError(e, HttpContext.Server.MapPath("~/ErrorLog.txt")); return(Json(new { draw = draw, recordsFiltered = recordsTotal, recordsTotal = recordsTotal, data = "" }, JsonRequestBehavior.AllowGet)); } }
public ActionResult WardEntry(tbl_Ward_masterss model) { ViewBag.prabhag = new SelectList(_prabhag.GetAll(), "pkid", "Prabhag_Name"); try { if (model.pkid == 0) { tbl_Ward_master abc = new tbl_Ward_master(); abc.prabhag_fkid = model.prabhag_fkid; abc.ward_Name = model.ward_Name; abc.description = model.description; abc.address = model.address; abc.adddate = DateTime.Now; _ward.Add(abc); } else { int _id = Convert.ToInt32(model.pkid); tbl_Ward_master abc = _ward.Get(_id); abc.pkid = model.pkid; abc.prabhag_fkid = model.prabhag_fkid; abc.ward_Name = model.ward_Name; abc.description = model.description; abc.address = model.address; abc.adddate = DateTime.Now; _ward.Update(abc); } return(RedirectToAction("WardEntry", "SystemMaster")); } catch (Exception e) { Commonfunction.LogError(e, Server.MapPath("~/Log.txt")); ViewBag.Exception = e.Message; return(View()); } }
public ActionResult operatorshiftList() { weighingcontrolSystemEntities _db = new weighingcontrolSystemEntities(); var search = Request.Form.GetValues("search[value]")[0]; var draw = Request.Form.GetValues("draw").FirstOrDefault(); var start = Request.Form.GetValues("start").FirstOrDefault(); var length = Request.Form.GetValues("length").FirstOrDefault(); //Find Order Column string sortColumn = Request.Form.GetValues("columns[" + Request.Form.GetValues("order[0][column]").FirstOrDefault() + "][name]").FirstOrDefault(); string sortColumnDir = Request.Form.GetValues("order[0][dir]").FirstOrDefault(); int pageSize = length != null?Convert.ToInt32(length) : 0; int skip = start != null?Convert.ToInt32(start) : 0; int recordsTotal = 0; try { //dc.Configuration.LazyLoadingEnabled = false; // if your table is relational, contain foreign key var v = (from a in _db.tbl_operatorMapping select new { pkid = a.pkid, operatorName = _db.tbl_operatorDetails.Where(x => x.pkid == a.operator_fkId).FirstOrDefault().OperatorName, truckNo = _db.tbl_TruckDetails.Where(x => x.pkid == a.rfiDfkId).FirstOrDefault().truckNo, shiftName = _db.tbl_operatorshift.Where(x => x.pkid == a.shift_fkid).FirstOrDefault().shiftname, date = a.workingdate }); //SORT if (!string.IsNullOrEmpty(search) && !string.IsNullOrWhiteSpace(search)) { v = (from a in _db.tbl_operatorMapping select new { pkid = a.pkid, operatorName = _db.tbl_operatorDetails.Where(x => x.pkid == a.operator_fkId).FirstOrDefault().OperatorName, truckNo = _db.tbl_TruckDetails.Where(x => x.pkid == a.rfiDfkId).FirstOrDefault().truckNo, shiftName = _db.tbl_operatorshift.Where(x => x.pkid == a.shift_fkid).FirstOrDefault().shiftname, date = a.workingdate }).Where(x => x.operatorName.Contains(search) || x.truckNo.Contains(search)); } if (!(string.IsNullOrEmpty(sortColumn) && string.IsNullOrEmpty(sortColumnDir))) { v = v.OrderBy(sortColumn, sortColumnDir); //v = v.OrderBy(x=>x.orderfkid); } recordsTotal = v.Count(); var data = v.Skip(skip).Take(pageSize).ToList(); List <OperatorList> opelist = new List <OperatorList>(); foreach (var item in data) { OperatorList _obj = new OperatorList(); _obj.pkid = item.pkid; _obj.shiftName = item.shiftName; _obj.truckNo = item.truckNo; _obj.operatorName = item.operatorName; _obj.date = Convert.ToDateTime(item.date).ToShortDateString(); opelist.Add(_obj); } return(Json(new { draw = draw, recordsFiltered = recordsTotal, recordsTotal = recordsTotal, data = opelist }, JsonRequestBehavior.AllowGet)); } catch (Exception e) { Commonfunction.LogError(e, HttpContext.Server.MapPath("~/ErrorLog.txt")); return(Json(new { draw = draw, recordsFiltered = recordsTotal, recordsTotal = recordsTotal, data = "" }, JsonRequestBehavior.AllowGet)); } }
public ActionResult AddExam(tbl_Exam_Masterss model) { string exception = ""; int Exam_id = 0; try { if (model.pkid == 0) { tbl_Exam_Master abc = new tbl_Exam_Master(); abc.Exam_Name = model.Exam_Name; abc.ExamDuration = model.ExamDuration; abc.Passing_Percentage = model.Passing_Percentage; abc.Total_Marks = model.Total_Marks; abc.PassingMarks = model.PassingMarks; abc.Instruction = model.Instruction; abc.AttemptCount = model.AttemptCount; abc.StartDate = model.StartDate; abc.EndDate = model.EndDate; abc.DeclareResult = model.DeclareResult; abc.Negative_Masrking = model.Negative_Masrking; abc.RandonQuestion = model.RandonQuestion; abc.ResultAfterFinish = model.ResultAfterFinish; abc.Course_fkid = model.Course_fkid; abc.Division_fkid = model.Division_fkid; abc.Adddate = DateTime.Now; _Exam.Add(abc); Exam_id = _Exam.GetAll().Max(x => x.pkid); exception = "Save Successfully"; } else { int _id = Convert.ToInt32(model.pkid); tbl_Exam_Master abc = _Exam.Get(_id); abc.Exam_Name = model.Exam_Name; abc.ExamDuration = model.ExamDuration; abc.Passing_Percentage = model.Passing_Percentage; abc.Total_Marks = model.Total_Marks; abc.PassingMarks = model.PassingMarks; abc.Instruction = model.Instruction; abc.AttemptCount = model.AttemptCount; abc.StartDate = model.StartDate; abc.EndDate = model.EndDate; abc.DeclareResult = model.DeclareResult; abc.Negative_Masrking = model.Negative_Masrking; abc.RandonQuestion = model.RandonQuestion; abc.ResultAfterFinish = model.ResultAfterFinish; abc.Course_fkid = model.Course_fkid; abc.Division_fkid = model.Division_fkid; abc.Adddate = DateTime.Now; _Exam.Update(abc); exception = "Update Successfully"; Exam_id = _id; } if (model.RandonQuestion == false) { return(RedirectToAction("AddQuestionExam", "Exam", new { id = Exam_id, Exception = exception })); } else { return(RedirectToAction("AddAutomaticQuestionExam", "Exam", new { id = Exam_id, Exception = exception })); } } catch (Exception e) { Commonfunction.LogError(e, Server.MapPath("~/Log.txt")); exception = e.Message; return(RedirectToAction("ExamMaster", "Exam", new { Exception = exception })); } }
public ActionResult AddStudent(tbl_StudentMasterss model, HttpPostedFileBase Mcopy, HttpPostedFileBase BIODATA, HttpPostedFileBase Medicalcer) { WebFunction web = new WebFunction(); string exception = ""; try { if (model.pkid == 0) { tbl_StudentMaster abc = new tbl_StudentMaster(); if (Mcopy != null) { abc.Movement_copy = web.Storefile(Mcopy, 2); } if (BIODATA != null) { abc.BIODataForm = web.Storefile(BIODATA, 2); } if (Medicalcer != null) { abc.MedicalCertificate = web.Storefile(Medicalcer, 2); } abc.Course_fkid = model.Course_fkid; abc.Division_fkid = model.Division_fkid; abc.Force_fkid = model.Force_fkid; abc.UserName = model.UserName; abc.Password = model.Password; abc.ConfirmedPassword = model.ConfirmedPassword; abc.CommisionNo = model.CommisionNo; abc.DateComm = model.DateComm; abc.Rank = model.Rank; abc.FullName = model.FullName; abc.DateOfBirth = model.DateOfBirth; abc.PlaceOfBirth = model.PlaceOfBirth; abc.IdentificationMarks = model.IdentificationMarks; abc.Height = model.Height; abc.Weight = model.Weight; abc.ColorOfEye = model.ColorOfEye; abc.ColorOfHair = model.ColorOfHair; abc.Religion = model.Religion; abc.Caste = model.Caste; abc.Nationality = model.Nationality; abc.UnitAndLocation = model.UnitAndLocation; abc.HQGroup = model.HQGroup; abc.Directorate = model.Directorate; abc.State = model.State; abc.CourseSeries = model.CourseSeries; abc.ChestNo = model.ChestNo; abc.DUCFrom = model.DUCFrom; abc.DUCTo = model.DUCTo; abc.ArrivalInNCCOTA = model.ArrivalInNCCOTA; abc.MotherToughe = model.MotherToughe; abc.PresentAddress = model.PresentAddress; abc.ParmanentAddress = model.ParmanentAddress; abc.MaritalStatus = model.MaritalStatus; abc.NOKFullName = model.NOKFullName; abc.NOKAddress = model.NOKAddress; abc.NOKRelation = model.NOKRelation; abc.TeachingInstitideName = model.TeachingInstitideName; abc.TeachingSubject = model.TeachingSubject; abc.TeachingDateOfEmplyment = model.TeachingDateOfEmplyment; abc.TeachingEmpStatus = model.TeachingEmpStatus; abc.NCCorOTUMember = model.NCCorOTUMember; abc.WhichDivision = model.WhichDivision; abc.WhichForce = model.WhichForce; abc.TrainingPeriod = model.TrainingPeriod; abc.RankofNCC = model.RankofNCC; abc.MedicallyExamined = model.MedicallyExamined; abc.AlimentName = model.AlimentName; abc.MovementOrderNo = model.MovementOrderNo; abc.MovementDate = model.MovementDate; abc.Games = model.Games; abc.OtherQualification = model.OtherQualification; abc.ReadNCCActRules = model.ReadNCCActRules; abc.ReadNCCorDG = model.ReadNCCorDG; abc.ReadSyllabus = model.ReadSyllabus; abc.ReadHandbook = model.ReadHandbook; abc.ReadNCCCompPlanning = model.ReadNCCCompPlanning; abc.ReadNCCCompInstruction = model.ReadNCCCompInstruction; abc.DateOfPreCourseTraining = model.DateOfPreCourseTraining; abc.Place = model.Place; abc.AddedDate = DateTime.Now; _student.Add(abc); exception = "Save Successfully"; } else { int _id = Convert.ToInt32(model.pkid); tbl_StudentMaster abc = _student.Get(_id); if (Mcopy != null) { if (model.Movement_copy != null) { web.DeleteImage(model.Movement_copy); } abc.Movement_copy = web.Storefile(Mcopy, 2); } if (BIODATA != null) { if (model.BIODataForm != null) { web.DeleteImage(model.BIODataForm); } abc.BIODataForm = web.Storefile(BIODATA, 2); } if (Medicalcer != null) { if (model.MedicalCertificate != null) { web.DeleteImage(model.MedicalCertificate); } abc.MedicalCertificate = web.Storefile(Medicalcer, 2); } abc.Course_fkid = model.Course_fkid; abc.Division_fkid = model.Division_fkid; abc.Force_fkid = model.Force_fkid; abc.UserName = model.UserName; abc.Password = model.Password; abc.ConfirmedPassword = model.ConfirmedPassword; abc.CommisionNo = model.CommisionNo; abc.DateComm = model.DateComm; abc.Rank = model.Rank; abc.FullName = model.FullName; abc.DateOfBirth = model.DateOfBirth; abc.PlaceOfBirth = model.PlaceOfBirth; abc.IdentificationMarks = model.IdentificationMarks; abc.Height = model.Height; abc.Weight = model.Weight; abc.ColorOfEye = model.ColorOfEye; abc.ColorOfHair = model.ColorOfHair; abc.Religion = model.Religion; abc.Caste = model.Caste; abc.Nationality = model.Nationality; abc.UnitAndLocation = model.UnitAndLocation; abc.HQGroup = model.HQGroup; abc.Directorate = model.Directorate; abc.State = model.State; abc.CourseSeries = model.CourseSeries; abc.ChestNo = model.ChestNo; abc.DUCFrom = model.DUCFrom; abc.DUCTo = model.DUCTo; abc.ArrivalInNCCOTA = model.ArrivalInNCCOTA; abc.MotherToughe = model.MotherToughe; abc.PresentAddress = model.PresentAddress; abc.ParmanentAddress = model.ParmanentAddress; abc.MaritalStatus = model.MaritalStatus; abc.NOKFullName = model.NOKFullName; abc.NOKAddress = model.NOKAddress; abc.NOKRelation = model.NOKRelation; abc.TeachingInstitideName = model.TeachingInstitideName; abc.TeachingSubject = model.TeachingSubject; abc.TeachingDateOfEmplyment = model.TeachingDateOfEmplyment; abc.TeachingEmpStatus = model.TeachingEmpStatus; abc.NCCorOTUMember = model.NCCorOTUMember; abc.WhichDivision = model.WhichDivision; abc.WhichForce = model.WhichForce; abc.TrainingPeriod = model.TrainingPeriod; abc.RankofNCC = model.RankofNCC; abc.MedicallyExamined = model.MedicallyExamined; abc.AlimentName = model.AlimentName; abc.MovementOrderNo = model.MovementOrderNo; abc.MovementDate = model.MovementDate; abc.Games = model.Games; abc.OtherQualification = model.OtherQualification; abc.ReadNCCActRules = model.ReadNCCActRules; abc.ReadNCCorDG = model.ReadNCCorDG; abc.ReadSyllabus = model.ReadSyllabus; abc.ReadHandbook = model.ReadHandbook; abc.ReadNCCCompPlanning = model.ReadNCCCompPlanning; abc.ReadNCCCompInstruction = model.ReadNCCCompInstruction; abc.DateOfPreCourseTraining = model.DateOfPreCourseTraining; abc.Place = model.Place; abc.AddedDate = DateTime.Now; _student.Update(abc); exception = "Updated Successfully"; } return(RedirectToAction("StudentMaster", "Student", new { Exception = exception })); } catch (Exception e) { Commonfunction.LogError(e, Server.MapPath("~/Log.txt")); exception = e.Message; return(RedirectToAction("StudentMaster", "Student", new { Exception = exception })); } }
public ActionResult getTruckWorkingList() { weighingcontrolSystemEntities _db = new weighingcontrolSystemEntities(); var search = Request.Form.GetValues("search[value]")[0]; var draw = Request.Form.GetValues("draw").FirstOrDefault(); var start = Request.Form.GetValues("start").FirstOrDefault(); var length = Request.Form.GetValues("length").FirstOrDefault(); //Find Order Column string sortColumn = Request.Form.GetValues("columns[" + Request.Form.GetValues("order[0][column]").FirstOrDefault() + "][name]").FirstOrDefault(); string sortColumnDir = Request.Form.GetValues("order[0][dir]").FirstOrDefault(); int pageSize = length != null?Convert.ToInt32(length) : 0; int skip = start != null?Convert.ToInt32(start) : 0; int recordsTotal = 0; //DateTime dtcurr = Convert.ToDateTime("2017-04-27"); try { DateTime dtcurr = DateTime.Now.Date; List <importData> importData = new List <importData>(); var data = (from report in _db.tbl_storemachineData where EntityFunctions.TruncateTime(report.dateTimeMachine) <= dtcurr && report.truckRFIDOUT != "" select new { report.pkid, report.ScaleId, report.truckRFIDIN, report.truckRFIDOUT, report.fairWeight, report.operatorRFID, report.grossWeight, report.netWeight, report.status, report.dateTimeMachine, report.outPkid, report.outTime, report.outGrossWeight, report.outLocation, report.shiftTime }).ToList(); foreach (var item in data.Skip(skip).Take(pageSize)) { importData _obj = new importData(); _obj.pkid = item.pkid; _obj.ScaleId = item.ScaleId; if (item.truckRFIDIN != null && item.truckRFIDIN != "") { _obj.truckNo = (from rfId1 in _db.tbl_rfidDetails where rfId1.RFIDNUMBER == item.truckRFIDIN join truckMap in _db.tbl_truckMapping on rfId1.pkid equals truckMap.rfif_fkId join truckdetails in _db.tbl_TruckDetails on truckMap.truckFKId equals truckdetails.pkid select new { truckdetails.truckNo }).FirstOrDefault().truckNo; } else { _obj.truckNo = (from rfId1 in _db.tbl_rfidDetails where rfId1.RFIDNUMBER == item.truckRFIDOUT join truckMap in _db.tbl_truckMapping on rfId1.pkid equals truckMap.rfif_fkId join truckdetails in _db.tbl_TruckDetails on truckMap.truckFKId equals truckdetails.pkid select new { truckdetails.truckNo }).FirstOrDefault().truckNo; } _obj.rfid = item.operatorRFID; _obj.netweight = item.netWeight.ToString(); _obj.tareWeight = item.fairWeight.ToString(); _obj.grossWeight = item.grossWeight.ToString(); _obj.status = item.status; _obj.outLocation = item.outLocation; _obj.shift = item.shiftTime.ToString(); _obj.pkidOut = (long?)item.outPkid ?? 0; try { _obj.grossWeightOut = (decimal)item.outGrossWeight; _obj.outTime = (DateTime)item.outTime; } catch { } _obj.dateTimeMachine = (DateTime)item.dateTimeMachine; importData.Add(_obj); } List <ExcelExport> lsitExcel = new List <ExcelExport>(); int i = 1; foreach (var item in importData) { ExcelExport _obj = new ExcelExport(); _obj.SRNO = i; _obj.TRUCKNO = item.truckNo; _obj.inLocation = item.ScaleId; try { _obj.CAPACITY = _db.tbl_TruckDetails.Where(x => x.truckNo == item.truckNo).FirstOrDefault().Contact; } catch { _obj.CAPACITY = ""; } _obj.TAREWEIGHT = item.tareWeight; _obj.GROSSWEIGHT = item.grossWeight; if (item.rfid != null && item.rfid != "") { try { long rfidpkid = _db.tbl_rfidDetails.Where(x => x.RFIDNUMBER == item.rfid).FirstOrDefault().pkid; long operatorPkid = (long)_db.tbl_operatorMapping.Where(x => x.rfiDfkId == rfidpkid).FirstOrDefault().operator_fkId; long ContactorId = (long)_db.tbl_operatorMapiingWithContactor.Where(x => x.operatorid == operatorPkid).FirstOrDefault().contactorId; _obj.CONTRACTOR = _db.tbl_contractor.Where(x => x.pkid == ContactorId).FirstOrDefault().contratorName; _obj.OPERATOR = _db.tbl_operatorDetails.Where(x => x.pkid == operatorPkid).FirstOrDefault().OperatorName; } catch { } } _obj.NETWEIGHT = item.netweight; try { _obj.FILL_FACTOR = (Convert.ToDecimal(((Convert.ToDecimal(item.netweight)) / Convert.ToDecimal(_db.tbl_TruckDetails.Where(x => x.truckNo == item.truckNo).FirstOrDefault().Contact))) * 100).ToString("0.00"); } catch { _obj.FILL_FACTOR = "0"; } _obj.TIME = item.dateTimeMachine; _obj.STATUS = item.ScaleId; _obj.outGrossWeight = item.grossWeightOut.ToString(); _obj.outpkid = item.pkidOut; _obj.OutTime = item.outTime; _obj.outLocation = item.outLocation; long shiftId = 0; if (item.outTime != default(DateTime)) { TimeSpan curr = item.outTime.TimeOfDay; var shifdata = _db.tbl_operatorshift.ToList(); foreach (var sht in shifdata) { if ((curr >= sht.shiftstsrtTime) && (curr <= sht.shiftEndTime)) { _obj.shift = sht.shiftname; shiftId = sht.pkid; } } } else { TimeSpan curr = item.dateTimeMachine.TimeOfDay; var shifdata = _db.tbl_operatorshift.ToList(); foreach (var sht in shifdata) { if ((curr >= sht.shiftstsrtTime) && (curr <= sht.shiftEndTime)) { _obj.shift = sht.shiftname; shiftId = sht.pkid; } } } if (_obj.shift != "") { long truckPkid = 36; try { truckPkid = _db.tbl_TruckDetails.Where(x => x.truckNo == _obj.TRUCKNO).FirstOrDefault().pkid; } catch { truckPkid = 36; } DateTime workingdate = _obj.TIME.Date; if (_db.tbl_operatorMapping.Where(x => x.shift_fkid == shiftId && x.rfiDfkId == truckPkid && x.workingdate == workingdate).Count() > 0) { long operatorPkid = (long)_db.tbl_operatorMapping.Where(x => x.shift_fkid == shiftId && x.rfiDfkId == truckPkid && x.workingdate == workingdate).FirstOrDefault().operator_fkId; long ContactorId = (long)_db.tbl_operatorMapiingWithContactor.Where(x => x.operatorid == operatorPkid).FirstOrDefault().contactorId; _obj.CONTRACTOR = _db.tbl_contractor.Where(x => x.pkid == ContactorId).FirstOrDefault().contratorName; _obj.OPERATOR = _db.tbl_operatorDetails.Where(x => x.pkid == operatorPkid).FirstOrDefault().OperatorName; } else { if (_db.tbl_operatorMapping.Where(x => x.rfiDfkId == truckPkid && x.shift_fkid == shiftId).Count() > 0) { try { long maxId = _db.tbl_operatorMapping.Where(x => x.rfiDfkId == truckPkid && x.shift_fkid == shiftId).Max(x => x.pkid); long operatorPkid = (long)_db.tbl_operatorMapping.Where(x => x.pkid == maxId).FirstOrDefault().operator_fkId; long ContactorId = (long)_db.tbl_operatorMapiingWithContactor.Where(x => x.operatorid == operatorPkid).FirstOrDefault().contactorId; _obj.CONTRACTOR = _db.tbl_contractor.Where(x => x.pkid == ContactorId).FirstOrDefault().contratorName; _obj.OPERATOR = _db.tbl_operatorDetails.Where(x => x.pkid == operatorPkid).FirstOrDefault().OperatorName; } catch { _obj.CONTRACTOR = ""; _obj.OPERATOR = ""; } } else { _obj.CONTRACTOR = ""; _obj.OPERATOR = ""; } } } lsitExcel.Add(_obj); i++; } List <dasBordDetaisModal> dasboardModel = new List <dasBordDetaisModal>(); foreach (var dm in lsitExcel.GroupBy(x => new { x.TRUCKNO }).ToList()) { dasBordDetaisModal dmObj = new dasBordDetaisModal(); var firstRow = dm.FirstOrDefault(); dmObj.TruckNo = firstRow.TRUCKNO; if (lsitExcel.Where(x => x.TRUCKNO == firstRow.TRUCKNO && x.shift == "Shift A").Count() > 0) { dmObj.TotalTonShiftA = (decimal)lsitExcel.Where(x => x.TRUCKNO == firstRow.TRUCKNO && x.shift == "Shift A").Sum(x => decimal.Parse(x.NETWEIGHT)); dmObj.noTripShifA = lsitExcel.Where(x => x.TRUCKNO == firstRow.TRUCKNO && x.shift == "Shift A").Count(); dmObj.ToltalFillFactorA = lsitExcel.Where(x => x.TRUCKNO == firstRow.TRUCKNO && x.shift == "Shift A").Sum(x => decimal.Parse(x.FILL_FACTOR)) / dmObj.noTripShifA; } if (lsitExcel.Where(x => x.TRUCKNO == firstRow.TRUCKNO && x.shift == "Shift B").Count() > 0) { dmObj.noTripShifB = lsitExcel.Where(x => x.TRUCKNO == firstRow.TRUCKNO && x.shift == "Shift B").Count(); dmObj.TotalTonShiftB = (decimal)lsitExcel.Where(x => x.TRUCKNO == firstRow.TRUCKNO && x.shift == "Shift B").Sum(x => decimal.Parse(x.NETWEIGHT)); dmObj.ToltalFillFactorB = lsitExcel.Where(x => x.TRUCKNO == firstRow.TRUCKNO && x.shift == "Shift A").Sum(x => decimal.Parse(x.FILL_FACTOR)) / dmObj.noTripShifB; } if (lsitExcel.Where(x => x.TRUCKNO == firstRow.TRUCKNO && x.shift == "Shift C").Count() > 0) { dmObj.TotalTonShiftC = (decimal)lsitExcel.Where(x => x.TRUCKNO == firstRow.TRUCKNO && x.shift == "Shift C").Sum(x => decimal.Parse(x.NETWEIGHT)); dmObj.noTripShifC = lsitExcel.Where(x => x.TRUCKNO == firstRow.TRUCKNO && x.shift == "Shift C").Count(); dmObj.ToltalFillFactorC = lsitExcel.Where(x => x.TRUCKNO == firstRow.TRUCKNO && x.shift == "Shift A").Sum(x => decimal.Parse(x.FILL_FACTOR)) / dmObj.noTripShifC; //dmObj.ToltalFillFactorC = (decimal)lsitExcel.Where(x => x.TRUCKNO == firstRow.TRUCKNO && x.shift == "Shift C").Sum(x => decimal.Parse(x.FILL_FACTOR)); } dmObj.noTripShifFD = dmObj.noTripShifC + dmObj.noTripShifB + dmObj.noTripShifA; dmObj.TotalTonShiftFD = dmObj.TotalTonShiftC + dmObj.TotalTonShiftB + dmObj.TotalTonShiftA; dmObj.ToltalFillFactorFD = dmObj.ToltalFillFactorC + dmObj.ToltalFillFactorB + dmObj.ToltalFillFactorA; dasboardModel.Add(dmObj); } try { //dc.Configuration.LazyLoadingEnabled = false; // if your table is relational, contain foreign key var v = (from a in dasboardModel select a); //SORT if (!string.IsNullOrEmpty(search) && !string.IsNullOrWhiteSpace(search)) { v = (from b in dasboardModel.Where(x => x.TruckNo.Contains(search)) select b); } if (!(string.IsNullOrEmpty(sortColumn) && string.IsNullOrEmpty(sortColumnDir))) { v = v.OrderBy(sortColumn, sortColumnDir); //v = v.OrderBy(x=>x.orderfkid); } recordsTotal = data.Count(); var dataList = v.ToList(); return(Json(new { draw = draw, recordsFiltered = recordsTotal, recordsTotal = recordsTotal, data = dataList }, JsonRequestBehavior.AllowGet)); } catch (Exception e) { Commonfunction.LogError(e, HttpContext.Server.MapPath("~/ErrorLog.txt")); return(Json(new { draw = draw, recordsFiltered = recordsTotal, recordsTotal = recordsTotal, data = "" }, JsonRequestBehavior.AllowGet)); } } catch (Exception e) { ViewBag.Msg = "Your RFID and Operator Mapping Not Done..."; Commonfunction.LogError(e, HttpContext.Server.MapPath("~/ErrorLog.txt")); return(Json(new { draw = draw, recordsFiltered = recordsTotal, recordsTotal = recordsTotal, data = "" }, JsonRequestBehavior.AllowGet)); } }
public ActionResult AddQuestion(QuestionMaster model) { WebFunction web = new WebFunction(); string exception = ""; try { if (model.pkid == 0) { tbl_QuestionMaster abc = new tbl_QuestionMaster(); abc.subjecttype_fkid = model.Questtype_fkid; abc.Question = model.Question; abc.Explaination = model.Explaination; abc.Subject_fkid = model.Subject_fkid; abc.Division_fkid = model.Division_fkid; abc.hint = model.hint; abc.SelectLevel = model.SelectLevel; abc.NegativeMarks = model.NegativeMarks; abc.Marks = model.Marks; abc.Status = 1; abc.Adddate = DateTime.Now; abc.lastModified = DateTime.Now; _question.Add(abc); int Maxid = _question.GetAll().Max(x => x.pkid); if (model.Questtype_fkid == 5) { foreach (var item in model.MATContent) { if (!string.IsNullOrWhiteSpace(item.FirstColoumn) && !string.IsNullOrWhiteSpace(item.OppositeColoumn) && !string.IsNullOrWhiteSpace(item.AnsweColoumn)) { tbl_MatchContentQuestionMaster MA = new tbl_MatchContentQuestionMaster(); MA.Ques_fkid = Maxid; MA.FirstColoumn = item.FirstColoumn; MA.OppositeColoumn = item.OppositeColoumn; MA.AnsweColoumn = item.AnsweColoumn; MA.LastDatetime = DateTime.Now; _Matc.Add(MA); } } } else if (model.Questtype_fkid == 7) { foreach (var item in model.FULLF) { if (!string.IsNullOrWhiteSpace(item.FirstColoumn) && !string.IsNullOrWhiteSpace(item.AnsweColoumn)) { tbl_MatchContentQuestionMaster MA = new tbl_MatchContentQuestionMaster(); MA.Ques_fkid = Maxid; MA.FirstColoumn = item.FirstColoumn; MA.AnsweColoumn = item.AnsweColoumn; MA.LastDatetime = DateTime.Now; _Matc.Add(MA); } } } else if (model.Questtype_fkid == 6) { tbl_AnswerMaster ANS = new tbl_AnswerMaster(); ANS.Ques_fkid = _question.GetAll().Max(x => x.pkid); ANS.Questtype_fkid = model.Questtype_fkid; var httpRequest = System.Web.HttpContext.Current.Request; if (httpRequest.Files.Count > 0) { var docfiles = new List <string>(); for (int i = 0; i <= httpRequest.Files.Count - 1; i++) { string path = ""; var postedFile = httpRequest.Files[i]; if (i == 0) { DateTime date = DateTime.Now; string dates = date.Day.ToString() + date.Month.ToString() + date.Year.ToString() + date.Hour.ToString() + date.Minute.ToString() + date.Second.ToString() + date.ToString("tt"); ANS.Answer1 = "/UploadFiles/QuestionImage/" + dates + postedFile.FileName; path = Path.Combine(System.Web.HttpContext.Current.Server.MapPath("/UploadFiles/QuestionImage/"), dates + postedFile.FileName); postedFile.SaveAs(path); } else if (i == 1) { DateTime date = DateTime.Now; string dates = date.Day.ToString() + date.Month.ToString() + date.Year.ToString() + date.Hour.ToString() + date.Minute.ToString() + date.Second.ToString() + date.ToString("tt"); ANS.Answer2 = "/UploadFiles/QuestionImage/" + dates + postedFile.FileName; path = Path.Combine(System.Web.HttpContext.Current.Server.MapPath("/UploadFiles/QuestionImage/"), dates + postedFile.FileName); postedFile.SaveAs(path); } else if (i == 2) { DateTime date = DateTime.Now; string dates = date.Day.ToString() + date.Month.ToString() + date.Year.ToString() + date.Hour.ToString() + date.Minute.ToString() + date.Second.ToString() + date.ToString("tt"); ANS.Answer3 = "/UploadFiles/QuestionImage/" + dates + postedFile.FileName; path = Path.Combine(System.Web.HttpContext.Current.Server.MapPath("/UploadFiles/QuestionImage/"), dates + postedFile.FileName); postedFile.SaveAs(path); } else if (i == 3) { DateTime date = DateTime.Now; string dates = date.Day.ToString() + date.Month.ToString() + date.Year.ToString() + date.Hour.ToString() + date.Minute.ToString() + date.Second.ToString() + date.ToString("tt"); ANS.Answer4 = "/UploadFiles/QuestionImage/" + dates + postedFile.FileName; path = Path.Combine(System.Web.HttpContext.Current.Server.MapPath("/UploadFiles/QuestionImage/"), dates + postedFile.FileName); postedFile.SaveAs(path); } } } ANS.CorrectAnswer = model.CorrectAnswerDD; ANS.BlanckSpace = model.BlanckSpace; ANS.TrueFalse = model.TrueFalse; ANS.SubAnswer = model.SubAnswer; ANS.status = 1; ANS.Adddate = DateTime.Now; ANS.lastmodified = DateTime.Now; _answer.Add(ANS); exception = "Save Successfully"; } else { tbl_AnswerMaster ANS = new tbl_AnswerMaster(); ANS.Ques_fkid = _question.GetAll().Max(x => x.pkid); ANS.Questtype_fkid = model.Questtype_fkid; ANS.Answer1 = model.Answer1; ANS.Answer2 = model.Answer2; ANS.Answer3 = model.Answer3; ANS.Answer4 = model.Answer4; ANS.CorrectAnswer = model.CorrectAnswerDD; ANS.BlanckSpace = model.BlanckSpace; ANS.TrueFalse = model.TrueFalse; ANS.SubAnswer = model.SubAnswer; ANS.status = 1; ANS.Adddate = DateTime.Now; ANS.lastmodified = DateTime.Now; _answer.Add(ANS); exception = "Save Successfully"; } } else { int _id = Convert.ToInt32(model.pkid); tbl_QuestionMaster abc = _question.Get(_id); abc.subjecttype_fkid = model.Questtype_fkid; abc.Division_fkid = model.Division_fkid; abc.Question = model.Question; abc.Explaination = model.Explaination; abc.Subject_fkid = model.Subject_fkid; abc.Division_fkid = model.Division_fkid; abc.hint = model.hint; abc.SelectLevel = model.SelectLevel; abc.SelectLevel = model.SelectLevel; abc.NegativeMarks = model.NegativeMarks; abc.Marks = model.Marks; abc.Status = model.Status; abc.Adddate = model.Adddate; abc.lastModified = DateTime.Now; _question.Update(abc); if (model.Questtype_fkid == 5) { foreach (var item in model.MATContent) { if (!string.IsNullOrWhiteSpace(item.FirstColoumn) && !string.IsNullOrWhiteSpace(item.OppositeColoumn) && !string.IsNullOrWhiteSpace(item.AnsweColoumn)) { tbl_MatchContentQuestionMaster MA = _Matc.Get(item.pkid); MA.FirstColoumn = item.FirstColoumn; MA.OppositeColoumn = item.OppositeColoumn; MA.AnsweColoumn = item.AnsweColoumn; MA.LastDatetime = DateTime.Now; _Matc.Update(MA); } } } else if (model.Questtype_fkid == 7) { foreach (var item in model.FULLF) { if (!string.IsNullOrWhiteSpace(item.FirstColoumn) && !string.IsNullOrWhiteSpace(item.AnsweColoumn)) { tbl_MatchContentQuestionMaster MA = _Matc.Get(item.pkid); MA.FirstColoumn = item.FirstColoumn; MA.AnsweColoumn = item.AnsweColoumn; MA.LastDatetime = DateTime.Now; _Matc.Update(MA); } } } else if (model.Questtype_fkid == 6) { tbl_AnswerMaster ANS = _answer.GetAll().Where(x => x.Ques_fkid == _id).FirstOrDefault(); ANS.Ques_fkid = _id; ANS.Questtype_fkid = model.Questtype_fkid; var httpRequest = System.Web.HttpContext.Current.Request; if (httpRequest.Files.Count > 0) { var docfiles = new List <string>(); for (int i = 0; i <= httpRequest.Files.Count - 1; i++) { string path = ""; var postedFile = httpRequest.Files[i]; if (i == 0) { if (System.IO.File.Exists(ANS.Answer1)) { System.IO.File.Delete(ANS.Answer1); } DateTime date = DateTime.Now; string dates = date.Day.ToString() + date.Month.ToString() + date.Year.ToString() + date.Hour.ToString() + date.Minute.ToString() + date.Second.ToString() + date.ToString("tt"); ANS.Answer1 = "/UploadFiles/QuestionImage/" + dates + postedFile.FileName; path = Path.Combine(System.Web.HttpContext.Current.Server.MapPath("/UploadFiles/QuestionImage/"), dates + postedFile.FileName); postedFile.SaveAs(path); } else if (i == 1) { if (System.IO.File.Exists(ANS.Answer2)) { System.IO.File.Delete(ANS.Answer2); } DateTime date = DateTime.Now; string dates = date.Day.ToString() + date.Month.ToString() + date.Year.ToString() + date.Hour.ToString() + date.Minute.ToString() + date.Second.ToString() + date.ToString("tt"); ANS.Answer2 = "/UploadFiles/QuestionImage/" + dates + postedFile.FileName; path = Path.Combine(System.Web.HttpContext.Current.Server.MapPath("/UploadFiles/QuestionImage/"), dates + postedFile.FileName); postedFile.SaveAs(path); } else if (i == 2) { if (System.IO.File.Exists(ANS.Answer3)) { System.IO.File.Delete(ANS.Answer3); } DateTime date = DateTime.Now; string dates = date.Day.ToString() + date.Month.ToString() + date.Year.ToString() + date.Hour.ToString() + date.Minute.ToString() + date.Second.ToString() + date.ToString("tt"); ANS.Answer3 = "/UploadFiles/QuestionImage/" + dates + postedFile.FileName; path = Path.Combine(System.Web.HttpContext.Current.Server.MapPath("/UploadFiles/QuestionImage/"), dates + postedFile.FileName); postedFile.SaveAs(path); } else if (i == 3) { if (System.IO.File.Exists(ANS.Answer4)) { System.IO.File.Delete(ANS.Answer4); } DateTime date = DateTime.Now; string dates = date.Day.ToString() + date.Month.ToString() + date.Year.ToString() + date.Hour.ToString() + date.Minute.ToString() + date.Second.ToString() + date.ToString("tt"); ANS.Answer4 = "/UploadFiles/QuestionImage/" + dates + postedFile.FileName; path = Path.Combine(System.Web.HttpContext.Current.Server.MapPath("/UploadFiles/QuestionImage/"), dates + postedFile.FileName); postedFile.SaveAs(path); } } } ANS.CorrectAnswer = model.CorrectAnswerDD; ANS.BlanckSpace = model.BlanckSpace; ANS.TrueFalse = model.TrueFalse; ANS.SubAnswer = model.SubAnswer; ANS.status = 1; ANS.Adddate = DateTime.Now; ANS.lastmodified = DateTime.Now; _answer.Update(ANS); exception = "Save Successfully"; } else { tbl_AnswerMaster ANS = _answer.GetAll().Where(x => x.Ques_fkid == model.pkid).FirstOrDefault(); ANS.Questtype_fkid = model.Questtype_fkid; ANS.Answer1 = model.Answer1; ANS.Answer2 = model.Answer2; ANS.Answer3 = model.Answer3; ANS.Answer4 = model.Answer4; ANS.CorrectAnswer = model.CorrectAnswerDD; ANS.BlanckSpace = model.BlanckSpace; ANS.TrueFalse = model.TrueFalse; ANS.SubAnswer = model.SubAnswer; ANS.status = 1; ANS.Adddate = DateTime.Now; ANS.lastmodified = DateTime.Now; _answer.Update(ANS); } exception = "Updated Successfully"; } return(RedirectToAction("AddQuestion", "SubjectGroup", new { Exception = exception })); } catch (Exception e) { Commonfunction.LogError(e, Server.MapPath("~/Log.txt")); exception = e.Message; return(RedirectToAction("AddQuestion", "SubjectGroup", new { Exception = exception })); } }
public ActionResult PIOCMaster(tbl_PIOC_Arrival_DataMasterss model, HttpPostedFileBase MED, HttpPostedFileBase CHR, HttpPostedFileBase SIG) { try { if (model.pkid == 0) { tbl_PIOC_Arrival_DataMaster abc = new tbl_PIOC_Arrival_DataMaster(); if (MED != null) { abc.MedicalCertificate = web.Storefile(MED, 3); } if (CHR != null) { abc.CharacterCertificate = web.Storefile(CHR, 3); } if (SIG != null) { abc.SignofIndividual = web.Storefile(SIG, 3); } abc.Course_fkid = model.Course_fkid; abc.Division_fkid = model.Division_fkid; abc.Force_fkid = model.Force_fkid; abc.Session_fkid = model.Session_fkid; abc.Student_fkid = model.Student_fkid; abc.ChestNo = model.ChestNo; abc.ArmyNo = model.ArmyNo; abc.Rank = model.Rank; abc.ParentUnit = model.ParentUnit; abc.Records = model.Records; abc.NCCUnit = model.NCCUnit; abc.DateOfArrival = model.DateOfArrival; abc.DTE = model.DTE; abc.DateofDEP = model.DateofDEP; abc.MoveOrder = model.MoveOrder; abc.IdentityCard = model.IdentityCard; abc.MobileNo = model.MobileNo; abc.IMEIno = model.IMEIno; abc.AddedDate = DateTime.Now; abc.LastModifiedDate = DateTime.Now; _PIOCMaster.Add(abc); } else { tbl_PIOC_Arrival_DataMaster abc = _PIOCMaster.Get(model.pkid); if (CHR != null) { if (model.CharacterCertificate != null) { web.DeleteImage(model.CharacterCertificate); } abc.CharacterCertificate = web.Storefile(CHR, 3); } if (MED != null) { if (model.MedicalCertificate != null) { web.DeleteImage(model.MedicalCertificate); } abc.MedicalCertificate = web.Storefile(MED, 3); } if (SIG != null) { if (model.SignofIndividual != null) { web.DeleteImage(model.SignofIndividual); } abc.SignofIndividual = web.Storefile(SIG, 3); } abc.Course_fkid = model.Course_fkid; abc.Division_fkid = model.Division_fkid; abc.Force_fkid = model.Force_fkid; abc.Session_fkid = model.Session_fkid; abc.Student_fkid = model.Student_fkid; abc.ChestNo = model.ChestNo; abc.ArmyNo = model.ArmyNo; abc.Rank = model.Rank; abc.ParentUnit = model.ParentUnit; abc.Records = model.Records; abc.NCCUnit = model.NCCUnit; abc.DateOfArrival = model.DateOfArrival; abc.DTE = model.DTE; abc.DateofDEP = model.DateofDEP; abc.MoveOrder = model.MoveOrder; abc.IdentityCard = model.IdentityCard; abc.MobileNo = model.MobileNo; abc.IMEIno = model.IMEIno; abc.AddedDate = model.AddedDate; abc.LastModifiedDate = DateTime.Now; _PIOCMaster.Update(abc); } return(RedirectToAction("PIOCMaster", "ArrivalSchema")); } catch (Exception e) { Commonfunction.LogError(e, Server.MapPath("~/Log.txt")); return(RedirectToAction("PIOCMaster", "ArrivalSchema")); } }
public ActionResult REFMaster(tbl_REF_Arrival_DataMasterss model, HttpPostedFileBase MED, HttpPostedFileBase RIS, HttpPostedFileBase SERCER, HttpPostedFileBase SIG) { try { if (model.pkid == 0) { tbl_REF_Arrival_DataMaster abc = new tbl_REF_Arrival_DataMaster(); if (MED != null) { abc.MedicalCertificate = web.Storefile(MED, 3); } if (RIS != null) { abc.RiskCertificate = web.Storefile(RIS, 3); } abc.pkid = model.pkid; abc.Course_fkid = model.Course_fkid; abc.Division_fkid = model.Division_fkid; abc.Force_fkid = model.Force_fkid; abc.Session_fkid = model.Session_fkid; abc.Student_fkid = model.Student_fkid; abc.ChestNo = model.ChestNo; abc.NCCNo = model.NCCNo; abc.Rank = model.Rank; abc.NCCunit = model.NCCunit; abc.GPHQ = model.GPHQ; abc.DTE = model.DTE; abc.MoveOrder = model.MoveOrder; abc.NominalRoll = model.NominalRoll; abc.IdentemnityBond = model.IdentemnityBond; abc.DetailsService = model.DetailsService; abc.AddedDate = DateTime.Now; abc.LastModifiedDate = DateTime.Now; if (SERCER != null) { abc.MedicalCertificate = web.Storefile(MED, 3); } if (SIG != null) { abc.SignOfIndivisual = web.Storefile(SIG, 3); } _REFMaster.Add(abc); } else { tbl_REF_Arrival_DataMaster abc = _REFMaster.Get(model.pkid); if (MED != null) { if (model.MedicalCertificate != null) { web.DeleteImage(model.MedicalCertificate); } abc.MedicalCertificate = web.Storefile(MED, 3); } if (RIS != null) { if (model.RiskCertificate != null) { web.DeleteImage(model.RiskCertificate); } abc.RiskCertificate = web.Storefile(RIS, 3); } if (SERCER != null) { if (model.Copyofpreviouscertific != null) { web.DeleteImage(model.Copyofpreviouscertific); } abc.Copyofpreviouscertific = web.Storefile(SERCER, 3); } if (SIG != null) { if (model.SignOfIndivisual != null) { web.DeleteImage(model.SignOfIndivisual); } abc.SignOfIndivisual = web.Storefile(SIG, 3); } abc.Course_fkid = model.Course_fkid; abc.Division_fkid = model.Division_fkid; abc.Force_fkid = model.Force_fkid; abc.Session_fkid = model.Session_fkid; abc.Student_fkid = model.Student_fkid; abc.ChestNo = model.ChestNo; abc.NCCNo = model.NCCNo; abc.Rank = model.Rank; abc.NCCunit = model.NCCunit; abc.GPHQ = model.GPHQ; abc.DTE = model.DTE; abc.MoveOrder = model.MoveOrder; abc.NominalRoll = model.NominalRoll; abc.IdentemnityBond = model.IdentemnityBond; abc.DetailsService = model.DetailsService; abc.AddedDate = model.AddedDate; abc.LastModifiedDate = DateTime.Now; _REFMaster.Update(abc); } return(RedirectToAction("REFMaster", "ArrivalSchema")); } catch (Exception e) { Commonfunction.LogError(e, Server.MapPath("~/Log.txt")); return(RedirectToAction("REFMaster", "ArrivalSchema")); } }
public ActionResult UploadExcel(QuestionMaster model) { ViewBag.QueTypeList = new SelectList(_subtype.GetAll().Where(x => x.pkid != 4).ToList(), "pkid", "Questiontype"); ViewBag.CourseList = new SelectList(_course.GetAll(), "pkid", "CourseName"); string exception = ""; try { WebFunction comm = new WebFunction(); HttpPostedFileBase FileUpload = Request.Files[0]; DataTable dt = new DataTable(); string alert = "", msg = ""; if (FileUpload != null) { dt = comm.GetExcesData(FileUpload); // List<tbl_MonthlyLibility> monthlyLibalityList = new List<tbl_MonthlyLibility>(); int i = 1; foreach (DataRow dr in dt.Rows.Cast <DataRow>().Skip(2)) { if (model.Questtype_fkid == 5) { if (FileUpload.FileName == "Match_Content5.xlsx") { tbl_QuestionMaster QUESTION = new tbl_QuestionMaster(); var q = dr[1].ToString(); var A = dr[2].ToString(); QUESTION.subjecttype_fkid = Convert.ToInt32(dr[0]); QUESTION.Question = dr[1].ToString(); QUESTION.Explaination = dr[2].ToString(); QUESTION.Subject_fkid = Convert.ToInt32(dr[3]); QUESTION.Division_fkid = Convert.ToInt32(dr[4]); QUESTION.hint = dr[5].ToString(); QUESTION.Marks = Convert.ToDecimal(dr[6]); try { QUESTION.NegativeMarks = Convert.ToDecimal(dr[7]); } catch { QUESTION.NegativeMarks = 0; } QUESTION.SelectLevel = Convert.ToInt32(dr[8]); QUESTION.Adddate = DateTime.Now; QUESTION.Status = 1; QUESTION.lastModified = DateTime.Now; _question.Add(QUESTION); int _Maxid = _question.GetAll().Max(x => x.pkid); for (int p = 1; p <= 10; p++) { tbl_MatchContentQuestionMaster ANSWER = new tbl_MatchContentQuestionMaster(); int AA = 0; int BB = 0; int CC = 0; if (p == 1) { AA = 9; BB = 10; CC = 11; } else if (p == 2) { AA = 12; BB = 13; CC = 14; } else if (p == 3) { AA = 15; BB = 16; CC = 17; } else if (p == 4) { AA = 18; BB = 19; CC = 20; } else if (p == 5) { AA = 21; BB = 22; CC = 23; } else if (p == 6) { AA = 24; BB = 25; CC = 26; } else if (p == 7) { AA = 27; BB = 28; CC = 29; } else if (p == 8) { AA = 30; BB = 31; CC = 32; } else if (p == 9) { AA = 33; BB = 34; CC = 35; } else { AA = 36; BB = 37; CC = 38; } ANSWER.Ques_fkid = _Maxid; ANSWER.FirstColoumn = dr[AA].ToString(); ANSWER.OppositeColoumn = dr[BB].ToString(); ANSWER.AnsweColoumn = dr[CC].ToString(); ANSWER.LastDatetime = DateTime.Now; if (!string.IsNullOrWhiteSpace(ANSWER.FirstColoumn) && !string.IsNullOrWhiteSpace(ANSWER.OppositeColoumn) && !string.IsNullOrWhiteSpace(ANSWER.AnsweColoumn)) { _Matc.Add(ANSWER); } } } else { exception = "Select Correct File."; return(RedirectToAction("UploadExcel", "SubjectGroup", new { Exception = exception })); } } else if (model.Questtype_fkid == 7) { if (FileUpload.FileName == "Full_Form7.xlsx") { tbl_QuestionMaster QUESTION = new tbl_QuestionMaster(); var q = dr[1].ToString(); var A = dr[2].ToString(); QUESTION.subjecttype_fkid = Convert.ToInt32(dr[0]); QUESTION.Question = dr[1].ToString(); QUESTION.Explaination = dr[2].ToString(); QUESTION.Subject_fkid = Convert.ToInt32(dr[3]); QUESTION.Division_fkid = Convert.ToInt32(dr[4]); QUESTION.hint = dr[5].ToString(); QUESTION.Marks = Convert.ToDecimal(dr[6]); try { QUESTION.NegativeMarks = Convert.ToDecimal(dr[7]); } catch { QUESTION.NegativeMarks = 0; } QUESTION.SelectLevel = Convert.ToInt32(dr[8]); QUESTION.Adddate = DateTime.Now; QUESTION.Status = 1; QUESTION.lastModified = DateTime.Now; _question.Add(QUESTION); int _Maxid = _question.GetAll().Max(x => x.pkid); for (int p = 1; p <= 10; p++) { tbl_MatchContentQuestionMaster ANSWER = new tbl_MatchContentQuestionMaster(); int AA = 0; int CC = 0; if (p == 1) { AA = 9; CC = 10; } else if (p == 2) { AA = 11; CC = 12; } else if (p == 3) { AA = 13; CC = 14; } else if (p == 4) { AA = 15; CC = 16; } else if (p == 5) { AA = 17; CC = 18; } else if (p == 6) { AA = 19; CC = 20; } else if (p == 7) { AA = 21; CC = 22; } else if (p == 8) { AA = 23; CC = 24; } else if (p == 9) { AA = 25; CC = 26; } else { AA = 27; CC = 28; } ANSWER.Ques_fkid = _Maxid; ANSWER.FirstColoumn = dr[AA].ToString(); ANSWER.AnsweColoumn = dr[CC].ToString(); ANSWER.LastDatetime = DateTime.Now; if (!string.IsNullOrWhiteSpace(ANSWER.FirstColoumn) && !string.IsNullOrWhiteSpace(ANSWER.AnsweColoumn)) { _Matc.Add(ANSWER); } } } else { exception = "Select Correct File."; return(RedirectToAction("UploadExcel", "SubjectGroup", new { Exception = exception })); } } else { if (FileUpload.FileName == "QuestionAnswer.xlsx") { tbl_QuestionMaster QUESTION = new tbl_QuestionMaster(); tbl_AnswerMaster ANSWER = new tbl_AnswerMaster(); var q = dr[1].ToString(); var A = dr[2].ToString(); QUESTION.subjecttype_fkid = Convert.ToInt32(dr[0]); QUESTION.Question = dr[1].ToString(); QUESTION.Explaination = dr[2].ToString(); QUESTION.Subject_fkid = Convert.ToInt32(dr[3]); QUESTION.Division_fkid = Convert.ToInt32(dr[4]); QUESTION.hint = dr[5].ToString(); QUESTION.Marks = Convert.ToDecimal(dr[6]); try { QUESTION.NegativeMarks = Convert.ToDecimal(dr[7]); } catch { QUESTION.NegativeMarks = 0; } QUESTION.SelectLevel = Convert.ToInt32(dr[8]); QUESTION.Adddate = DateTime.Now; QUESTION.Status = 1; QUESTION.lastModified = DateTime.Now; _question.Add(QUESTION); ANSWER.Ques_fkid = _question.GetAll().Max(x => x.pkid); ANSWER.Questtype_fkid = Convert.ToInt32(dr[0]); ANSWER.Answer1 = dr[9].ToString(); ANSWER.Answer2 = dr[10].ToString(); ANSWER.Answer3 = dr[11].ToString(); ANSWER.Answer4 = dr[12].ToString(); try { ANSWER.CorrectAnswer = Convert.ToInt32(dr[13]); } catch { } ANSWER.BlanckSpace = dr[14].ToString(); try { ANSWER.TrueFalse = Convert.ToBoolean(dr[15]); } catch { } ANSWER.Adddate = DateTime.Now; ANSWER.status = 1; ANSWER.lastmodified = DateTime.Now; _answer.Add(ANSWER); } else { exception = "Select Correct File."; return(RedirectToAction("UploadExcel", "SubjectGroup", new { Exception = exception })); } } } exception = "All Data Uploaded Successfully"; } else { exception = "Please select File."; } return(RedirectToAction("UploadExcel", "SubjectGroup", new { Exception = exception })); } catch (Exception e) { Commonfunction.LogError(e, Server.MapPath("~/Log.txt")); exception = e.Message; return(RedirectToAction("UploadExcel", "SubjectGroup", new { Exception = exception })); } }
public void start() { weighingcontrolSystemEntities _db = new weighingcontrolSystemEntities(); foreach (var server in _db.tbl_RemoteConnection.ToList()) { #region string connectionstring = "Data Source=" + server.serverName + ";Initial Catalog=" + server.dataBaseName + ";User ID=" + server.userName + ";Password="******";"; //string connectionString=_db.tbl_accessConnection.FirstOrDefault().accessconnection; SqlConnection con = new SqlConnection(connectionstring); //OleDbConnection con= new OleDbConnection(connectionstring); SqlCommand cmd; string date1 = ""; #region if (date1 != "") { long idint = 0; try { idint = (long)_db.tbl_storemachineData.Max(x => x.machinePkid); } catch { idint = 0; } if (date1 == "") { cmd = new SqlCommand("select * from tbl_WeighingMachineFill", con); } else { DateTime dt = DateTime.Now.Date; string datestring = dt.ToString("MM-dd-yyyy"); cmd = new SqlCommand("select * from tbl_WeighingMachineFill where CAST(cdateTime as date)='" + datestring + "' ", con); } try { con.Open(); SqlDataAdapter sda = new SqlDataAdapter(); sda.SelectCommand = cmd; DataSet ds = new DataSet(); sda.Fill(ds); con.Close(); using (var ctx = new weighingcontrolSystemEntities()) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { var data = ds.Tables[0].Rows[i][1]; tbl_storemachineData smd = new tbl_storemachineData(); smd.ScaleId = ds.Tables[0].Rows[i][1].ToString().Trim(); smd.truckRFIDIN = ds.Tables[0].Rows[i][2].ToString().Trim(); smd.truckRFIDOUT = ds.Tables[0].Rows[i][3].ToString().Trim(); smd.operatorRFID = ds.Tables[0].Rows[i][4].ToString().Trim(); TimeSpan time1 = TimeSpan.Parse(DateTime.Now.TimeOfDay.ToString()); TimeSpan time2 = TimeSpan.Parse(DateTime.Now.TimeOfDay.ToString()); if (_db.tbl_operatorshift.Where(x => x.shiftstsrtTime <= time1 && x.shiftEndTime >= time2).Count() > 0) { smd.shiftTime = _db.tbl_operatorshift.Where(x => x.shiftstsrtTime <= time1 && x.shiftEndTime >= time2).FirstOrDefault().pkid; } smd.material = ds.Tables[0].Rows[i][5].ToString().Trim(); smd.grossWeight = Convert.ToDecimal(ds.Tables[0].Rows[i][6].ToString().Trim()); smd.dateTimeMachine = Convert.ToDateTime(ds.Tables[0].Rows[i][7].ToString().Trim()); smd.machinePkid = Convert.ToInt32(ds.Tables[0].Rows[i][0].ToString().Trim()); // rfid MappedOrNot if (_db.tbl_truckMapping.Where(x => x.truckRFID == smd.truckRFIDIN || x.truckRFID == smd.truckRFIDOUT).Count() == 1) { // Truck In and unque Record save into database othe wise skip if (smd.truckRFIDIN != "" && _db.tbl_storemachineData.Where(x => x.truckRFIDIN == smd.truckRFIDIN && x.ScaleId == smd.ScaleId && x.dateTimeMachine == smd.dateTimeMachine).Count() == 0) { smd.status = "IN"; smd.netWeight = 0; smd.fairWeight = smd.grossWeight; _db.tbl_storemachineData.Add(smd); _db.SaveChanges(); } else { if (smd.truckRFIDOUT != "" && _db.tbl_storemachineData.Where(x => x.truckRFIDOUT == smd.truckRFIDOUT && x.ScaleId == smd.ScaleId && x.dateTimeMachine == smd.dateTimeMachine).Count() == 0) { if (_db.tbl_storemachineData.Where(x => x.truckRFIDIN == smd.truckRFIDOUT).Count() > 0) { long maxId = _db.tbl_storemachineData.Where(x => x.truckRFIDIN == smd.truckRFIDOUT).Max(x => x.pkid); decimal maxVal = (decimal)_db.tbl_storemachineData.Where(x => x.pkid == maxId).FirstOrDefault().grossWeight; if (maxVal != 0) { smd.status = "OUT"; smd.netWeight = smd.grossWeight - maxVal; smd.fairWeight = maxVal; } } else { smd.status = "OUT"; smd.netWeight = smd.grossWeight; smd.fairWeight = smd.grossWeight; smd.outGrossWeight = smd.grossWeight; smd.outNetWeight = smd.grossWeight; smd.outPkid = smd.machinePkid; smd.netWeight = 0; } if (smd.truckRFIDOUT != "" && smd.truckRFIDOUT != null && smd.status == "OUT") { try { long maxId = _db.tbl_storemachineData.Where(x => x.truckRFIDIN == smd.truckRFIDOUT && x.outPkid == null).Max(x => x.pkid); if (maxId > 0) { var updateData = _db.tbl_storemachineData.Where(x => x.pkid == maxId).FirstOrDefault(); updateData.outPkid = Convert.ToInt32(ds.Tables[0].Rows[i][0].ToString().Trim()); updateData.material = ds.Tables[0].Rows[i][5].ToString().Trim(); updateData.outGrossWeight = Convert.ToDecimal(ds.Tables[0].Rows[i][6].ToString().Trim()); updateData.outTime = Convert.ToDateTime(ds.Tables[0].Rows[i][7].ToString().Trim()); updateData.outLocation = smd.ScaleId; TimeSpan Outtime1 = TimeSpan.Parse(ds.Tables[0].Rows[i][7].ToString().Trim()); if (_db.tbl_operatorshift.Where(x => x.shiftstsrtTime <= Outtime1 && x.shiftEndTime >= Outtime1).Count() > 0) { updateData.outShift = _db.tbl_operatorshift.Where(x => x.shiftstsrtTime <= Outtime1 && x.shiftEndTime >= Outtime1).FirstOrDefault().pkid; } else { updateData.outShift = 0; } _db.Entry(updateData).State = EntityState.Modified; _db.SaveChanges(); } else { _db.tbl_storemachineData.Add(smd); _db.SaveChanges(); } } catch { } } } } } } } } catch (Exception ex) { //itechDll.Commonfunction.LogError(ex, @"~/Errorlog.txt"); Commonfunction.LogError(ex, Path.Combine("~/ErrorLog.txt")); } #endregion } else { long idint = 0; try { idint = (long)_db.tbl_storemachineData.Max(x => x.machinePkid); } catch { idint = 0; } cmd = new SqlCommand("select * from tbl_WeighingMachineFill where pkid>=" + idint + " ", con); try { con.Open(); SqlDataAdapter sda = new SqlDataAdapter(); sda.SelectCommand = cmd; DataSet ds = new DataSet(); sda.Fill(ds); con.Close(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { var data = ds.Tables[0].Rows[i][1]; tbl_storemachineData smd = new tbl_storemachineData(); smd.ScaleId = ds.Tables[0].Rows[i][1].ToString().Trim(); smd.truckRFIDIN = ds.Tables[0].Rows[i][2].ToString().Trim(); smd.truckRFIDOUT = ds.Tables[0].Rows[i][3].ToString().Trim(); smd.operatorRFID = ds.Tables[0].Rows[i][4].ToString().Trim(); // shift Time TimeSpan time1 = TimeSpan.Parse(DateTime.Now.TimeOfDay.ToString()); TimeSpan time2 = TimeSpan.Parse(DateTime.Now.TimeOfDay.ToString()); if (_db.tbl_operatorshift.Where(x => x.shiftstsrtTime <= time1 && x.shiftEndTime >= time2).Count() > 0) { smd.shiftTime = _db.tbl_operatorshift.Where(x => x.shiftstsrtTime <= time1 && x.shiftEndTime >= time2).FirstOrDefault().pkid; } smd.material = ds.Tables[0].Rows[i][5].ToString().Trim(); smd.grossWeight = Convert.ToDecimal(ds.Tables[0].Rows[i][6].ToString().Trim()); smd.dateTimeMachine = Convert.ToDateTime(ds.Tables[0].Rows[i][7].ToString().Trim()); smd.machinePkid = Convert.ToInt32(ds.Tables[0].Rows[i][0].ToString().Trim()); // rfid MappedOrNot if (_db.tbl_truckMapping.Where(x => x.truckRFID == smd.truckRFIDIN || x.truckRFID == smd.truckRFIDOUT).Count() == 1) { // Truck In and unque Record save into database othe wise skip if (smd.truckRFIDIN != "" && _db.tbl_storemachineData.Where(x => x.truckRFIDIN == smd.truckRFIDIN && x.ScaleId == smd.ScaleId && x.dateTimeMachine == smd.dateTimeMachine).Count() == 0) { smd.status = "IN"; smd.netWeight = 0; smd.fairWeight = smd.grossWeight; _db.tbl_storemachineData.Add(smd); _db.SaveChanges(); } else { if (smd.truckRFIDOUT != "" && _db.tbl_storemachineData.Where(x => x.truckRFIDOUT == smd.truckRFIDOUT && x.ScaleId == smd.ScaleId && x.dateTimeMachine == smd.dateTimeMachine).Count() == 0) { if (_db.tbl_storemachineData.Where(x => x.truckRFIDIN == smd.truckRFIDOUT && x.outPkid == null).Count() > 0) { long maxId = _db.tbl_storemachineData.Where(x => x.truckRFIDIN == smd.truckRFIDOUT).Max(x => x.pkid); decimal maxVal = (decimal)_db.tbl_storemachineData.Where(x => x.pkid == maxId).FirstOrDefault().grossWeight; if (maxVal != 0) { smd.status = "OUT"; smd.netWeight = smd.grossWeight - maxVal; smd.fairWeight = maxVal; } } else { smd.status = "OUT"; smd.netWeight = smd.grossWeight; smd.fairWeight = smd.grossWeight; smd.outGrossWeight = smd.grossWeight; smd.outNetWeight = smd.grossWeight; smd.outPkid = smd.machinePkid; smd.netWeight = 0; } if (smd.truckRFIDOUT != "" && smd.truckRFIDOUT != null && smd.status == "OUT") { try { long maxId = 0; try { maxId = _db.tbl_storemachineData.Where(x => x.truckRFIDIN == smd.truckRFIDOUT).Max(x => x.pkid); } catch { } if (maxId > 0) { var updateData = _db.tbl_storemachineData.Where(x => x.pkid == maxId).FirstOrDefault(); // masterid = Convert.ToInt32(ds.Tables[0].Rows[i][0]); updateData.outPkid = Convert.ToInt32(ds.Tables[0].Rows[i][0].ToString().Trim()); updateData.material = ds.Tables[0].Rows[i][5].ToString().Trim(); //updateData.truckRFIDIN = ds.Tables[0].Rows[i][2].ToString().Trim(); try { updateData.outGrossWeight = Convert.ToDecimal(ds.Tables[0].Rows[i][6].ToString().Trim()); } catch { //cmd.CommandText = "SELECT top 1 TgrossWeight FROM [TBForce].[dbo].[tbl_WeighingMachineFill] WHERE pkid < (" + masterid + ") and RFID1 = " + updateData.truckRFIDIN + "ORDER BY pkid DESC"; //cmd.CommandType = CommandType.Text; //cmd.Connection = con; //con.Open(); //returnValue = cmd.ExecuteScalar(); //con.Close(); //smd.grossWeight = Convert.ToDecimal(returnValue); } updateData.outTime = Convert.ToDateTime(ds.Tables[0].Rows[i][7].ToString().Trim()); updateData.outLocation = smd.ScaleId; TimeSpan Outtime1 = TimeSpan.Parse(ds.Tables[0].Rows[i][7].ToString().Trim()); if (_db.tbl_operatorshift.Where(x => x.shiftstsrtTime <= Outtime1 && x.shiftEndTime >= Outtime1).Count() > 0) { updateData.outShift = _db.tbl_operatorshift.Where(x => x.shiftstsrtTime <= Outtime1 && x.shiftEndTime >= Outtime1).FirstOrDefault().pkid; } else { updateData.outShift = 0; } _db.Entry(updateData).State = EntityState.Modified; _db.SaveChanges(); } else { _db.tbl_storemachineData.Add(smd); _db.SaveChanges(); } } catch { } } } else { } } } else { if (smd.grossWeight > 50) { smd.truckRFIDOUT = "0088"; smd.status = "OUT"; smd.netWeight = smd.grossWeight; smd.fairWeight = smd.grossWeight; smd.outGrossWeight = smd.grossWeight; smd.outNetWeight = smd.grossWeight; smd.outPkid = smd.machinePkid; _db.tbl_storemachineData.Add(smd); _db.SaveChanges(); } else { smd.truckRFIDIN = "0088"; smd.status = "IN"; smd.netWeight = 0; smd.fairWeight = smd.grossWeight; _db.tbl_storemachineData.Add(smd); _db.SaveChanges(); } } } } catch (Exception ex) { //Commonfunction.LogError(ex, Path.Combine("~/ErrorLog.txt")); } } } #endregion }
public ActionResult AddTourism(tbl_TourismMasterss model, HttpPostedFileBase[] files) { ViewBag.subList = new SelectList(_subcatTourism.GetAll(), "pkid", "SubCategory_Name"); ViewBag.cityList = new SelectList(_city.GetAll().Where(x => x.StateID == 1646).ToList(), "ID", "Name"); try { if (model.pkid == 0) { tbl_TourismMaster abc = new tbl_TourismMaster(); abc.city_fkid = model.city_fkid; abc.Sub_fkid = model.Sub_fkid; abc.Name = model.Name; abc.AddedDate = model.AddedDate; abc.Description = model.Description; abc.Longitude = model.Longitude; abc.openingTime = model.openingTime; abc.ClosingTime = model.ClosingTime; abc.Lid = model.Lid; abc.Lotitude = model.Lotitude; abc.Address = model.Address; abc.ContactNumber = model.ContactNumber; abc.InchargeName = model.InchargeName; abc.LastModifiedDate = DateTime.Now; _tourim.Add(abc); int maxid = _tourim.GetAll().Max(x => x.pkid); if (files != null) { foreach (HttpPostedFileBase file in files) { //Checking file is available to save. if (file != null) { tbl_MultipleFileUpload fob = new tbl_MultipleFileUpload(); WebFunction web = new WebFunction(); fob.Master_fkid = 3; fob.SubMaster_fkid = maxid; fob.Lastmodifieddatetime = DateTime.Now; fob.filepath = web.Storefile(file, 3); _mfile.Add(fob); } } } } else { int _id = Convert.ToInt32(model.pkid); tbl_TourismMaster abc = _tourim.Get(_id); abc.city_fkid = model.city_fkid; abc.Sub_fkid = model.Sub_fkid; abc.Name = model.Name; abc.AddedDate = model.AddedDate; abc.Description = model.Description; abc.Longitude = model.Longitude; abc.Lotitude = model.Lotitude; abc.openingTime = model.openingTime; abc.ClosingTime = model.ClosingTime; abc.Lid = model.Lid; abc.Address = model.Address; abc.ContactNumber = model.ContactNumber; abc.InchargeName = model.InchargeName; abc.LastModifiedDate = DateTime.Now; _tourim.Update(abc); foreach (HttpPostedFileBase file in files) { //Checking file is available to save. if (file != null) { tbl_MultipleFileUpload fob = new tbl_MultipleFileUpload(); WebFunction web = new WebFunction(); fob.Master_fkid = 3; fob.SubMaster_fkid = model.pkid; fob.Lastmodifieddatetime = DateTime.Now; fob.filepath = web.Storefile(file, 3); _mfile.Add(fob); } } } return(RedirectToAction("AddTourism", "Administration")); } catch (Exception e) { Commonfunction.LogError(e, Server.MapPath("~/Log.txt")); ViewBag.Exception = e.Message; return(View()); } }