Exemple #1
0
 /// <summary>
 /// get table record
 /// <summary>
 /// <param name=hostname>hostname</param>
 /// <param name=out emsg>return error message</param>
 ///<returns>get a record detail of logloginhost</returns>
 public modLogLoginHost GetItem(string hostname, out string emsg)
 {
     try
     {
         //Execute a query to read the categories
         string sql = string.Format("select host_name,host_code,register_code,update_user,update_time from log_login_host where host_name='{0}' order by host_name", hostname);
         using (SqlDataReader rdr = SqlHelper.ExecuteReader(sql))
         {
             if (rdr.Read())
             {
                 modLogLoginHost model = new modLogLoginHost();
                 model.HostName     = dalUtility.ConvertToString(rdr["host_name"]);
                 model.HostCode     = dalUtility.ConvertToString(rdr["host_code"]);
                 model.RegisterCode = dalUtility.ConvertToString(rdr["register_code"]);
                 model.UpdateUser   = dalUtility.ConvertToString(rdr["update_user"]);
                 model.UpdateTime   = dalUtility.ConvertToDateTime(rdr["update_time"]);
                 emsg = null;
                 return(model);
             }
             else
             {
                 emsg = "Error on read data";
                 return(null);
             }
         }
     }
     catch (Exception ex)
     {
         emsg = dalUtility.ErrorMessage(ex.Message);
         return(null);
     }
 }
Exemple #2
0
 /// <summary>
 /// get all logloginhost
 /// <summary>
 /// <param name=out emsg>return error message</param>
 ///<returns>details of all logloginhost</returns>
 public BindingCollection <modLogLoginHost> GetIList(out string emsg)
 {
     try
     {
         BindingCollection <modLogLoginHost> modellist = new BindingCollection <modLogLoginHost>();
         //Execute a query to read the categories
         string sql = "select host_name,host_code,register_code,update_user,update_time from log_login_host order by host_name";
         using (SqlDataReader rdr = SqlHelper.ExecuteReader(sql))
         {
             while (rdr.Read())
             {
                 modLogLoginHost model = new modLogLoginHost();
                 model.HostName     = dalUtility.ConvertToString(rdr["host_name"]);
                 model.HostCode     = dalUtility.ConvertToString(rdr["host_code"]);
                 model.RegisterCode = dalUtility.ConvertToString(rdr["register_code"]);
                 model.UpdateUser   = dalUtility.ConvertToString(rdr["update_user"]);
                 model.UpdateTime   = dalUtility.ConvertToDateTime(rdr["update_time"]);
                 modellist.Add(model);
             }
         }
         emsg = null;
         return(modellist);
     }
     catch (Exception ex)
     {
         emsg = dalUtility.ErrorMessage(ex.Message);
         return(null);
     }
 }
Exemple #3
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;
            }
        }
Exemple #4
0
 /// <summary>
 /// insert a logloginhost
 /// <summary>
 /// <param name=mod>model object of logloginhost</param>
 /// <param name=out emsg>return error message</param>
 /// <returns>true/false</returns>
 public bool Insert(modLogLoginHost mod, out string emsg)
 {
     try
     {
         string sql = string.Format("insert into log_login_host(host_name,host_code,register_code,update_user,update_time)values('{0}','{1}','{2}','{3}',getdate())", mod.HostName, mod.HostCode, mod.RegisterCode, mod.UpdateUser);
         int    i   = SqlHelper.ExecuteNonQuery(sql);
         if (i > 0)
         {
             emsg = null;
             return(true);
         }
         else
         {
             emsg = "Unknown error when ExecuteNonQuery!";
             return(false);
         }
     }
     catch (Exception ex)
     {
         emsg = dalUtility.ErrorMessage(ex.Message);
         return(false);
     }
 }
Exemple #5
0
 /// <summary>
 /// update a logloginhost
 /// <summary>
 /// <param name=hostname>hostname</param>
 /// <param name=mod>model object of logloginhost</param>
 /// <param name=out emsg>return error message</param>
 /// <returns>true/false</returns>
 public bool Update(string hostname, modLogLoginHost mod, out string emsg)
 {
     try
     {
         string sql = string.Format("update log_login_host set host_code='{0}',register_code='{1}',update_user='******',update_time=getdate() where host_name='{3}'", mod.HostCode, mod.RegisterCode, mod.UpdateUser, hostname);
         int    i   = SqlHelper.ExecuteNonQuery(sql);
         if (i > 0)
         {
             emsg = null;
             return(true);
         }
         else
         {
             emsg = "Unknown error when ExecuteNonQuery!";
             return(false);
         }
     }
     catch (Exception ex)
     {
         emsg = dalUtility.ErrorMessage(ex.Message);
         return(false);
     }
 }
Exemple #6
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;
            }
        }