Exemple #1
0
        private void Frm我指派的任务预览_Load(object sender, EventArgs e)
        {
            this.searchLookUpEdit1.Properties.DataSource = EmpService.findAll();
            List <String> empIds   = this.customAppointment.Assignee;
            List <EmpDto> empDtos  = EmpService.findByIds(empIds);
            List <String> empNames = new List <string>();

            foreach (EmpDto empDto in empDtos)
            {
                empNames.Add(empDto.Name);
            }

            this.searchLookUpEdit1.EditValue = string.Join(",", empNames);                                      //  name
            this.searchLookUpEdit1.ToolTip   = string.Join(",", empIds == null ? new List <String>() : empIds); //  id

            var v = this.luValues.Find(b => b.FindText == this.searchLookUpEdit1.Properties.View.FindFilterText);

            if (v == null)
            {
                v                  = new LookUpMultSelectValues();
                v.FindText         = this.searchLookUpEdit1.Properties.View.FindFilterText;
                v.SelectedValues   = new List <string>();
                v.SelectedDisplays = new List <string>();
                this.luValues.Add(v);
            }
        }
        public ActionResult Edit(FormCollection form)
        {
            EmpService service = new EmpService();
            Employee   emp     = new Employee();
            var        result  = false;

            emp.EmpId    = form["EmpId"];
            emp.EmpName  = form["EmpName"];
            emp.Ext      = form["Ext"];
            emp.DepId    = form["DepId"];
            emp.Birthday = Convert.ToDateTime(form["Birthday"]);
            emp.ID       = string.IsNullOrEmpty(form["ID"]) ? 0 : Convert.ToInt64(form["ID"]);
            try
            {
                if (emp.ID > 0)
                {
                    result = service.EditEmployee(emp);
                }
                else
                {
                    result = service.AddNewEmployee(emp);
                }
            }
            catch (Exception ex)
            {
                //可以處理要給前端的錯誤訊息/紀錄錯誤log
                throw ex;
            }

            return(RedirectToAction("Inquiry", "Emp"));
            //return View();
        }
Exemple #3
0
        public ActionResult Index(string returnUrl)
        {
            //logger.Trace("進入首頁");
            EmpService empService = new EmpService();

            return(View(empService.Get()));
        }
Exemple #4
0
        /// <summary>
        /// 通过任务信息初始化任务预览
        /// </summary>
        /// <param name="customAppointment"></param>
        /// <param name="empId"></param>
        /// <param name="isOwner">是否负责人</param>
        public Frm我指派的任务预览(Frm任务S frm, CustomAppointment customAppointment, String delegateId)
        {
            InitializeComponent();
            this.customAppointment = customAppointment;
            this.delegateId        = delegateId;

            //  补充参与者信息
            CustomAppointmentService.buildAssignee(customAppointment);
            CustomAppointmentService.taskRead(customAppointment);
            this.frm = frm;
            this.frm.RefrashGridcontrol();

            this.initViewData();    //  初始化视图的值

            this.getTaskAchievement();
            this.getTaskWorkIntensity();    //  工作强度

            //  任务分解一览
            this.treeListTask.DataSource = CustomAppointmentService.getAllById(customAppointment.TaskId);
            this.gridControl2.DataSource = this.GetDataTable();

            //  业务委托人
            //显示的数据
            this.comboBoxDelegate.DisplayMember = "Name"; //name为类A的字段名
            //隐藏的数据(对于多个数据,可以用逗号隔开。例:id,name)
            this.comboBoxDelegate.ValueMember = "Id";     //id为类A的字段名(对于隐藏对个数据,把数据放到一个字段用逗号隔开)
            this.comboBoxDelegate.DataSource  = EmpService.findAll();
        }
Exemple #5
0
        public EmployeeInfoDto Get()
        {
            var user = AuthService.GetCurrentUser(this.User).Result;
            var emp  = EmpService.GetEmployeeWithCalculation(user.Id);

            return(Mapper.Map <EmployeeInfoDto>(emp));
        }
