private void checkBox1_CheckedChanged(object sender, EventArgs e) { this.Cursor = Cursors.WaitCursor; string userid = "READ"; string strPwd = Util.Encrypt("READ", Util.PWD_MASK); dalUserList bll = new dalUserList(); bool ret = bll.Login(userid, strPwd, out Util.emsg); if (ret) { modUserList mod = bll.GetItem(userid); Util.UserId = mod.UserId; Util.UserName = mod.UserName; Util.RoleId = mod.RoleId; Util.UserStatus = mod.Status; this.DialogResult = DialogResult.OK; this.Cursor = Cursors.Default; return; } else { //this.DialogResult = DialogResult.Cancel; this.Cursor = Cursors.Default; MessageBox.Show(Util.emsg, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } }
private void Login() { if (txtUserId.Text.Trim().Length == 0) { MessageBox.Show("User Id can not be null!"); txtUserId.Focus(); return; } if (txtPwd.Text.Trim().Length == 0) { MessageBox.Show("Password can not be null!"); txtPwd.Focus(); return; } this.Cursor = Cursors.WaitCursor; string userid = txtUserId.Text.Trim().ToString(); string strPwd = Util.Encrypt(txtPwd.Text.Trim().ToString(), Util.PWD_MASK); dalUserList dal = new dalUserList(); bool ret = dal.Login(userid, strPwd, out Util.emsg); if (ret) { modUserList mod = dal.GetItem(userid); Util.UserId = mod.UserId; Util.UserName = mod.UserName; Util.RoleId = mod.RoleId; dalRoleList role = new dalRoleList(); modRoleList modrole = role.GetItem(mod.RoleId, out Util.emsg); Util.RoleDesc = modrole.RoleDesc; Util.UserStatus = mod.Status; ini.IniWriteValue("login", "userid", userid); dalLogLoginHost bllhost = new dalLogLoginHost(); modLogLoginHost modhost = new modLogLoginHost(); modhost.HostName = Environment.MachineName; modhost.HostCode = Util.HOST_CODE; modhost.UpdateUser = Util.UserId; if (bllhost.Exists(modhost.HostName, out Util.emsg)) { bllhost.Update(modhost.HostName, modhost, out Util.emsg); } else { bllhost.Insert(modhost, out Util.emsg); } this.DialogResult = DialogResult.OK; this.Cursor = Cursors.Default; return; } else { //this.DialogResult = DialogResult.Cancel; this.Cursor = Cursors.Default; MessageBox.Show(Util.emsg, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } }
/// <summary> /// get all already granted data /// <summary> /// <param name=roleid>roleid</param> ///<returns>Details about all TaskGrant</returns> public BindingCollection <modTaskGrant> GetAllUserTask(string userid, out string emsg) { try { dalUserList daluser = new dalUserList(); modUserList moduser = daluser.GetItem(userid); BindingCollection <modTaskGrant> modellist = new BindingCollection <modTaskGrant>(); string sql = string.Format("select a.task_code,b.task_name,b.form_name,b.group_id,b.task_type,b.url,b.web_url from sys_task_grant a,sys_task_list b where a.task_code=b.task_code and a.role_id= '{0}' and b.status=1 order by a.task_code", userid); using (SqlDataReader rdr = SqlHelper.ExecuteReader(sql)) { while (rdr.Read()) { modTaskGrant model = new modTaskGrant(); model.TaskCode = rdr["task_code"].ToString(); model.TaskName = rdr["task_name"].ToString(); model.TaskType = rdr["task_type"].ToString(); model.FormName = rdr["form_name"].ToString(); model.GroupId = rdr["group_id"].ToString(); model.Url = rdr["url"].ToString(); model.WebUrl = rdr["web_url"].ToString(); model.Checked = true; modellist.Add(model); } } sql = string.Format("select a.task_code,a.task_name,a.form_name,a.group_id,a.task_type,a.url,a.web_url from sys_task_list a where a.status=1 and not exists (select '#' from sys_task_grant where task_code =a.task_code and (role_id='{0}' or role_id='{1}'))", moduser.RoleId, userid); using (SqlDataReader rdr = SqlHelper.ExecuteReader(sql)) { while (rdr.Read()) { modTaskGrant model = new modTaskGrant(); model.TaskCode = rdr["task_code"].ToString(); model.TaskName = rdr["task_name"].ToString(); model.TaskType = rdr["task_type"].ToString(); model.FormName = rdr["form_name"].ToString(); model.GroupId = rdr["group_id"].ToString(); model.Url = rdr["url"].ToString(); model.WebUrl = rdr["web_url"].ToString(); model.Checked = false; modellist.Add(model); } } emsg = string.Empty; return(modellist); } catch (Exception ex) { emsg = dalUtility.ErrorMessage(ex.Message); return(null); } }
private void txtFind_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == 13 || e.KeyChar == 32) { if (string.IsNullOrEmpty(txtFind2.Text.Trim())) { MessageBox.Show("Please enter the text you want to find!", clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } dalUserList bll = new dalUserList(); modUserList mod = bll.GetItem(txtFind2.Text.Trim().ToUpper()); if (mod == null) { MessageBox.Show("No data found!", clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else { for (int i = 0; i < tvUser2.Nodes.Count; i++) { if (tvUser2.Nodes[i].GetNodeCount(false) > 0) { for (int j = 0; j < tvUser2.Nodes[i].GetNodeCount(false); j++) { if (mod.UserId == tvUser2.Nodes[i].Nodes[j].Name) { tvUser2.Nodes[i].Expand(); tvUser2.SelectedNode = tvUser2.Nodes[i].Nodes[j]; TreeViewEventArgs ea = new TreeViewEventArgs(tvUser2.SelectedNode); tvUser2_AfterSelect(null, ea); break; } } } } } } else { e.KeyChar = Convert.ToChar(e.KeyChar.ToString().ToUpper()); } }
private void Login() { if (txtSystemTime.Text.Trim() != txtServerTime.Text.Trim()) { DateTime dt1 = DateTime.Parse(txtSystemTime.Text); DateTime dt2 = DateTime.Parse(txtServerTime.Text); TimeSpan ts = new TimeSpan(dt1.Ticks - dt2.Ticks); if (Math.Abs(ts.Days) > 1 || Math.Abs(ts.Minutes) > 2 || Math.Abs(ts.Hours) > 1 || Math.Abs(ts.Days) > 1) { MessageBox.Show(clsTranslate.TranslateString("local time must equal to server time,please adjust your system time first!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); txtSystemTime.Focus(); return; } } if (cboPeriodList.Items.Count == 0) { btnNew_Click(null, null); return; } if (txtUserId.Text.Trim().Length == 0) { MessageBox.Show("User Id can not be null!"); txtUserId.Focus(); return; } if (txtPwd.Text.Trim().Length == 0) { MessageBox.Show("Password can not be null!"); txtPwd.Focus(); return; } this.Cursor = Cursors.WaitCursor; string userid = txtUserId.Text.Trim().ToString(); string strPwd = Util.Encrypt(txtPwd.Text.Trim().ToString(), Util.PWD_MASK); dalUserList dal = new dalUserList(); bool ret = dal.Login(userid, strPwd, out Util.emsg); if (ret) { modUserList mod = dal.GetItem(userid); Util.UserId = mod.UserId; Util.UserName = mod.UserName; Util.RoleId = mod.RoleId; dalRoleList role = new dalRoleList(); modRoleList modrole = role.GetItem(mod.RoleId, out Util.emsg); Util.RoleDesc = modrole.RoleDesc; Util.UserStatus = mod.Status; ini.IniWriteValue("login", "userid", userid); dalAccCurrencyList dalcur = new dalAccCurrencyList(); modAccCurrencyList modcur = dalcur.GetOwnerItem(out Util.emsg); Util.Currency = modcur.Currency; dalLogLoginHost bllhost = new dalLogLoginHost(); modLogLoginHost modhost = new modLogLoginHost(); modhost.HostName = Environment.MachineName; Util.modperiod = (modAccPeriodList)cboPeriodList.SelectedItem; clsLxms.CheckSoftwareRegister(); if (Util.SOFT_REGISTER) { modhost.RegisterCode = Util.REGISTER_CODE; } else { modhost.RegisterCode = string.Empty; if (cboPeriodList.Items.Count >= 7) { frmSoftRegister frm = new frmSoftRegister(); if (frm.ShowDialog() != DialogResult.OK) { return; } } } modhost.HostCode = Util.HOST_CODE; modhost.UpdateUser = Util.UserId; if (bllhost.Exists(modhost.HostName, out Util.emsg)) { bllhost.Update(modhost.HostName, modhost, out Util.emsg); } else { bllhost.Insert(modhost, out Util.emsg); } this.DialogResult = DialogResult.OK; this.Cursor = Cursors.Default; return; } else { //this.DialogResult = DialogResult.Cancel; this.Cursor = Cursors.Default; MessageBox.Show(Util.emsg, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } }