/// <summary> /// Insert Department Information /// </summary> /// <param name="data">Department Information</param> /// <returns>Number Affected Row</returns> public static Tuple <ErrorObject, string> Department(tblDepartment data) { erros = new ErrorObject(); try { using (HSCMEntities db = new HSCMEntities()) { int propertyFind = db.tblDepartment.Count(); if (propertyFind > 0) { data.id = db.tblDepartment.Max(s => s.id); } else { data.id = 1; } db.tblDepartment.Add(data); result = db.SaveChanges(); Message = "Affected Row: " + result.ToString(); return(new Tuple <ErrorObject, string>(erros.IfError(false), Message)); } } catch (Exception ex) { erros.InfoError(ex); return(new Tuple <ErrorObject, string>(erros, String.Empty)); } }
public ActionResult AddOrEdit(int id = 0) { if (id == 0) { using (Entities db = new Entities()) { ViewBag.Students = db.tblStudents.ToList(); ViewBag.Action = "Add New Department"; return(View(new DepartmentViewModel())); } } else { using (Entities db = new Entities()) { ViewBag.Action = "Edit Department"; ViewBag.Students = db.tblStudents.ToList(); tblDepartment item = db.tblDepartments.Where(i => i.DepartmentId == id).FirstOrDefault(); DepartmentViewModel itemvm = new DepartmentViewModel(); itemvm.DepartmentId = item.DepartmentId; // itemvm.StudentId = Convert.ToInt32(item.StudentId); itemvm.DepartmentName = item.DepartmentName; itemvm.TeacherId = item.TeacherId; itemvm.ReportId = item.ReportId; return(View(itemvm)); } } }
public IHttpActionResult PosttblDepartment(DepartmentModel department) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } object Lock = new object(); int depId = 0; lock (Lock) { depId = db.tblDepartments.Select(i => i.ID).DefaultIfEmpty(0).Max(); department.ID = depId; tblDepartment tblDepartment = new tblDepartment() { ID = department.ID, Name = department.Name, Location = department.Location }; db.tblDepartments.Add(tblDepartment); int save = db.SaveChanges(); } return(CreatedAtRoute("DefaultApi", new { id = depId }, department)); }
public ActionResult Save(tblDepartment department) { if (!ModelState.IsValid) { return(View("DepartmentForm")); } if (department.d_ID == 0) { department.d_IsActive = true; db.tblDepartment.Add(department); } else { var upDepartment = db.tblDepartment.Find(department.d_ID); if (upDepartment == null) { return(HttpNotFound()); } upDepartment.d_Name = department.d_Name; } db.SaveChanges(); return(RedirectToAction("Index")); }
public bool InsertDepartment(CollegeModel collegeModel) { try { tblDepartment check = new tblDepartment(); check = _unitOfWork.DepartmentRepository.Get(prop => prop.DepartmentCode == collegeModel.DepartmentCode).FirstOrDefault(); Guid newGuid = Guid.NewGuid(); if (check == null) { tblDepartment entity = new tblDepartment() { DepartmentID = newGuid, DepartmentCode = collegeModel.DepartmentCode, DepartmentName = collegeModel.DepartmentName, CollegeId = collegeModel.CollegeID, TotalSem = collegeModel.TotalSem, IsDeleted = false }; _unitOfWork.DepartmentRepository.Insert(entity); _unitOfWork.Save(); return(true); } else { return(false); } } catch (Exception e) { string currentFile = new System.Diagnostics.StackTrace(true).GetFrame(0).GetFileName(); ErrorLogger.LogException(e, currentFile); CollegeModel college = new CollegeModel(); return(false); } }
public IActionResult IsAvailable([FromBody] tblDepartment _dep) { if (_dep.Id == 0) { var Check = _context.tblDepartment.Where(x => x.DepartmentName == _dep.DepartmentName).Count(); if (Check > 0) { return(Json(false)); } else { return(Json(true)); } } else { var Check = _context.tblDepartment.Where(x => x.DepartmentName == _dep.DepartmentName && x.Id != _dep.Id).Count(); if (Check > 0) { return(Json("Department Already Exist")); } else { return(Json(true)); } } }
public async Task <IActionResult> Edit(int id, [Bind("Id,DepartmentName")] tblDepartment tblDepartment) { if (id != tblDepartment.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(tblDepartment); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!tblDepartmentExists(tblDepartment.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(tblDepartment)); }
public static List <StudentHistoryModel> GetStudentHistory(Guid id) { try { List <StudentHistoryModel> modelList = new List <StudentHistoryModel>(); IEnumerable <tblStudentHistory> historyEntityList = new List <tblStudentHistory>(); historyEntityList = from ordered in _unitOfWork.StudentHistoryRepository.Get(filter: prop => prop.StudentID == id) orderby ordered.Semester descending select ordered; foreach (var history in historyEntityList) { tblCollege collegeEntity = new tblCollege(); collegeEntity = _unitOfWork.CollegeRepository.Get(filter: prop => prop.CollegeID == history.CollegeID).FirstOrDefault(); tblDepartment departmentEntity = new tblDepartment(); departmentEntity = _unitOfWork.DepartmentRepository.Get(filter: prop => prop.DepartmentID == history.DepartmentID).FirstOrDefault(); StudentHistoryModel newHistory = new StudentHistoryModel() { StudentID = history.StudentID, CollegeName = collegeEntity.CollegeName, DepartmentName = departmentEntity.DepartmentName, Semester = history.Semester, DateOfJoining = history.DateOfJoining }; modelList.Add(newHistory); } return(modelList); } catch (Exception e) { string currentFile = new System.Diagnostics.StackTrace(true).GetFrame(0).GetFileName(); ErrorLogger.LogException(e, currentFile); List <StudentHistoryModel> modelList = new List <StudentHistoryModel>(); return(modelList); } }
public int DeleteDepartment(int id) { tblDepartment department = _db.tblDepartments.Where(u => u.Id == id).FirstOrDefault(); department.IsDeleted = true; //_db.tblDepartments.Remove(department); return(_db.SaveChanges()); }
Department fillDomainModel(tblDepartment objtbDepartment) { Department objDepartment = new Department(); objDepartment.Id = objtbDepartment.DeptId; objDepartment.Name = objtbDepartment.DeptName; return(objDepartment); }
tblDepartment fillEntityModel(Department dept) { tblDepartment objTblDepartment = new tblDepartment(); objTblDepartment.DeptId = dept.Id; objTblDepartment.DeptName = dept.Name; return(objTblDepartment); }
public ActionResult Update(tblDepartment department) { if (ModelState.IsValid) { db.Entry(department).State = EntityState.Modified; db.SaveChanges(); } return(Json(department, JsonRequestBehavior.AllowGet)); }
public ActionResult Create([Bind(Exclude = "DeptCode")] tblDepartment department) { if (ModelState.IsValid) { db.tblDepartments.Add(department); db.SaveChanges(); } return(Json(department, JsonRequestBehavior.AllowGet)); }
public ActionResult AddOrEdit(DepartmentViewModel dvm) { using (Entities db = new Entities()) { if (dvm.DepartmentId == 0) { tblDepartment itm = new tblDepartment(); // itm.StudentId = Convert.ToInt32(dvm.StudentId); itm.DepartmentName = dvm.DepartmentName; itm.ReportId = dvm.ReportId; itm.TeacherId = dvm.TeacherId; //HttpPostedFileBase fup = Request.Files["Photo"]; //if (fup != null) //{ // if (fup.FileName != "") // { // fup.SaveAs(Server.MapPath("~/ProductImages/" + fup.FileName)); // itm.Photo = fup.FileName; // } //} db.tblDepartments.Add(itm); db.SaveChanges(); ViewBag.Message = "Updated Successfully"; } else { tblDepartment itm = db.tblDepartments.Where(i => i.DepartmentId == dvm.DepartmentId).FirstOrDefault(); // itm.StudentId = Convert.ToInt32(dvm.StudentId); itm.DepartmentName = dvm.DepartmentName; itm.ReportId = dvm.ReportId; itm.TeacherId = dvm.TeacherId; //HttpPostedFileBase fup = Request.Files["SmallImage"]; //if (fup != null) //{ // if (fup.FileName != "") // { // fup.SaveAs(Server.MapPath("~/ProductImages/" + fup.FileName)); // itm.Photo = fup.FileName; // } //} db.SaveChanges(); ViewBag.Message = "Updated Successfully"; } ViewBag.Students = db.tblStudents.ToList(); return(View(new DepartmentViewModel())); } }
public ActionResult Edit([Bind(Include = "Id,DepartmentName")] tblDepartment tblDepartment) { if (ModelState.IsValid) { db.Entry(tblDepartment).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tblDepartment)); }
public tblDepartment AddDep(int departmentid, string departmentname) { var dep = new tblDepartment() { DepartmentId = departmentid, DepartmentName = departmentname, }; return(dep); }
public ActionResult Delete(int id) { using (Entities db = new Entities()) { tblDepartment sm = db.tblDepartments.Where(x => x.DepartmentId == id).FirstOrDefault(); db.tblDepartments.Remove(sm); db.SaveChanges(); return(Json(new { success = true, message = "Deleted Successfully" }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Create([Bind(Include = "DepartmentName")] tblDepartment tblDepartment) { if (ModelState.IsValid) { db.tblDepartments.Add(tblDepartment); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tblDepartment)); }
// GET: Employee public ActionResult Index(string searching) { DataTable dt = new DataTable(); List <tblEmployee> tblEmp = new List <tblEmployee>(); using (SqlConnection con = new SqlConnection(connectionString)) { string query = "Select * from tblEmployee"; SqlDataAdapter sda = new SqlDataAdapter(query, con); sda.Fill(dt); } foreach (DataRow row in dt.Rows) { tblEmployee emp = new tblEmployee(); emp.EmployeeId = Convert.ToInt32(row["EmployeeId"]); emp.Name = Convert.ToString(row["Name"]); emp.Gender = Convert.ToString(row["Gender"]); emp.City = Convert.ToString(row["City"]); emp.DepartmentId = Convert.ToInt32(row["DepartmentId"]); tblEmp.Add(emp); } DataTable dtDept = new DataTable(); using (SqlConnection con = new SqlConnection(connectionString)) { string query = "Select * from tblDepartment"; SqlDataAdapter sdaDept = new SqlDataAdapter(query, con); sdaDept.Fill(dtDept); } List <tblDepartment> lstDept = new List <tblDepartment>(); foreach (DataRow row in dtDept.Rows) { tblDepartment dept = new tblDepartment(); dept.Id = Convert.ToInt32(row["Id"]); dept.Name = Convert.ToString(row["Name"]); lstDept.Add(dept); } ViewBag.empdata = lstDept; if (!string.IsNullOrEmpty(searching)) { int a = (from e in lstDept where e.Name == searching select e.Id).FirstOrDefault(); tblEmp = tblEmp.Where(emp => emp.DepartmentId.Equals(a)).ToList(); } return(View(tblEmp)); }
public ActionResult GetDataById(int deptId) { tblDepartment mDepartment = new tblDepartment(); var efData = db.tblDepartments.Where(x => x.Id == deptId).FirstOrDefault(); if (efData != null) { mDepartment.Name = efData.Name; mDepartment.Id = efData.Id; } return(Json(mDepartment)); }
public int UpdateDepartment(BODepartment model) { tblDepartment department = _db.tblDepartments.Where(u => u.Id == model.Id).FirstOrDefault(); department.phone = model.phone; department.Email = model.Email; department.Details = model.Details; department.Name = model.Name; department.LastUpdated = DateTime.Now.ToString(); department.HOD = model.HOD; return(_db.SaveChanges()); }
public string POST(tblDepartment dep) { try { db.tblDepartments.Add(dep); db.SaveChanges(); return("Added successfully"); } catch (Exception) { return("Failed to add"); } }
public IHttpActionResult DeletetblDepartment(int id) { tblDepartment tblDepartment = db.tblDepartments.Find(id); if (tblDepartment == null) { return(NotFound()); } db.tblDepartments.Remove(tblDepartment); db.SaveChanges(); return(Ok(tblDepartment)); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblDepartment tblDepartment = db.tblDepartments.Find(id); if (tblDepartment == null) { return(HttpNotFound()); } return(View(tblDepartment)); }
private void btnView_Click(object sender, RoutedEventArgs e) { try { object rowDep = lupeditDep.SelectedItem; tblDepartment iDep = (tblDepartment)rowDep; object rowSec = lupeditSec.SelectedItem; tblSection iSec = (tblSection)rowSec; object rowGro = lupeditGroup.SelectedItem; tblGroup iGro = (tblGroup)rowGro; if (colFromDate.DateTime != null && colToDate.DateTime != null) { int depID = -1; if (iDep != null) { depID = iDep.DepartmentID; } int secID = -1; if (iSec != null) { secID = iSec.SectionID; } int groID = -1; if (iGro != null) { groID = iGro.GroupID; } string empID = "-1"; if (txtEmpId.GetID().EmployeeID != null) { empID = txtEmpId.GetID().EmployeeID; } websv.CheckTimeListAsync(colFromDate.DateTime, colToDate.DateTime, depID, secID, groID, empID, ckbNormal.IsChecked.Value, ckbNoTimeInHasTimeOut.IsChecked.Value, ckbHasTimeInNoTimeOut.IsChecked.Value, ckbNoTimeInNoTimeOut.IsChecked.Value, ckbWorkOnHoliday.IsChecked.Value, ckbLeave.IsChecked.Value, ckbHoliday.IsChecked.Value, 3); //panelThietLap.Closed = true; gridCheckTimeList.View.ShowTotalSummary = true; gridCheckTimeList.View.ShowFixedTotalSummary = true; tblView.SelectAll(); //lblTest.Content = gridCheckTimeList.VisibleRowCount.ToString(); //hide panel Layout1.DockController.Hide(panelThietLap); gridCheckTimeList.Focus(); } } catch (Exception) { throw new Exception(); } }
public BODepartment GetDepartmentById(int id) { tblDepartment model = _db.tblDepartments.Where(u => u.Id == id).FirstOrDefault(); BODepartment department = new BODepartment(); department.CompanyId = model.CompanyId; department.lstCompany = blcompany.GetCompanyById(model.CompanyId.Value); department.phone = model.phone; department.Details = model.Details; department.Email = model.Email; department.Id = model.Id; department.Name = model.Name; department.HOD = model.HOD; return(department); }
public int CreateDepartment(BODepartment model) { tblDepartment department = new tblDepartment(); department.CompanyId = model.CompanyId; department.phone = model.phone; department.Email = model.Email; department.Details = model.Details; department.IsDeleted = false; department.Name = model.Name; department.CreatedAt = DateTime.Now.ToString(); department.HOD = model.HOD; _db.tblDepartments.Add(department); return(_db.SaveChanges()); }
public JsonResult Delete(tblDepartment _dep) { try { var _resp = db.tblDepartments.Where(x => x.Id == _dep.Id).SingleOrDefault(); db.tblDepartments.Remove(_resp); db.SaveChanges(); return(Json(200, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(300, JsonRequestBehavior.AllowGet)); } }
public string Delete(int id) { try { tblDepartment tb = db.tblDepartments.Where(a => a.DepartmentId == id).FirstOrDefault(); db.tblDepartments.Remove(tb); db.SaveChanges(); return("Deleted successfully"); } catch (Exception) { return("Failed to delete"); } }
public JsonResult Delete([FromBody] tblDepartment _dep) { try { var _resp = _context.tblDepartment.Where(x => x.Id == _dep.Id).SingleOrDefault(); _context.tblDepartment.Remove(_resp); _context.SaveChanges(); return(Json(200)); } catch (Exception ex) { return(Json(300)); } }
partial void InserttblDepartment(tblDepartment instance);
partial void UpdatetblDepartment(tblDepartment instance);
partial void DeletetblDepartment(tblDepartment instance);