Exemple #6
0
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            if (this.isModified) //  修改
            {
                DBUtil.ExecuteSQL("UPDATE project_plan SET plan_name ='" +
                                  this.jihuamingcheng.Text +
                                  "',start_time ='" + this.kaishishijian.Text +
                                  "' , end_time = '" + this.jieshushijian.Text +
                                  "' , emp_id = '" + EmpService.findEmpIdByName(this.empDtos, this.combo负责人.Text) + "'    WHERE    id = '" + planId + "'");
            }
            else
            {
                String uuid = System.Guid.NewGuid().ToString("N");

                //string str = this.dateEdit1.Text;
                //string str1 = this.dateEdit2.Text;

                DBUtil.ExecuteSQL("INSERT INTO project_plan(id,plan_name,start_time,end_time,emp_id)  " +
                                  " VALUES  ('" + uuid + "','" + this.jihuamingcheng.Text + "','" + this.kaishishijian.Text + "','" + this.jieshushijian.Text + "','"
                                  + EmpService.findEmpIdByName(this.empDtos, this.combo负责人.Text)
                                  + "')");
            }
            this.frmbiao.refreshPlan();
            this.Close();
        }
Exemple #7
0
 /// <summary>
 /// 修改
 /// </summary>
 /// <param name="id"></param>
 public Frm修改(Frm目录 frmbiao, String id)
 {
     this.initComponent(frmbiao);
     this.planId = id;
     this.initedit();
     this.isModified = true;
     this.empDtos    = EmpService.findAll();
 }
        public void TestFindByName()
        {
            var empService = new EmpService();
            var employees = empService.FindByName("Sh");

            foreach (var emp in employees) {
                Console.WriteLine(String.Format("{0}, {1}", emp.Emp_Id, emp.Name));
            }
        }
Exemple #9
0
        public async Task <ActionResult> DeleteEmp(int id)
        {
            CustomModel.ResultModel customModel = new CustomModel.ResultModel()
            {
                Message = "刪除失敗"
            };
            EmpService empService = new EmpService();
            EMPLOYEE   emp        = empService.FindOne(id);

            var user = await UserManager.FindByNameAsync(emp.empaccount);

            var logins       = user.Logins;
            var rolesForUser = await UserManager.GetRolesAsync(user.Id);

            var appDbContext = HttpContext.GetOwinContext().Get <ApplicationDbContext>();

            using (var transaction = appDbContext.Database.BeginTransaction())
            {
                try
                {
                    foreach (var login in logins.ToList())
                    {
                        await UserManager.RemoveLoginAsync(login.UserId, new UserLoginInfo(login.LoginProvider, login.ProviderKey));
                    }

                    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);

                    empService.Delete(id);

                    transaction.Commit();

                    customModel.Success = true;
                    customModel.Message = "刪除成功";
                    return(Json(customModel));
                }
                catch (DbEntityValidationException ex)
                {
                    logger.Error(GetEntityErrorMsg(ex));
                }
                catch (Exception ex)
                {
                    logger.Error(ex.Message);
                    transaction.Rollback();
                }
                return(Json(customModel));
            }
        }
Exemple #10
0
        private List <EmpDto> empDtos = new List <EmpDto>();  //  员工列表

        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="frmbiao"></param>
        public Frm修改(Frm目录 frmbiao)
        {
            this.initComponent(frmbiao);
            this.isModified = false;
            this.empDtos    = EmpService.findAll();
            for (int i = 0; i < this.empDtos.Count; i++)
            {
                this.combo负责人.Properties.Items.Add(empDtos[i].Name.ToString()); //  TODO
            }
        }
Exemple #11
0
        public void Shoul_Return_EmployeeList()
        {
            //Arrange

            //Act
            var List = EmpService.FetchEmployeeList();

            //Assert
            Assert.Equal(10, List.Count);
        }
Exemple #12
0
        public ActionResult Delete(Emp model)
        {
            var result = EmpService.DeleteUser(model.No);

            if (result.Result == "1")
            {
                return(RedirectToAction("Index"));
            }
            return(View());
        }
Exemple #13
0
        public ActionResult Edit(Emp model)
        {
            var result = EmpService.UpdateUser(model);

            if (result.Result == "1")
            {
                return(RedirectToAction("Index"));
            }
            return(View());
        }
