public List <Staff> GetAllStaffs() { List <Staff> elements = new List <Staff>(); string sql = "select * from TF_Staff"; DataTable dt = sqlHelper.Query(sql); if (dt != null && dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { Staff element = new Staff(); element.ID = Convert.ToInt32(dt.Rows[i]["ID"]); element.Depart = DepartmentLogic.GetInstance().GetDepartment(Convert.ToInt32(dt.Rows[i]["Depart"])); element.Condition = StaffConditionLogic.GetInstance().GetStaffCondition(Convert.ToInt32(dt.Rows[i]["Condition"])); element.性别 = (性别)Enum.ToObject(typeof(性别), Convert.ToInt32(dt.Rows[i]["性别"])); element.姓名 = dt.Rows[i]["姓名"].ToString(); element.电话 = dt.Rows[i]["电话"].ToString(); element.生日 = Convert.ToDateTime(dt.Rows[i]["生日"]); element.宿舍 = dt.Rows[i]["宿舍"].ToString(); element.备注 = dt.Rows[i]["备注"].ToString(); element.钥匙数 = Convert.ToInt32(dt.Rows[i]["钥匙数"]); element.工衣数 = Convert.ToInt32(dt.Rows[i]["工衣数"]); element.工牌数 = Convert.ToInt32(dt.Rows[i]["工牌数"]); element.是否全部回收 = Convert.ToBoolean(dt.Rows[i]["是否全部回收"]); elements.Add(element); } } return(elements); }
internal bool UpgradeArchitectureToRemote(out Exception ex) { ex = null; int errCount = 0; try { Architecture a = this.CurrentArchitecture; List <Action> atcs = a.Acts; List <Department> deps = a.Deps; List <Module> mods = a.Mods; List <Permission> perms = a.Pers; List <Role> roles = a.Roles; List <UserGroup> ugrps = a.Ugroups; List <User> users = a.Users; ActionLogic.GetInstance().UpgradeList(atcs); DepartmentLogic.GetInstance().UpgradeList(deps); ModuleLogic.GetInstance().UpgradeList(mods); PermissionLogic.GetInstance().UpgradeList(perms); RoleLogic.GetInstance().UpgradeList(roles); UserGroupLogic.GetInstance().UpgradeList(ugrps); UserLogic.GetInstance().UpgradeList(users); } catch (Exception e) { errCount++; ex = e; } return(errCount == 0); }
private void label1_Click(object sender, EventArgs e) { List <Department> allDeps = DepartmentLogic.GetInstance().GetAllDepartments(); List <Staff> allStaffs = StaffLogic.GetInstance().GetAllStaffs(); SelectStaffForm f = new SelectStaffForm(selectOnlyOne, this.SelectedStaffs, allDeps, allStaffs); if (f.ShowDialog() == DialogResult.OK) { this.label1.Tag = f.SelectedStaffs; if (f.SelectedStaffs != null && f.SelectedStaffs.Count > 0) { StringBuilder sb = new StringBuilder(); foreach (Staff staff in f.SelectedStaffs) { if (sb.Length == 0) { sb.Append(staff.姓名); } else { sb.Append("," + staff.姓名); } } this.label1.Text = sb.ToString(); } else { this.label1.Text = "选择员工..."; } } }
public Staff GetStaffByName(string name) { string sql = "select * from TF_Staff where 姓名 like '%" + name + "%'"; DataTable dt = sqlHelper.Query(sql); if (dt != null && dt.Rows.Count > 0) { Staff element = new Staff(); element.ID = Convert.ToInt32(dt.Rows[0]["ID"]); element.Depart = DepartmentLogic.GetInstance().GetDepartment(Convert.ToInt32(dt.Rows[0]["Depart"])); element.Condition = StaffConditionLogic.GetInstance().GetStaffCondition(Convert.ToInt32(dt.Rows[0]["Condition"])); element.性别 = (性别)Enum.ToObject(typeof(性别), Convert.ToInt32(dt.Rows[0]["性别"])); element.姓名 = dt.Rows[0]["姓名"].ToString(); element.电话 = dt.Rows[0]["电话"].ToString(); element.生日 = Convert.ToDateTime(dt.Rows[0]["生日"]); element.宿舍 = dt.Rows[0]["宿舍"].ToString(); element.备注 = dt.Rows[0]["备注"].ToString(); element.钥匙数 = Convert.ToInt32(dt.Rows[0]["钥匙数"]); element.工衣数 = Convert.ToInt32(dt.Rows[0]["工衣数"]); element.工牌数 = Convert.ToInt32(dt.Rows[0]["工牌数"]); element.是否全部回收 = Convert.ToBoolean(dt.Rows[0]["是否全部回收"]); return(element); } return(null); }
public static DepartmentLogic GetInstance() { if (instance == null) { instance = new DepartmentLogic(); } return(instance); }
private void LoadDeparts() { List <Department> elements = DepartmentLogic.GetInstance().GetAllDepartments(); comboBox5.Items.Clear(); comboBox5.Items.Add("--不限--"); foreach (Department element in elements) { comboBox5.Items.Add(element); } comboBox5.SelectedIndex = 0; }
private void btn_Dept_Click(object sender, EventArgs e) { if (comboBox1.SelectedIndex > -1) { Department depart = new Department(); depart.ID = data[comboBox1.SelectedIndex].ID; depart.Name = textBox1.Text.Trim(); depart.Manager = textBox3.Text.Trim(); Department parent = comboBox11.SelectedItem as Department; if (parent != null) { depart.ParentID = parent.ID; } depart.Remark = textBox2.Text; DepartmentLogic dl = DepartmentLogic.GetInstance(); if (dl.ExistsNameOther(depart.Name, depart.ID)) { if (MessageBox.Show("系统中已经存在该名称,确定还要继续保存么?", "重名提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK) { if (dl.UpdateDepartment(depart)) { data[comboBox1.SelectedIndex].Name = depart.Name; data[comboBox1.SelectedIndex].Manager = depart.Manager; data[comboBox1.SelectedIndex].ParentID = depart.ParentID; data[comboBox1.SelectedIndex].Remark = depart.Remark; RefreshInfo(); MessageBox.Show("修改成功!"); } } else { textBox1.Focus(); textBox1.SelectAll(); } } else { if (dl.UpdateDepartment(depart)) { data[comboBox1.SelectedIndex].Name = depart.Name; data[comboBox1.SelectedIndex].Manager = depart.Manager; data[comboBox1.SelectedIndex].ParentID = depart.ParentID; data[comboBox1.SelectedIndex].Remark = depart.Remark; RefreshInfo(); MessageBox.Show("修改成功!"); } } } else { MessageBox.Show("先选定要修改的项目!"); } }
private static Architecture GetRemoteArchitecture() { Architecture a = Architecture.Empty; a.Deps = DepartmentLogic.GetInstance().GetAllDepartments(); a.Ugroups = UserGroupLogic.GetInstance().GetAllUserGroups(); a.Users = UserLogic.GetInstance().GetAllUsers(); a.Mods = ModuleLogic.GetInstance().GetAllModules(); a.Acts = ActionLogic.GetInstance().GetAllActions(); a.Pers = PermissionLogic.GetInstance().GetAllPermissions(); a.Roles = RoleLogic.GetInstance().GetAllRoles(); return(a); }
/// <summary> /// 指定部门是否为我的后代 /// </summary> /// <param name="dep">指定部门</param> /// <param name="recursion">是否递归判断后代,默认为true,只找下一代为false</param> /// <returns></returns> public static bool IsMyChildren(this int thisDep, int depId, bool recursion = true) { int parentId = DepartmentLogic.GetInstance().GetDepartmentParentId(depId); if (parentId > 0) { if (parentId == thisDep) //dep=1.2,this=1 { return(true); //dep.parent=1 } if (recursion) //dep=1.2.3 { return(thisDep.IsMyChildren(parentId, true)); //dep=1.2.3,this=1.2 } } return(false); }
private void button12_Click(object sender, EventArgs e) { Department depart = new Department(); depart.Name = textBox1.Text.Trim(); depart.Manager = textBox3.Text.Trim(); Department parent = comboBox11.SelectedItem as Department; if (parent != null) { depart.ParentID = parent.ID; } depart.Remark = textBox2.Text; DepartmentLogic dl = DepartmentLogic.GetInstance(); if (dl.ExistsName(depart.Name)) { if (MessageBox.Show("系统中已经存在该名称,确定还要继续保存么?", "重名提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK) { int id = dl.AddDepartment(depart); if (id > 0) { depart.ID = id; data.Add(depart); RefreshInfo(); MessageBox.Show("添加成功!"); } } else { textBox1.Focus(); textBox1.SelectAll(); } } else { int id = dl.AddDepartment(depart); if (id > 0) { depart.ID = id; data.Add(depart); RefreshInfo(); MessageBox.Show("添加成功!"); } } }
public static List <int> GetDepartmentIds(string deps, DepartmentLogic dl = null) { List <int> depts = new List <int>(); string[] ids = deps.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (dl == null) { dl = DepartmentLogic.GetInstance(); } foreach (string id in ids) { int I; if (int.TryParse(id, out I)) { depts.Add(I); } } return(depts); }
public List <User> GetAllUsers() { List <User> users = new List <User>(); string sql = "select * from TF_User"; DataTable dt = sqlHelper.Query(sql); if (dt != null && dt.Rows.Count > 0) { DepartmentLogic dl = DepartmentLogic.GetInstance(); RoleLogic rl = RoleLogic.GetInstance(); UserGroupLogic ul = UserGroupLogic.GetInstance(); for (int i = 0; i < dt.Rows.Count; i++) { User user = new User(); user.ID = Convert.ToInt32(dt.Rows[i]["ID"]); user.Username = dt.Rows[i]["Username"].ToString(); user.Departments = Common.GetDepartments(dt.Rows[i]["Depart"].ToString(), dl); user.Flag = Convert.ToInt32(dt.Rows[i]["Flag"]); if (dt.Rows[i]["Password"] != null && dt.Rows[i]["Password"] != DBNull.Value) { user.Password = dt.Rows[i]["Password"].ToString(); } else { user.Password = ""; } if (dt.Rows[i]["Roles"] != null && dt.Rows[i]["Roles"] != DBNull.Value) { user.Roles = Common.GetRoles(dt.Rows[i]["Roles"].ToString(), rl); } if (dt.Rows[i]["Usergroup"] != null && dt.Rows[i]["Usergroup"] != DBNull.Value) { user.Usergroups = Common.GetUserGroups(dt.Rows[i]["Usergroup"].ToString(), ul); } if (dt.Rows[i]["Remark"] != null && dt.Rows[i]["Remark"] != DBNull.Value) { user.Remark = dt.Rows[i]["Remark"].ToString(); } users.Add(user); } } return(users); }
private void button1_Click(object sender, EventArgs e) { if (comboBox1.SelectedIndex > -1) { if (MessageBox.Show("确定要删除该项目?", "删除提醒", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK) { Department depart = data[comboBox1.SelectedIndex]; if (DepartmentLogic.GetInstance().DeleteDepartment(depart)) { data.RemoveAt(comboBox1.SelectedIndex); RefreshInfo(); } } } else { MessageBox.Show("先选定要删除的项目!"); } }