コード例 #1
0
        public ActionResult EmployeeRegistration()
        {
            try
            {
                Employee emp_reg = new Employee();
                DataTable dt = emp_reg.Emp_Dept_data();
                Service1 gis_service = new Service1();
                DataSet ds = new DataSet();
                ds = gis_service._1Get_Company();
                List<SelectListItem> Company = new List<SelectListItem>();
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    Company.Add(new SelectListItem()
                    {
                        Value = ds.Tables[0].Rows[i]["Company"].ToString(),
                        Text = ds.Tables[0].Rows[i]["Company"].ToString()
                    });
                }
                ViewData["Company"] = new SelectList(Company, "Value", "Text", "Select Company");

                List<SelectListItem> dept = new List<SelectListItem>();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    dept.Add(new SelectListItem()
                    {
                        Text = dt.Rows[i]["DEPT_NAME"].ToString(),
                        Value = dt.Rows[i]["DEPT_ID"].ToString()
                    });
                }
                ViewData["Dept_name"] = new SelectList(dept, "Value", "Text", "Select Department");
            }
            catch
            { }
            return View();
        }
コード例 #2
0
        public ActionResult Employee_reg(Employee emp_reg)
        {
            if (ModelState.IsValid)
            {
                try
                {

                }
                catch (Exception) { ModelState.AddModelError("", "Already registered.please update your contact details "); }
            }
            else
            {
                emp_reg = new Employee();
                ViewData["Company"] = new SelectList(emp_reg.Company, "Value", "Text", "Select Company name");
                ViewData["Dept_name"] = new SelectList(emp_reg.Department, "Value", "Text", "Select Department name");
            }
            return View(emp_reg);
        }