public ActionResult Update(VM_Designation designation) { if (ModelState.IsValid) { try { tblDesignation aDesignation = unitOfWork.DesignationRepository.GetByID(designation.DesignationId); aDesignation.DesignationName = designation.DesignationName; aDesignation.EditedBy = SessionManger.LoggedInUser(Session); aDesignation.EditedDateTime = DateTime.Now; unitOfWork.DesignationRepository.Update(aDesignation); unitOfWork.Save(); return(Json(new { success = true, successMessage = "Designation Info update successfully." }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { success = false, errorMessage = ex }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { success = false, errorMessage = "Model is not valid" }, JsonRequestBehavior.AllowGet)); } }
// \AddAdmin.aspx // AddDesignation.aspx public Boolean AddDesignation(string Designation, int AdminID) { var DC = new DataClassesDataContext(); int cnt = (from obj in DC.tblDesignations where obj.Name == Designation && obj.IsDeleted == false select obj).Count(); if (cnt > 0) { return(false); } int cnt2 = (from obj in DC.tblDesignations where obj.Name == Designation && obj.IsDeleted == true select obj).Count(); if (cnt2 > 0) { tblDesignation DesignationData = DC.tblDesignations.SingleOrDefault(ob => ob.Name == Designation); DesignationData.IsDeleted = false; DesignationData.UpdatedBy = AdminID; DesignationData.UpdatedOn = DateTime.Now; } else { tblDesignation DesignationData = new tblDesignation(); DesignationData.Name = Designation; DesignationData.IsDeleted = false; DesignationData.CreatedBy = AdminID; DesignationData.CreatedOn = DateTime.Now; DC.tblDesignations.InsertOnSubmit(DesignationData); } DC.SubmitChanges(); return(true); }
public ActionResult AddDesignation(VM_Designation designation) { if (ModelState.IsValid) { try { tblDesignation aDesignation = new tblDesignation(); aDesignation.DesignationName = designation.DesignationName; aDesignation.WorkShopId = Int32.Parse(SessionManger.WorkShopOfLoggedInUser(Session).ToString()); aDesignation.CreatedBy = SessionManger.LoggedInUser(Session); aDesignation.CreatedDateTime = DateTime.Now; aDesignation.EditedBy = null; aDesignation.EditedDateTime = null; unitOfWork.DesignationRepository.Insert(aDesignation); unitOfWork.Save(); return(Json(new { success = true, successMessage = "Designation Save Successfully" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { success = false, errorMessage = ex }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { success = false, errorMessage = "Designation not Save" }, JsonRequestBehavior.AllowGet)); } }
public bool UpdateDesignation(DesignationVM designationVM) { using (var dbTransaction = unitOfWork.dbContext.Database.BeginTransaction()) { try { tblDesignation designation = unitOfWork.TblDesignationRepository.GetByID(designationVM.DesignationID); designation.BUID = designationVM.BusinessUnitID; designation.Designation = designationVM.DesignationName; designation.ModifiedDate = DateTime.Now; designation.ModifiedBy = designationVM.ModifiedBy; unitOfWork.TblDesignationRepository.Update(designation); unitOfWork.Save(); //Complete the Transaction dbTransaction.Commit(); return(true); } catch (Exception ex) { //Roll back the Transaction dbTransaction.Rollback(); return(false); } } }
public bool IsExists(string strDesigName, int intDesigIdno) { using (TransportMandiEntities db = new TransportMandiEntities(MultipleDBDAL.strDynamicConString())) { tblDesignation objtblDesignation = new tblDesignation(); if (intDesigIdno <= 0) { objtblDesignation = (from mast in db.tblDesignations where mast.Desig_Name == strDesigName select mast).FirstOrDefault(); } else if (intDesigIdno > 0) { objtblDesignation = (from mast in db.tblDesignations where mast.Desig_Name == strDesigName && mast.Desig_Idno != intDesigIdno select mast).FirstOrDefault(); } if (objtblDesignation != null) { return(true); } else { return(false); } } }
public Int32 UpdateStatus(int intDesigIdno, bool Status, Int32 empIdno) { int value = 0; try { using (TransportMandiEntities db = new TransportMandiEntities(MultipleDBDAL.strDynamicConString())) { tblDesignation objtblDesignation = (from mast in db.tblDesignations where mast.Desig_Idno == intDesigIdno select mast).FirstOrDefault(); if (objtblDesignation != null) { objtblDesignation.Emp_Idno = empIdno; objtblDesignation.Status = Status; objtblDesignation.Date_Modified = System.DateTime.Now; db.SaveChanges(); value = 1; } } } catch { } return(value); }
/// <summary> /// Insert records in tblDesignation /// </summary> /// <param name="strDesigName"></param> /// <param name="bStatus"></param> /// <returns></returns> public Int64 Insert(string strDesigName, bool bStatus, Int32 empIdno) { Int64 intValue = 0; try { using (TransportMandiEntities db = new TransportMandiEntities(MultipleDBDAL.strDynamicConString())) { tblDesignation objtblDesignation = new tblDesignation(); objtblDesignation.Desig_Name = strDesigName; objtblDesignation.Status = bStatus; objtblDesignation.Emp_Idno = empIdno; objtblDesignation.Date_Added = System.DateTime.Now; objtblDesignation.UserRights_Status = false; if (IsExists(strDesigName, 0) == true) { intValue = -1; } else { db.AddTotblDesignations(objtblDesignation); db.SaveChanges(); intValue = objtblDesignation.Desig_Idno; } } } catch { //ApplicationFunction.ErrorLog(ex.ToString()); } return(intValue); }
public ActionResult DeleteConfirmed(int id) { tblDesignation tblDesignation = db.tblDesignations.Find(id); db.tblDesignations.Remove(tblDesignation); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "DesigCode,Designation,DeptCode")] tblDesignation tblDesignation) { if (ModelState.IsValid) { db.Entry(tblDesignation).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.DeptCode = new SelectList(db.tblDepartments, "DeptCode", "DepartmentName", tblDesignation.DeptCode); return(View(tblDesignation)); }
public ActionResult Create([Bind(Include = "DesigCode,Designation,DeptCode")] tblDesignation tblDesignation) { if (ModelState.IsValid) { db.tblDesignations.Add(tblDesignation); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.DeptCode = new SelectList(db.tblDepartments, "DeptCode", "DepartmentName", tblDesignation.DeptCode); return(View(tblDesignation)); }
// GET: tblDesignations/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblDesignation tblDesignation = db.tblDesignations.Find(id); if (tblDesignation == null) { return(HttpNotFound()); } return(View(tblDesignation)); }
public int Add() { using (var context = new RedSeaEntities()) { var designation = new tblDesignation() { Designation = this.designation }; context.tblDesignations.Add(designation); context.SaveChanges(); this.id = designation.Id; } return(this.id); }
// GET: tblDesignations/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblDesignation tblDesignation = db.tblDesignations.Find(id); if (tblDesignation == null) { return(HttpNotFound()); } ViewBag.DeptCode = new SelectList(db.tblDepartments, "DeptCode", "DepartmentName", tblDesignation.DeptCode); return(View(tblDesignation)); }
public void ChangeActivation(int ID, string TableName) { var DC = new DataClassesDataContext(); if (TableName == "tblCompany") { tblCompany result = (from u in DC.tblCompanies where u.CompanyID == ID select u).Single(); if (result.IsActive) { result.IsActive = false; } else { result.IsActive = true; } } if (TableName == "tblAdmin") { tblAdmin result = (from u in DC.tblAdmins where u.AdminID == ID select u).Single(); if (result.IsActive) { result.IsActive = false; } else { result.IsActive = true; } } if (TableName == "tblDesignation") { tblDesignation result = (from u in DC.tblDesignations where u.DesignationID == ID select u).Single(); if (result.IsDeleted) { result.IsDeleted = false; } else { result.IsDeleted = true; } } DC.SubmitChanges(); }
public int Update(string strDesigName, bool bStatus, int intDesigIdno, Int32 empIdno) { int intValue = 0; try { using (TransportMandiEntities db = new TransportMandiEntities(MultipleDBDAL.strDynamicConString())) { tblDesignation objtblDesignation = (from mast in db.tblDesignations where mast.Desig_Idno == intDesigIdno select mast).FirstOrDefault(); if (objtblDesignation != null) { objtblDesignation.Desig_Name = strDesigName; objtblDesignation.Status = bStatus; objtblDesignation.Emp_Idno = empIdno; if (objtblDesignation.UserRights_Status == true) { objtblDesignation.UserRights_Status = true; } else { objtblDesignation.UserRights_Status = false; } objtblDesignation.Status = false; objtblDesignation.Date_Added = System.DateTime.Now; objtblDesignation.Date_Modified = System.DateTime.Now; if (IsExists(strDesigName, intDesigIdno) == true) { intValue = -1; } else { db.SaveChanges(); intValue = intDesigIdno; } } } } catch { //ApplicationFunction.ErrorLog(ex.ToString()); } return(intValue); }
public ActionResult Create(VmDepartmentDesignation vm) { if (ModelState.IsValid) { tblDepartment d = new tblDepartment(); d.Department = vm.Department; db.tblDepartments.Add(d); db.SaveChanges(); tblDesignation dg = new tblDesignation(); dg.Designation = vm.Designation; dg.DepartmentID = d.Id; db.tblDesignations.Add(dg); db.SaveChanges(); return(RedirectToAction("Index")); } return(View()); }
protected void ddlDesignation_SelectedIndexChanged(object sender, EventArgs e) { string msg = ""; EmployeeMasterDAL userBLL = new EmployeeMasterDAL(); tblDesignation objDesigMast = new tblDesignation(); objDesigMast = userBLL.SelectDesigRghtsStatus(Convert.ToInt32(ddlDesignation.SelectedValue)); bool?bDesigRghtsStatus = false; if (objDesigMast != null) { bDesigRghtsStatus = objDesigMast.UserRights_Status; } if (bDesigRghtsStatus == false) { msg = "Rights for this designation has not assigned. Kindly Assign rights!"; ddlDesignation.Focus(); ScriptManager.RegisterStartupScript(this, this.GetType(), "alertstrMsg", "PassMessage('" + msg + "')", true); } RdoBtnMale.Focus(); }
public bool DeleteDesignation(int designationID) { using (var dbTransaction = unitOfWork.dbContext.Database.BeginTransaction()) { try { tblDesignation designation = unitOfWork.TblDesignationRepository.GetByID(designationID); unitOfWork.TblDesignationRepository.Delete(designation); unitOfWork.Save(); //Complete the Transaction dbTransaction.Commit(); return(true); } catch (Exception ex) { //Roll back the Transaction dbTransaction.Rollback(); return(false); } } }
public Int32 UpdateDesigRights(int intDesigIdno, bool bDesigRights) { int value = 0; try { using (TransportMandiEntities db = new TransportMandiEntities(MultipleDBDAL.strDynamicConString())) { tblDesignation objDesignation = (from mast in db.tblDesignations where mast.Desig_Idno == intDesigIdno select mast).FirstOrDefault(); if (objDesignation != null) { objDesignation.UserRights_Status = bDesigRights; db.SaveChanges(); value = 1; } } } catch (Exception ex) { } return(value); }
public int Delete(int intDesigIdno) { int intValue = 0; try { using (TransportMandiEntities db = new TransportMandiEntities(MultipleDBDAL.strDynamicConString())) { tblDesignation objtblDesignation = (from mast in db.tblDesignations where mast.Desig_Idno == intDesigIdno select mast).FirstOrDefault(); if (objtblDesignation != null) { db.DeleteObject(objtblDesignation); db.SaveChanges(); intValue = 1; } } } catch { } return(intValue); }
protected void lnkbtnSave_OnClick(object sender, EventArgs e) { Int32 empIdno = Convert.ToInt32((Session["UserIdno"] == null) ? "0" : Session["UserIdno"].ToString()); EmployeeMasterDAL objEmployeeMaster = new EmployeeMasterDAL(); string strMsg = string.Empty; Int64 intEmpIdno = 0, intUserRghtsIdno = 0; //, intEmpWHStoreIdno = 0; tblDesignation objDesigMast = new tblDesignation(); objDesigMast = objEmployeeMaster.SelectDesigRghtsStatus(Convert.ToInt32(ddlDesignation.SelectedValue)); bool?bDesigRghtsStatus = false; bDesigRghtsStatus = objDesigMast.UserRights_Status; int rowcount = 0; if (bDesigRghtsStatus == false) { ShowMessageErr("Rights for this designation has not assigned. Kindly assign rights and then save!"); ddlDesignation.Focus(); return; } string strEmail = txtEmail.Text.Trim(); string strPassword = WebTransport.Classes.EncryptDecryptPass.encryptPassword(txtPassword.Text.Trim()); bool BSeXIST = false; bool EmailExist; if (string.IsNullOrEmpty(hidEmpIdno.Value) == true) { BSeXIST = objEmployeeMaster.SelectExistInMasterDB(strEmail, strPassword, 0); } else { BSeXIST = objEmployeeMaster.SelectExistInMasterDB(strEmail, strPassword, Convert.ToInt32(hidEmpIdno.Value.Trim())); } EmailExist = objEmployeeMaster.EmailExist(strEmail, 1, Convert.ToInt32(string.IsNullOrEmpty(hidEmpIdno.Value.Trim()) ? "0" : hidEmpIdno.Value.Trim())); if ((BSeXIST == true) || (EmailExist == true)) { ShowMessageErr("Email Id And Password Already Exist Please Enter Different Email And Password!"); txtEmail.Focus(); return; } for (int i = 0; i <= chklistFromcity.Items.Count - 1; i++) { if (chklistFromcity.Items[i].Selected == true) { rowcount++; } } if (chklistFromcity.Items.Count == 0) { ShowMessageErr("Please define Location in City Master!"); return; } if (rowcount == 0) { ShowMessageErr("Please select From City!"); chklistFromcity.Focus(); return; } using (TransactionScope tScope = new TransactionScope(TransactionScopeOption.Required)) { if (string.IsNullOrEmpty(hidEmpIdno.Value) == true) { intEmpIdno = InsertIntoUsers(); if (intEmpIdno > 0) { objEmployeeMaster.InsertMultpleFromCity(intEmpIdno, chklistFromcity); } } else { intEmpIdno = UpdateUsers(Convert.ToInt64(hidEmpIdno.Value.Trim())); if (intEmpIdno > 0) { objEmployeeMaster.UpdateMultpleFromCity(intEmpIdno, chklistFromcity); } } if (intEmpIdno > 0) { if (string.IsNullOrEmpty(hidEmpIdno.Value) == true) { intUserRghtsIdno = objEmployeeMaster.InsertIntoUserRights(intEmpIdno, Convert.ToInt32(ddlDesignation.SelectedValue), empIdno); if (intEmpIdno > 0 && intUserRghtsIdno > 0) { tScope.Complete(); ShowMessage("Record saved successfully."); this.ClearCntrl(); lnkbtnNew.Visible = false; } else { ShowMessageErr("Record not saved."); txtEmpName.Focus(); } } else { if (intEmpIdno > 0) { tScope.Complete(); ShowMessage("Record updated successfully."); this.ClearCntrl(); lnkbtnNew.Visible = false; } } } else if (intEmpIdno == -1) { ShowMessageErr("Record already exists."); txtEmpName.Focus(); } else { ShowMessageErr("Record not saved."); txtEmpName.Focus(); } } txtEmpName.Focus(); }
public ActionResult CreateEmployee() { int empID = 0; //===================================== Department Binding entity ============================================= // List <tblDepartment> deptList = (from data in db.tblDepartments orderby data.varDepartmentName ascending select data).ToList(); tblDepartment objDept = new tblDepartment(); objDept.varDepartmentName = "-- Select --"; objDept.intDepartmentID = 0; deptList.Insert(0, objDept); SelectList objModelDept = new SelectList(deptList, "intDepartmentID", "varDepartmentName", 0); LoginViewModel objLogin = new LoginViewModel(); objLogin.DepartmentModel = objModelDept; //===================================== End Department Binding ==================================================// //==================================== Start Designation Binding entity =======================================// List <tblDesignation> desigList = (from data in db.tblDesignations orderby data.varDesignationName ascending select data).ToList(); tblDesignation objDesignation = new tblDesignation(); objDesignation.varDesignationName = "-- Select --"; objDesignation.intDesignationID = 0; desigList.Insert(0, objDesignation); SelectList objModelDesignation = new SelectList(desigList, "intDesignationID", "varDesignationName", 0); objLogin.DesignationModel = objModelDesignation; //=================================== End Designation Binding ================================================// //=================================== Employee Binding entity ================================================// List <tblEmployee> empList = (from data in db.tblEmployees orderby data.varFirstName ascending select data).ToList(); var empIndex = empList.Find(item => item.varFirstName == "Azam"); if (empIndex != null) { empID = empIndex.intEmployeeID; } else { empID = 0; } tblEmployee objemp = new tblEmployee(); objemp.varFirstName = "-- Select --"; objemp.intEmployeeID = 0; empList.Insert(0, objemp); SelectList objEmployeeModel = new SelectList(empList, "intEmployeeID", "varFirstName", empID); objLogin.EmployeeModel = objEmployeeModel; //=================================== End Employee Binding =====================================================// //======================Access Binding entity ==============================================================// //List<tblAccess> accessList = (from data in db.tblAccesses // orderby data.varAccessName ascending // select data).ToList(); //SelectList objAccessList = new SelectList(accessList, "intAccessID", "varAccessName", 0); //objLogin.AccessList = objAccessList; //=====================End Access Binding =======================================================================// objLogin.access = new List <tblAccess>(); objLogin.access = BindAccess(); return(View(objLogin)); }