Esempio n. 1
0
        private ActionResult ViewDetail(TblDepartment ob, string msg, AlertMsgType?msgType)
        {
            try
            {
                if (ob == null)
                {
                    throw new Exception("ไม่พบข้อมูลที่ต้องการ, กรุณาลองใหม่อีกครั้ง");
                }

                if (!string.IsNullOrWhiteSpace(msg))
                {
                    WidgetAlertModel alert = new WidgetAlertModel()
                    {
                        Message = msg
                    };
                    if (msgType.HasValue)
                    {
                        alert.Type = msgType.Value;
                    }
                    ViewBag.Alert = alert;
                }
                //ViewData["optPrefix"] = uow.Role.Gets(1, 0, 2);
                //ViewData["optRoleCal"] = uow.Role.Gets(1, 0, 2);
                return(View(ob));
            }
            catch (Exception ex)
            {
                return(RedirectToAction("Index", MVCController, new
                {
                    area = MVCArea,
                    msg = ex.GetMessage(),
                    msgType = AlertMsgType.Danger
                }));
            }
        }
Esempio n. 2
0
        public async Task <IActionResult> Edit(Guid id, [Bind("DepartmentId,DepartmentCode,DepartmentName,ActiveFlag")] TblDepartment tblDepartment)
        {
            if (id != tblDepartment.DepartmentId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(tblDepartment);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TblDepartmentExists(tblDepartment.DepartmentId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(tblDepartment));
        }
Esempio n. 3
0
        public ActionResult SetDetail()
        {
            int           id = Request.Form["DepartmentId"].ParseInt();
            TblDepartment ob = uow.Modules.Department.Get(id);

            if (ob.DepartmentId <= 0)
            {
                ob.CreatedBy   = CurrentUID;
                ob.CreatedDate = CurrentDate;
            }
            ob.DepartmentName = Request.Form["DepartmentName"];
            ob.UpdatedBy      = CurrentUID;
            ob.UpdatedDate    = CurrentDate;
            try
            {
                //Validate model b4 save

                uow.Modules.Department.Set(ob);
                uow.SaveChanges();

                return(RedirectToAction("Index", new
                {
                    area = "",
                    controller = MVCController,
                    msg = "บันทึกข้อมูลเรียบร้อยแล้ว",
                    msgType = AlertMsgType.Success
                }));
            }
            catch (Exception ex)
            {
                string msg = ex.GetMessage(true);
                return(ViewDetail(ob, msg, AlertMsgType.Danger));
            }
        }
Esempio n. 4
0
        public int DeleteDepartment(int Id)
        {
            int returnVal = 0;

            try
            {
                using (var dBContext1 = new EmployeeDatabaseContext())
                {
                    Model1.Entity.TblDepartment departmentEntity = new TblDepartment();
                    Models.Commen.Department    DeleteDept       = new Models.Commen.Department();
                    departmentEntity = dBContext1.TblDepartment.FirstOrDefault(x => x.DepartmentId == Id);
                    if (departmentEntity != null)
                    {
                        dBContext1.TblDepartment.Remove(departmentEntity);
                    }
                    returnVal = dBContext1.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                //throw;
            }
            return(returnVal);
        }
Esempio n. 5
0
        private void Init()
        {
            BindData();

            TblBranch branch      = new TblBranch();
            DataTable branchTable = branch.SelectAll();

            new XtraUtils.LookupEditBuilder.BranchCodeLookupEditBuilder(branchTable, lkpEdtBranchCode.Properties);

            TblCaseType casetype      = new TblCaseType();
            DataTable   caseTypeTable = casetype.SelectAll();

            new XtraUtils.LookupEditBuilder.CaseTypeLookupEditBuilder(caseTypeTable, lkpEdtCaseType.Properties);

//			TblMember member = new TblMember();
//			DataTable memberTable = member.SelectAll();
//			new XtraUtils.LookupEditBuilder.MemberIDLookupEditBuilder(memberTable, lkpEdtMemberID.Properties);

            TblCaseCategory category      = new TblCaseCategory();
            DataTable       categoryTable = category.SelectAll();

            new XtraUtils.LookupEditBuilder.CaseCategoryLookupEditBuilder(categoryTable, lkpEdtCategory.Properties);

            TblDepartment department = new TblDepartment();
            DataTable     deptTable  = department.SelectAll();

            new XtraUtils.LookupEditBuilder.DepartmentLookupEditBuilder(deptTable, lkpEdtDeptID.Properties);
        }
Esempio n. 6
0
        private void Init()
        {
            BindData();

            TblBranch branch      = new TblBranch();
            DataTable branchTable = branch.SelectAll();

            new XtraUtils.LookupEditBuilder.BranchCodeLookupEditBuilder(branchTable, lkpEdtBranchCode.Properties);

            TblCaseType casetype      = new TblCaseType();
            DataTable   caseTypeTable = casetype.SelectAll();

            new XtraUtils.LookupEditBuilder.CaseTypeLookupEditBuilder(caseTypeTable, lkpEdtCaseType.Properties);

            TblCaseCategory category      = new TblCaseCategory();
            DataTable       categoryTable = category.SelectAll();

            new XtraUtils.LookupEditBuilder.CaseCategoryLookupEditBuilder(categoryTable, lkpEdtCategory.Properties);

            TblDepartment department = new TblDepartment();
            DataTable     deptTable  = department.SelectAll();

            new XtraUtils.LookupEditBuilder.DepartmentLookupEditBuilder(deptTable, lkpEdtDeptID.Properties);

            new XtraUtils.LookupEditBuilder.EmployeeIDLookupEditBuilder(lkpEdtStaff.Properties, false);

            new XtraUtils.LookupEditBuilder.DepartmentLookupEditBuilder(deptTable, lkpEdtDeptAssignedID.Properties);
        }
Esempio n. 7
0
        public ActionResult DeleteConfirmed(int id)
        {
            TblDepartment tblDepartment = db.TblDepartments.Find(id);

            db.TblDepartments.Remove(tblDepartment);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 8
0
        public async Task <IActionResult> AddDepartment(TblDepartment department)
        {
            await _practiceContext.TblDepartments.AddAsync(department);

            await _practiceContext.SaveChangesAsync();

            return(Ok(department));
        }
Esempio n. 9
0
        public TblDepartment getDepartment(int givenID)
        {
            TblDepartment tdObj = (TblDepartment)NHSession.CreateCriteria(typeof(TblDepartment))
                                  .Add(Restrictions.Eq(Constants.allModelProperties.DeptId, givenID))
                                  .UniqueResult();

            return(tdObj);
        }
Esempio n. 10
0
 public ActionResult Edit([Bind(Include = "Dept_no,DeptName")] TblDepartment tblDepartment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tblDepartment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tblDepartment));
 }
Esempio n. 11
0
        public async Task <IActionResult> Create([Bind("Id,Department,DepartmentManagerId")] TblDepartment tblDepartment)
        {
            if (ModelState.IsValid)
            {
                _context.Add(tblDepartment);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(tblDepartment));
        }
Esempio n. 12
0
        public int EditDepartment(Models.Commen.Department EditDept, string DepartmentName, int DepartmentId)
        {
            List <Models.Commen.Department> departments = new List <Models.Commen.Department>();
            int returnVal = 0;

            try
            {
                using (var dBContext1 = new EmployeeDatabaseContext())
                {
                    //GetDepartment
                    Models.Commen.Department department1;
                    foreach (var dept in dBContext1.TblDepartment)
                    {
                        department1 = new Models.Commen.Department();
                        department1.DepartmentId   = dept.DepartmentId;
                        department1.DepartmentName = dept.DepartmentName;
                        departments.Add(department1);
                    }

                    Model1.Entity.TblDepartment departmentEntity = new TblDepartment();
                    departmentEntity = dBContext1.TblDepartment.FirstOrDefault(x => x.DepartmentId == EditDept.DepartmentId);
                    if (departmentEntity != null)
                    {
                        departmentEntity.DepartmentId   = EditDept.DepartmentId;
                        departmentEntity.DepartmentName = EditDept.DepartmentName;
                        dBContext1.TblDepartment.Update(departmentEntity);
                        DepartmentName = departmentEntity.DepartmentName;
                        DepartmentId   = departmentEntity.DepartmentId;
                    }

                    bool deptexist  = departments.Any(x => x.DepartmentName == DepartmentName);
                    bool deptexist1 = departments.Any(x => (x.DepartmentId == DepartmentId) && (x.DepartmentName == DepartmentName));

                    if ((deptexist1 == true))
                    {
                        returnVal = dBContext1.SaveChanges();
                    }
                    else if (deptexist == true)
                    {
                        returnVal = -1;
                    }
                    else
                    {
                        returnVal = dBContext1.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                //throw;
            }
            return(returnVal);
        }
Esempio n. 13
0
        public ActionResult Create([Bind(Include = "Dept_no,DeptName")] TblDepartment tblDepartment)
        {
            if (ModelState.IsValid)
            {
                db.TblDepartments.Add(tblDepartment);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tblDepartment));
        }
Esempio n. 14
0
        public async Task <IActionResult> UpdateDepartment(int id, TblDepartment department)
        {
            if (id != department.Id)
            {
                return(BadRequest());
            }

            _practiceContext.Entry(department).State = EntityState.Modified;
            await _practiceContext.SaveChangesAsync();

            return(Ok());
        }
Esempio n. 15
0
        public async Task <IActionResult> Create([Bind("DepartmentId,DepartmentCode,DepartmentName,ActiveFlag")] TblDepartment tblDepartment)
        {
            if (ModelState.IsValid)
            {
                tblDepartment.DepartmentId = Guid.NewGuid();
                _context.Add(tblDepartment);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(tblDepartment));
        }
Esempio n. 16
0
        // GET: TblDepartments/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TblDepartment tblDepartment = db.TblDepartments.Find(id);

            if (tblDepartment == null)
            {
                return(HttpNotFound());
            }
            return(View(tblDepartment));
        }
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            TblDepartment = await _context.TblDepartment.FirstOrDefaultAsync(m => m.Id == id);

            if (TblDepartment == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Esempio n. 18
0
        public int AddDepartment(Models.Commen.Department DepartmentModel, string DepartmentName)
        {
            List <Models.Commen.Department> departments = new List <Models.Commen.Department>();

            int returnVal = 0;

            try
            {
                using (var dBContext = new EmployeeDatabaseContext())
                {
                    //GetDepartment
                    Models.Commen.Department department1;
                    foreach (var dept in dBContext.TblDepartment)
                    {
                        department1 = new Models.Commen.Department();
                        department1.DepartmentName = dept.DepartmentName;
                        departments.Add(department1);
                    }

                    Model1.Entity.TblDepartment departmentEntity;
                    //Add Designation
                    if (DepartmentModel.DepartmentId == 0)
                    {
                        departmentEntity = new TblDepartment();
                        departmentEntity.DepartmentName = DepartmentModel.DepartmentName;
                        dBContext.TblDepartment.Add(departmentEntity);
                        DepartmentName = departmentEntity.DepartmentName;
                    }

                    bool deptexist = departments.Any(x => x.DepartmentName == DepartmentName);
                    if (deptexist == true)
                    {
                        returnVal = -1;
                    }
                    else
                    {
                        returnVal = dBContext.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                //throw;
            }
            return(returnVal);
        }
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            TblDepartment = await _context.TblDepartment.FindAsync(id);

            if (TblDepartment != null)
            {
                _context.TblDepartment.Remove(TblDepartment);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Esempio n. 20
0
        public frmAssignCV(object nDepartmentID)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
            TblDepartment department = new TblDepartment();
            DataTable     deptTable  = department.SelectAll();

            new XtraUtils.LookupEditBuilder.DepartmentLookupEditBuilder(deptTable, lkpEdtDeptID.Properties);

            lkpEdtDeptID.EditValue = nDepartmentID;
        }
Esempio n. 21
0
        public ActionResult Delete(int id)
        {
            try
            {
                TblDepartment ob = uow.Modules.Department.Get(id);
                if (ob == null)
                {
                    return(RedirectToAction("Index", MVCController, new { msg = "ไม่พบข้อมูลที่ต้องการ", msgType = AlertMsgType.Warning }));
                }

                uow.Modules.Department.Delete(ob);
                uow.SaveChanges();
                return(RedirectToAction("Index", MVCController, new { msg = "ลบข้อมูลเรียบร้อยแล้ว", msgType = AlertMsgType.Success }));
            }
            catch (Exception ex)
            { return(RedirectToAction("Index", MVCController, new { msg = ex.GetMessage(), msgType = AlertMsgType.Danger })); }
        }
Esempio n. 22
0
        public bool deleteDepartment(TblDepartment D)
        {
            bool result = false;

            using (ITransaction T = NHSession.BeginTransaction())
            {
                try
                {
                    NHSession.Delete(D);
                    T.Commit();
                    result = true;
                }
                catch (Exception ex)
                {
                    T.Rollback();
                }
            }
            return(result);
        }
Esempio n. 23
0
        public async Task <short> Handle(CreateDepartment request, CancellationToken cancellationToken)
        {
            TblDepartment entity;

            if (request.id > 0)
            {
                entity = _departmentRepository.FindById(request.id);
            }
            else
            {
                entity = new TblDepartment();
            }
            entity.departmentName = request.department;
            var department = (entity.id == 0) ? _departmentRepository.AddDepartment(entity) : _departmentRepository.EditDepartment(entity);

            //entity.gid = await _eventStoreService.createStream(entity);
            var saved = await _unitOfWork.CommitAsync(); /* s.n todo handle saved result*/

            return(department.id);
        }
Esempio n. 24
0
        public ActionResult Detail(int?id, string msg, AlertMsgType?msgType)
        {
            TblDepartment ob = uow.Modules.Department.Get(id ?? 0);

            return(ViewDetail(ob, msg, msgType));
        }
Esempio n. 25
0
 public HttpResponseMessage Put(int id, [FromBody] TblDepartment value)
 {
     UserDB.Entry(value).State = EntityState.Modified;
     return(ToJson(UserDB.SaveChanges()));
 }
Esempio n. 26
0
 public HttpResponseMessage Post([FromBody] TblDepartment value)
 {
     UserDB.TblDepartment.Add(value);
     return(ToJson(UserDB.SaveChanges()));
 }
 public IActionResult Post([FromBody] TblDepartment nDepartment)
 {
     return(new JsonResult(this.repository.AddAsync(nDepartment).Result, this.DefaultJsonSettings));
 }
 public IActionResult Put(string id, [FromBody] TblDepartment uDepartment)
 {
     return(new JsonResult(this.repository.UpdateAsync(uDepartment, id).Result, this.DefaultJsonSettings));
 }