public List <FormObject> GetFormObjectsByUser(User user) { List <FormObject> elements = new List <FormObject>(); string sql = "select * from TF_FormObject where Owner=" + user.ID; DataTable dt = sqlHelper.Query(sql); if (dt != null && dt.Rows.Count > 0) { FormTypeLogic ftl = FormTypeLogic.GetInstance(); FormItemLogic fil = FormItemLogic.GetInstance(); UserLogic ul = UserLogic.GetInstance(); for (int i = 0; i < dt.Rows.Count; i++) { FormObject element = new FormObject(); element.ID = Convert.ToInt32(dt.Rows[i]["ID"]); element.FormName = dt.Rows[i]["FormName"].ToString(); element.FormType = ftl.GetFormType(Convert.ToInt32(dt.Rows[i]["FormType"])); element.FormItems = fil.GetFormItemsByIds(dt.Rows[i]["FormItems"].ToString()); element.Owner = ul.GetUser(Convert.ToInt32(dt.Rows[i]["Owner"])); element.Remark = dt.Rows[i]["Remark"].ToString(); elements.Add(element); } } return(elements); }
private void button2_Click(object sender, EventArgs e) { string oldPwd = textBox1.Text; if (!this.user.Password.Equals(oldPwd, StringComparison.InvariantCultureIgnoreCase)) { MessageBox.Show("原密码有误!请重新输入。"); textBox1.Focus(); textBox1.SelectAll(); return; } string newPwd = textBox2.Text; string newPwd2 = textBox3.Text; if (newPwd != newPwd2) { MessageBox.Show("新密码确认有误!请重新确认。"); return; } if (UserLogic.GetInstance().ChangePwd(this.user.ID, newPwd)) { this.user.Password = newPwd; MessageBox.Show("密码修改成功!"); } else { MessageBox.Show("密码修改失败!"); } this.Close(); }
public List <DocObject> GetAllDocObjects() { List <DocObject> elements = new List <DocObject>(); string sql = "select * from TF_DocObject"; DataTable dt = sqlHelper.Query(sql); if (dt != null && dt.Rows.Count > 0) { FormObjectLogic fol = FormObjectLogic.GetInstance(); FormItemLogic fil = FormItemLogic.GetInstance(); UserLogic ul = UserLogic.GetInstance(); for (int i = 0; i < dt.Rows.Count; i++) { DocObject element = new DocObject(); element.ID = Convert.ToInt32(dt.Rows[i]["ID"]); element.Name = dt.Rows[i]["Name"].ToString(); element.Form = fol.GetFormObject(Convert.ToInt32(dt.Rows[i]["FormID"])); element.DocItems = fil.GetFormItemsByIds(dt.Rows[i]["DocItems"].ToString()); element.Owner = ul.GetUser(Convert.ToInt32(dt.Rows[i]["Owner"])); element.Remark = dt.Rows[i]["Remark"].ToString(); element.Flag = Convert.ToInt32(dt.Rows[i]["Flag"]); 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); }
public List <DocObject> GetDocObjectsByTemplateId(List <int> flowTemplateIds) { List <DocObject> elements = new List <DocObject>(); if (flowTemplateIds != null && flowTemplateIds.Count > 0) { string sql = "select TF_DocObject.* from TF_DocObject,TaskInfo,Flow,FlowTemplate where TF_DocObject.ID=TaskInfo.EntityId and TaskInfo.FlowID=Flow.ID and Flow.TemplateID in (" + flowTemplateIds + ")"; DataTable dt = sqlHelper.Query(sql); if (dt != null && dt.Rows.Count > 0) { FormObjectLogic fol = FormObjectLogic.GetInstance(); FormItemLogic fil = FormItemLogic.GetInstance(); UserLogic ul = UserLogic.GetInstance(); for (int i = 0; i < dt.Rows.Count; i++) { DocObject element = new DocObject(); element.ID = Convert.ToInt32(dt.Rows[i]["ID"]); element.Name = dt.Rows[i]["Name"].ToString(); element.Form = fol.GetFormObject(Convert.ToInt32(dt.Rows[i]["FormID"])); element.DocItems = fil.GetFormItemsByIds(dt.Rows[i]["DocItems"].ToString()); element.Owner = ul.GetUser(Convert.ToInt32(dt.Rows[i]["Owner"])); element.Remark = dt.Rows[i]["Remark"].ToString(); element.Flag = Convert.ToInt32(dt.Rows[i]["Flag"]); elements.Add(element); } } } return(elements); }
private void button2_Click(object sender, EventArgs e) { User user = new User(); user.Username = textBox1.Text.Trim(); user.Remark = textBox2.Text; user.Flag = 0; ConfigEntity ce = comboBox3.SelectedItem as ConfigEntity; if (ce != null) { user.Flag = ce.extension; } user.Password = textBox3.Text; Department dep = comboBox2.SelectedItem as Department; if (dep != null) { user.Departments.Clear(); user.Departments.Add(dep); } UserLogic ul = UserLogic.GetInstance(); if (ul.ExistsName(user.Username)) { if (MessageBox.Show("系统中已经存在该名称,确定还要继续保存么?", "重名提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK) { int id = ul.AddUser(user); if (id > 0) { user.ID = id; data.Add(user); RefreshInfo(); MessageBox.Show("添加成功!"); } } else { textBox1.Focus(); textBox1.SelectAll(); } } else { int id = ul.AddUser(user); if (id > 0) { user.ID = id; data.Add(user); RefreshInfo(); MessageBox.Show("添加成功!"); } } }
private List <User> GetUsers(List <string> list) { List <User> users = new List <User>(); UserLogic ul = UserLogic.GetInstance(); foreach (string id in list) { users.Add(ul.GetUser(Convert.ToInt32(id))); } return(users); }
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); }
public List <Attachment> GetAttachmentsByIds(string items) { List <Attachment> attachs = new List <Attachment>(); if (!string.IsNullOrEmpty(items)) { string[] ss = items.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (ss.Length > 0) { StringBuilder sb = new StringBuilder(); foreach (string s in ss) { string id = s.Trim(); int ID; if (int.TryParse(id, out ID)) { if (sb.Length == 0) { sb.Append(id); } else { sb.Append("," + id); } } } if (sb.Length > 0) { string sql = "select * from TF_Attachment where ID in (" + sb.ToString() + ")"; DataTable dt = sqlHelper.Query(sql); if (dt != null && dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { Attachment attach = new Attachment(); attach.ID = Convert.ToInt32(dt.Rows[i]["ID"]); attach.AttachmentFilename = dt.Rows[i]["AttachmentFilename"].ToString(); attach.Size = Convert.ToInt64(dt.Rows[i]["Size"]); attach.Uploader = UserLogic.GetInstance().GetUser(Convert.ToInt32(dt.Rows[i]["Uploader"])); attach.UploadTime = Convert.ToDateTime(dt.Rows[i]["UploadTime"]); attach.Flag = Convert.ToInt32(dt.Rows[i]["Flag"]); attachs.Add(attach); } } } } } return(attachs); }
public bool Login(TextBox textBox1, TextBox textBox2) { string use = textBox1.Text.Trim(); string pwd = textBox2.Text; if (use != string.Empty) { RefreshMsg("正在获取用户信息..."); User user = UserLogic.GetInstance().GetUser(use); if (user != null && user.Flag == 0) { if (user.Password == pwd) { if (this.User != null && this.User.ID != user.ID) { //关掉所有的已经打开的窗口... foreach (TabPage page in tabControl1.TabPages) { CloseSubForm(page); } } this.User = user; toolStripStatusLabel3.Text = "当前用户:" + user.Username; WriteLog.CreateLog(this.User.Username, "MainForm.Login", "log", "用户:" + user.Username); UnlockSystem(); RefreshMsg("Ready..."); return(true); } else { MessageBox.Show("密码错误!"); textBox2.SelectAll(); textBox2.Focus(); } } else { MessageBox.Show("用户名错误或者该用户已经被禁用!"); textBox1.SelectAll(); textBox1.Focus(); } } else { MessageBox.Show("请输入用户名!"); textBox1.Focus(); } return(false); }
public Attachment GetAttachment(int id) { string sql = "select * from TF_Attachment where ID=" + id; DataTable dt = sqlHelper.Query(sql); if (dt != null && dt.Rows.Count > 0) { Attachment attach = new Attachment(); attach.ID = id; attach.AttachmentFilename = dt.Rows[0]["AttachmentFilename"].ToString(); attach.Size = Convert.ToInt64(dt.Rows[0]["Size"]); attach.Uploader = UserLogic.GetInstance().GetUser(Convert.ToInt32(dt.Rows[0]["Uploader"])); attach.UploadTime = Convert.ToDateTime(dt.Rows[0]["UploadTime"]); attach.Flag = Convert.ToInt32(dt.Rows[0]["Flag"]); return(attach); } return(null); }
public FormObject GetFormObject(int id) { string sql = "select * from TF_FormObject where ID=" + id; DataTable dt = sqlHelper.Query(sql); if (dt != null && dt.Rows.Count > 0) { FormObject element = new FormObject(); element.ID = id; element.FormName = dt.Rows[0]["FormName"].ToString(); element.FormType = FormTypeLogic.GetInstance().GetFormType(Convert.ToInt32(dt.Rows[0]["FormType"])); element.FormItems = FormItemLogic.GetInstance().GetFormItemsByIds(dt.Rows[0]["FormItems"].ToString()); element.Owner = UserLogic.GetInstance().GetUser(Convert.ToInt32(dt.Rows[0]["Owner"])); element.Remark = dt.Rows[0]["Remark"].ToString(); return(element); } return(null); }
private void button7_Click(object sender, EventArgs e) { if (comboBox1.SelectedIndex > -1) { if (MessageBox.Show("确定要删除该项目?", "删除提醒", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK) { User user = data[comboBox1.SelectedIndex]; if (UserLogic.GetInstance().DeleteUser(user)) { data.RemoveAt(comboBox1.SelectedIndex); RefreshInfo(); } } } else { MessageBox.Show("先选定要删除的项目!"); } }
public List <Attachment> GetAllAttachments() { List <Attachment> attachs = new List <Attachment>(); string sql = "select * from TF_Attachment"; DataTable dt = sqlHelper.Query(sql); if (dt != null && dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { Attachment attach = new Attachment(); attach.ID = Convert.ToInt32(dt.Rows[i]["ID"]); attach.AttachmentFilename = dt.Rows[i]["AttachmentFilename"].ToString(); attach.Size = Convert.ToInt64(dt.Rows[i]["Size"]); attach.Uploader = UserLogic.GetInstance().GetUser(Convert.ToInt32(dt.Rows[i]["Uploader"])); attach.UploadTime = Convert.ToDateTime(dt.Rows[i]["UploadTime"]); attach.Flag = Convert.ToInt32(dt.Rows[i]["Flag"]); attachs.Add(attach); } } return(attachs); }
private void btn_User_Click(object sender, EventArgs e) { if (comboBox1.SelectedIndex > -1) { User user = new User(); user.ID = data[comboBox1.SelectedIndex].ID; user.Username = textBox1.Text.Trim(); user.Remark = textBox2.Text; user.Password = textBox3.Text; Department dep = comboBox2.SelectedItem as Department; if (dep != null) { user.Departments.Clear(); user.Departments.Add(dep); } user.Flag = 0; ConfigEntity ce = comboBox3.SelectedItem as ConfigEntity; if (ce != null) { user.Flag = ce.extension; } UserLogic ul = UserLogic.GetInstance(); if (ul.ExistsNameOther(user.Username, user.ID)) { if (MessageBox.Show("系统中已经存在该名称,确定还要继续保存么?", "重名提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK) { if (ul.UpdateUser(user)) { data[comboBox1.SelectedIndex].Username = user.Username; data[comboBox1.SelectedIndex].Password = user.Password; data[comboBox1.SelectedIndex].Flag = user.Flag; data[comboBox1.SelectedIndex].Departments = user.Departments; data[comboBox1.SelectedIndex].Remark = user.Remark; RefreshInfo(); MessageBox.Show("修改成功!"); } } else { textBox1.Focus(); textBox1.SelectAll(); } } else { if (ul.UpdateUser(user)) { data[comboBox1.SelectedIndex].Username = user.Username; data[comboBox1.SelectedIndex].Password = user.Password; data[comboBox1.SelectedIndex].Flag = user.Flag; data[comboBox1.SelectedIndex].Departments = user.Departments; data[comboBox1.SelectedIndex].Remark = user.Remark; RefreshInfo(); MessageBox.Show("修改成功!"); } } } else { MessageBox.Show("先选定要修改的项目!"); } }