private void LoadTree() { try { this.Cursor = Cursors.WaitCursor; tvLeft.AllowDrop = true; tvLeft.Nodes.Clear(); tvLeft.ImageList = Util.GetImageList(); dalRoleList bll = new dalRoleList(); BindingCollection <modRoleList> list = bll.GetIList(true, out Util.emsg); if (list != null) { foreach (modRoleList mod in list) { tvLeft.Nodes.Add(mod.RoleId, mod.RoleDesc, 0, 1); } if (tvLeft.Nodes.Count > 0) { tvLeft.SelectedNode = tvLeft.Nodes[0]; } } } catch (Exception ex) { MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } finally { this.Cursor = Cursors.Default; } }
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; } }
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; } }
private void SEC_TASK_GRANT_Load(object sender, EventArgs e) { try { this.Cursor = Cursors.WaitCursor; dalRoleList bll = new dalRoleList(); //DataSet ds = bll.GetRoleList(true, out Util.emsg); tvUser2.ImageList = Util.GetImageList(); BindingCollection <modRoleList> rolelist = new BindingCollection <modRoleList>(); rolelist = bll.GetIList(true, out Util.emsg); if (rolelist != null) { comboBox1.ValueMember = "RoleId"; comboBox1.DisplayMember = "RoleDesc"; comboBox1.DataSource = rolelist; if (comboBox1.Items.Count > 0) { comboBox1.SelectedIndex = 0; //LoadListBox(); } foreach (modRoleList role in rolelist) { dalUserList _ubll = new dalUserList(); BindingCollection <modUserList> userlist = _ubll.GetIList(role.RoleId, out Util.emsg); if (userlist != null) { TreeNode tn = tvUser2.Nodes.Add(role.RoleId, role.RoleDesc, 0, 1); foreach (modUserList user in userlist) { TreeNode node = tn.Nodes.Add(user.UserId, user.UserName, 2, 3); node.ToolTipText = node.Name; } } } tvUser2.ShowNodeToolTips = true; dalTaskList task = new dalTaskList(); BindingCollection <modTaskList> tasklist = task.GetIList(string.Empty, true, false, out Util.emsg); DBGrid2.DataSource = tasklist; for (int j = 0; j < DBGrid2.RowCount; j++) { DBGrid2.Rows[j].Cells["Taskname"].Value = clsTranslate.TranslateString(DBGrid2.Rows[j].Cells["Taskname"].Value.ToString()); } DataGridViewCheckBoxColumn checkboxColumn = new DataGridViewCheckBoxColumn(); checkboxColumn.HeaderText = clsTranslate.TranslateString("Select"); checkboxColumn.DataPropertyName = "Select"; DBGrid2.Columns.Insert(0, checkboxColumn); DBGrid2.Columns[9].Visible = false; DBGrid2.Columns[8].Visible = false; DBGrid2.Columns[7].Visible = false; DBGrid2.Columns[6].Visible = false; DBGrid2.Columns[5].Visible = false; DBGrid2.Columns[4].Visible = false; DBGrid2.Columns[3].Visible = false; //DBGrid2.Columns[8].ReadOnly = true; //DBGrid2.Columns[7].ReadOnly = true; //DBGrid2.Columns[6].ReadOnly = true; //DBGrid2.Columns[5].ReadOnly = true; //DBGrid2.Columns[4].ReadOnly = true; //DBGrid2.Columns[3].ReadOnly = true; DBGrid2.Columns[2].ReadOnly = true; DBGrid2.Columns[1].ReadOnly = true; //Util.AutoSetColWidth(1, DBGrid2); DBGrid2.AllowUserToAddRows = false; } } catch (Exception ex) { MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } finally { this.Cursor = Cursors.Default; } }