Exemple #14
0
 /// <summary>
 /// 废弃
 /// </summary>
 /// <param name="frm"></param>
 public Frm新建申报(Frm目录 frm)
 {
     InitializeComponent();
     this.form    = frm;
     this.empDtos = EmpService.findAll();
     for (int i = 0; i < this.empDtos.Count; i++)
     {
         this.combo负责人.Properties.Items.Add(empDtos[i].Name.ToString()); //  TODO
         this.combo参与者.Properties.Items.Add(empDtos[i].Name.ToString()); //  TODO
     }
 }
Exemple #15
0
        public ActionResult Delete(string no)
        {
            var result = EmpService.GetUser(no);

            if (result.Result == "1")
            {
                var model = result.ReturnList;
                return(View(model));
            }
            return(View());
        }
Exemple #16
0
        // GET: Emp
        public ActionResult Index()
        {
            var result = EmpService.GetAllEmp();

            if (result.Result == "1")
            {
                var model = result.ReturnList;
                return(View(model));
            }
            return(View());
        }
Exemple #17
0
        public ActionResult Create(Emp model)
        {
            var result = EmpService.InsertUser(model);

            if (result.Result == "1")
            {
                TempData["AlertMessage"] = result.Message;
                return(RedirectToAction("Index"));
            }
            ViewData["ReturnMsg"] = result.Message;
            return(View(model));
        }
Exemple #18
0
 public Frm新建申报(String taskId, String taskTemplateId)
 {
     InitializeComponent();
     this.taskId         = taskId;
     this.taskTemplateId = taskTemplateId;
     this.empDtos        = EmpService.findAll();
     for (int i = 0; i < this.empDtos.Count; i++)
     {
         this.combo负责人.Properties.Items.Add(empDtos[i].Name.ToString()); //  TODO
         this.combo参与者.Properties.Items.Add(empDtos[i].Name.ToString()); //  TODO
     }
     this.treeList1.ExpandAll();
 }
Exemple #19
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            EmpService empService = new EmpService();
            EMPLOYEE   emp        = empService.FindOne(id);

            var viewModel = empService.GetEditModel(emp);

            return(View(viewModel));
        }
Exemple #20
0
        public async Task <ActionResult> Edit(EmpEditModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            else
            {
                //var user = UserManager.FindById(User.Identity.GetUserId());
                EmpService empService = new EmpService();
                EMPLOYEE   emp        = empService.FindOne(model.empno);

                var user = await UserManager.FindByNameAsync(emp.empaccount);

                user.Email       = model.EMPEMAIL;
                user.PhoneNumber = model.emptel;
                if (!string.IsNullOrWhiteSpace(model.Newpwd))
                {
                    user.PasswordHash = UserManager.PasswordHasher.HashPassword(model.Newpwd);
                    model.emppwd      = user.PasswordHash;
                }
                using (var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
                {
                    try
                    {
                        var result = await UserManager.UpdateAsync(user);

                        if (result.Succeeded)
                        {
                            empService.Update(model);

                            scope.Complete();
                            return(RedirectToAction("Index", "Home", new { area = "Admin" }));
                        }
                    }
                    catch (DbEntityValidationException ex)
                    {
                        logger.Error(GetEntityErrorMsg(ex));
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.Message);
                        scope.Dispose();
                    }
                }
            }
            return(View(model));
        }
Exemple #21
0
        public async Task <IActionResult> Grabar(string nombre
                                                 , long salario
                                                 , int edad
                                                 , string perfil)
        {
            EmployeeBO employee = new EmployeeBO();

            employee.edad    = edad;
            employee.salario = salario;
            employee.nombre  = nombre;
            employee.perfil  = perfil;

            EmployeeBO emp = await EmpService.Insertar(employee);

            return(RedirectToAction("Index"));
        }
        public void TestInsert()
        {
            Employee emp = new Employee
            {
                Emp_Id = 1001,
                Name = "Stone",
                Gender = "Male",
                Email = "*****@*****.**",
                Phone_Number = "138",
                City = "WUHAN"
            };

            var empService = new EmpService();
            int rv = empService.Insert(emp);
            Console.WriteLine(rv);
        }
        public void TestUpdate()
        {
            Employee emp = new Employee
            {
                Emp_Id = 1001,
                Name = "Stone",
                Gender = "Male",
                Email = "*****@*****.**",
                Phone_Number = "138",
                City = "WUHAN"
            };

            var empService = new EmpService();
            int rv = empService.Update(emp);
            Assert.AreEqual(rv, 1);
        }
        /// <summary>
        /// 根据部门取出上下级关系,构建部门和负责人kv
        /// </summary>
        /// <param name="departments"></param>
        private void generateCustomResource(List <String> departments)
        {
            Dictionary <String, List <EmpDto> > keyValuePairs = new Dictionary <String, List <EmpDto> >();

            foreach (String department in departments)
            {
                keyValuePairs.Add(
                    department
                    , EmpService.findByDepartment(department)
                    );
            }   //  部门和员工kv


            int          i      = 0;
            List <Color> Colors = new ResouceColorUtil().Colors; //  资源颜色工具类

            foreach (string department in keyValuePairs.Keys)
            {
                foreach (EmpDto empDto in keyValuePairs[department])
                {  //  员工
                    if (this.departmentAndCustomResource.ContainsKey(department))
                    {
                        //  更新
                        Boolean conflict = false;   //  id重复
                        foreach (CustomResource customResource in this.departmentAndCustomResource[department])
                        {
                            if (empDto.Id.Equals(customResource.ResID))
                            {
                                conflict = true;
                                break;  //  去重
                            }
                        }
                        if (!conflict)
                        {
                            this.departmentAndCustomResource[department].Add(new CustomResource(empDto.Id, empDto.Name, Colors[++i]));
                        }
                    }
                    else
                    {
                        //  新增
                        BindingList <CustomResource> customResources = new BindingList <CustomResource>();
                        customResources.Add(new CustomResource(empDto.Id, empDto.Name, Colors[++i]));
                        this.departmentAndCustomResource.Add(department, customResources);
                    }
                }
            }
        }
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         EmpService.findByEmpNoAndPassword(textBox1.Text, textBox2.Text);
         //if ((textBox1.Text.ToString() == "abc") || (textBox2.Text.ToString() == "abc"))
         {
             //MessageBox.Show("登录成功");
             this.Hide();
             new Frm任务S(EmpService.findEmpIdByJobnum(textBox1.Text), this).Show();
             //new Frm主界面(EmpService.findEmpIdByJobnum(textBox1.Text)).Show();
         }
     }
     catch
     {
         MessageBox.Show("工号或密码错误");
     }
 }
Exemple #26
0
        /**
         * 页面数据加载
         */
        public ActionResult getEmpList(String eid, String ename, String rid, String did)
        {
            Emp empQuery = new Emp();

            empQuery.Eid   = eid;
            empQuery.Ename = ename;
            if (rid != null && !rid.Equals(""))
            {
                empQuery.Rid = int.Parse(rid);
            }
            if (did != null && !did.Equals(""))
            {
                empQuery.Did = int.Parse(did);
            }
            EmpService empService = new EmpService();
            List <Emp> list       = empService.SelectEmps(empQuery);

            return(Json(list));
        }
Exemple #27
0
        /// <summary>
        /// 刪除員工資料
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Delete(int id)
        {
            EmpService service = new EmpService();
            var        result  = false;

            try
            {
                if (id > 0)
                {
                    result = service.RemoveEmployee(id);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(RedirectToAction("Inquiry", "Emp"));
        }
Exemple #28
0
        public Frm新建任务(Frm任务S form)
        {
            InitializeComponent();

            this.form     = form;
            this.owner_id = form.owner_id;

            RefrashGridcontrol();
            this.chineseLocale();
            //  选择任务模板的事件
            this.repositoryItemComboBox1.SelectedIndexChanged += TaskTemplateSelectedIndexChanged;

            //显示的数据
            this.comboBoxEmp.DisplayMember = "Name"; //name为类A的字段名
            //隐藏的数据(对于多个数据,可以用逗号隔开。例:id,name)
            this.comboBoxEmp.ValueMember = "Id";     //id为类A的字段名(对于隐藏对个数据,把数据放到一个字段用逗号隔开)
            List <String> emps = new List <string>();

            emps.Add(this.owner_id);
            this.comboBoxEmp.DataSource = EmpService.findByIds(emps);

            //  当没有选择模板
            this.nextTaskTemplates = TaskTemplateService.getByFrontTaskTemplateId(this.parentTaskTemplateId);

            this.barTaskTemp.Enabled = true;
            if (this.nextTaskTemplates.Count > 0)
            {
                foreach (NextTaskTemplate nextTaskTemplate in this.nextTaskTemplates)
                {
                    this.repositoryItemComboBox1.Items.Add(nextTaskTemplate.TaskTemplateName);
                }
                //this.barTaskTemplate.EditValue = this.nextTaskTemplates[0].TaskTemplateName;
            }

            //  初始化任务model
            this.appointmentModel = new AppointmentModel();
            this.appointmentModel.build难度(1);

            /// 参与者
            this.searchLookUpEdit1.EditValue = ""; //  name
            this.searchLookUpEdit1.ToolTip   = ""; //  id
        }
Exemple #29
0
        private void Frm新建任务_Load(object sender, EventArgs e)
        {
            //  日期
            this.edtStartDate.Text = DateTime.Now.ToShortDateString();
            this.edtEndDate.Text   = DateTime.Now.ToShortDateString();

            //  参与者
            this.searchLookUpEdit1.Properties.DataSource = EmpService.findAll();
            //  任务级别
            this.repositoryItem任务级别.Items.Add("公司级任务");
            this.repositoryItem任务级别.Items.Add("部门任务");
            this.repositoryItem任务级别.Items.Add("业务组任务");
            this.repositoryItem任务级别.Items.Add("个人任务");
            //  业务委托人
            //显示的数据
            this.comboBoxDelegate.DisplayMember = "Name"; //name为类A的字段名
            //隐藏的数据(对于多个数据,可以用逗号隔开。例:id,name)
            this.comboBoxDelegate.ValueMember = "Id";     //id为类A的字段名(对于隐藏对个数据,把数据放到一个字段用逗号隔开)
            this.comboBoxDelegate.DataSource  = EmpService.findAll();
        }
Exemple #30
0
        public void initedit()
        {
            this.kaishishijian.Properties.DisplayFormat.FormatString = "yyyy-MM-dd HH:mm";
            this.kaishishijian.Properties.DisplayFormat.FormatType   = DevExpress.Utils.FormatType.DateTime;
            this.kaishishijian.Properties.EditFormat.FormatString    = "yyyy-MM-dd HH:mm";
            this.kaishishijian.Properties.EditFormat.FormatType      = DevExpress.Utils.FormatType.DateTime;
            this.kaishishijian.Properties.Mask.EditMask = "yyyy-MM-dd HH:mm";

            this.jieshushijian.Properties.DisplayFormat.FormatString = "yyyy-MM-dd HH:mm";
            this.jieshushijian.Properties.DisplayFormat.FormatType   = DevExpress.Utils.FormatType.DateTime;
            this.jieshushijian.Properties.EditFormat.FormatString    = "yyyy-MM-dd HH:mm";
            this.jieshushijian.Properties.EditFormat.FormatType      = DevExpress.Utils.FormatType.DateTime;
            this.jieshushijian.Properties.Mask.EditMask = "yyyy-MM-dd HH:mm";

            //  sql改DTO
            this.dt = DBUtil.ExecuteDataTable("SELECT * FROM project_plan WHERE id = '" + planId + "'");
            this.jihuamingcheng.Text = dt.Rows[0]["plan_name"].ToString();
            this.kaishishijian.Text  = dt.Rows[0]["start_time"].ToString();
            this.jieshushijian.Text  = dt.Rows[0]["end_time"].ToString();
            this.combo负责人.Text       = EmpService.findEmpNameById(this.empDtos, dt.Rows[0]["emp_id"].ToString());
        }