Esempio n. 1
0
        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;
            }
        }
Esempio n. 2
0
        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;
            }
        }
Esempio n. 3
0
 protected override void Find()
 {
     for (int i = 0; i < DBGrid.Rows.Count; i++)
     {
         modUserList mod = (modUserList)DBGrid.Rows[i].DataBoundItem;
         if (mod.UserId.CompareTo(FindText) == 0 || mod.UserName.IndexOf(FindText) > 0)
         {
             DBGrid.CurrentCell = DBGrid.Rows[i].Cells[0];
             DBGrid_SelectionChanged(null, null);
             return;
         }
     }
 }
Esempio n. 4
0
        /// <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);
            }
        }
Esempio n. 5
0
        protected override bool Save()
        {
            if (string.IsNullOrEmpty(txtUserId.Text.Trim()))
            {
                MessageBox.Show(clsTranslate.TranslateString("store id") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtUserId.Focus();
                return(false);
            }
            if (string.IsNullOrEmpty(txtUserName.Text.Trim()))
            {
                MessageBox.Show(clsTranslate.TranslateString("store name") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtUserName.Focus();
                return(false);
            }
            if (cboRoleId.SelectedValue == null)
            {
                MessageBox.Show(clsTranslate.TranslateString("Role Id") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                cboRoleId.Focus();
                return(false);
            }
            if (string.IsNullOrEmpty(_roleid))
            {
                MessageBox.Show(clsTranslate.TranslateString("Role Id") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                tvLeft.Focus();
                return(false);
            }
            int?   status   = cboStatus.SelectedIndex;
            string password = Util.Encrypt(txtUserId.Text.Trim(), Util.PWD_MASK);

            modUserList mod = new modUserList(txtUserId.Text.Trim(), txtUserName.Text.Trim(), status, password, cboRoleId.SelectedValue.ToString(), Util.UserId, DateTime.Now, txtEmail.Text.Trim());
            bool        ret = false;

            if (_status == 1)
            {
                ret = _dal.Insert(mod, out Util.emsg);
            }
            else if (_status == 2)
            {
                ret = _dal.Update(txtUserId.Text, mod, out Util.emsg);
            }
            if (ret)
            {
                Util.ChangeStatus(this, true);
                LoadData();
                FindText = mod.UserId;
                Find();
            }
            return(ret);
        }
Esempio n. 6
0
 private void DBGrid_SelectionChanged(object sender, EventArgs e)
 {
     if (DBGrid.CurrentRow != null)
     {
         modUserList mod = (modUserList)DBGrid.CurrentRow.DataBoundItem;
         txtUserId.Text          = mod.UserId;
         txtUserName.Text        = mod.UserName;
         cboStatus.SelectedIndex = Convert.ToInt32(mod.Status);
         cboRoleId.SelectedValue = mod.RoleId;
         txtEmail.Text           = mod.Email;
         FindText = mod.UserId;
     }
     else
     {
         Util.EmptyFormBox(this);
     }
 }
Esempio n. 7
0
        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());
            }
        }
Esempio n. 8
0
        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;
            }
        }