Ejemplo n.º 1
0
        /// <summary>
        /// Authes the logon.
        /// </summary>
        /// <returns></returns>
        private bool AuthLogon()
        {
            string sql = "StaffNumber = '" + txtUserName.Text.Trim().Replace("'", "") + "' AND Password = '******'", "") + "'";

            RT2020.DAL.Staff oStaff = RT2020.DAL.Staff.LoadWhere(sql);
            if (oStaff != null)
            {
                if (oStaff.Status > Convert.ToInt32(RT2020.DAL.Common.Enums.Status.Inactive.ToString("d")))
                {
                    if (!oStaff.Retired)
                    {
                        this.Context.Session.IsLoggedOn = AuthShopLogon();

                        Common.Utility.CurrentUserId = oStaff.StaffId;
                    }
                    else
                    {
                        this.lblErrorMessage.Text = "Staff was retired!";
                    }
                }
                else
                {
                    this.lblErrorMessage.Text = "Staff is inactivate! Please contact system administrator!";
                }
            }
            else
            {
                // When user inputs incorrect staff number or password, prompt user the error message.
                // To Do: We can try to limited the times of attempt to 5 or less.
                this.lblErrorMessage.Text       = "Incorrect Staff Number or Password! Please try again!";
                this.Context.Session.IsLoggedOn = false;
            }

            return(this.Context.Session.IsLoggedOn);
        }
Ejemplo n.º 2
0
 private string GetStaffName(Guid staffId)
 {
     RT2020.DAL.Staff oStaff = RT2020.DAL.Staff.Load(staffId);
     if (oStaff != null)
     {
         return(oStaff.StaffNumber);
     }
     else
     {
         return(string.Empty);
     }
 }
Ejemplo n.º 3
0
        public Guid IsAuth(string staffNumber, string password)
        {
            string query = "StaffNumber = '" + staffNumber.Trim().Replace("'", "") + "' AND Password = '******'", "") + "'";

            RT2020.DAL.Staff objStaff = RT2020.DAL.Staff.LoadWhere(query);
            if (objStaff != null)
            {
                return(objStaff.StaffId);
            }
            else
            {
                return(Guid.Empty);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Only support the ComboBox control from WinForm/Visual WebGUI
        /// </summary>
        /// <param name="ddList">the ComboBox control from WinForm/Visual WebGUI</param>
        /// <param name="TextField">e.g. new string[]{"FieldName1", "FieldName2", ...}</param>
        /// <param name="TextFormatString">e.g. "{0} - {1}"</param>
        /// <param name="SwitchLocale">Can be localized, if the FieldName has locale suffix, e.g. '_chs'</param>
        /// <param name="BlankLine">add blank label text to ComboBox or not</param>
        /// <param name="BlankLineText">the blank label text</param>
        /// <param name="ParentFilter">e.g. "ForeignFieldName = 'value'"</param>
        /// <param name="WhereClause">Where Clause for SQL Statement. e.g. "FieldName = 'SomeCondition'"</param>
        /// <param name="OrderBy">Sorting order, string array, e.g. {"FieldName1", "FiledName2"}</param>
        public static void LoadCombo(ref ComboBox ddList, string [] TextField, string TextFormatString, bool SwitchLocale, bool BlankLine, string BlankLineText, string ParentFilter, string WhereClause, string[] OrderBy)
        {
            if (SwitchLocale)
            {
                TextField = GetSwitchLocale(TextField);
            }
            ddList.Items.Clear();

            StaffCollection source;

            if (OrderBy == null || OrderBy.Length == 0)
            {
                OrderBy = TextField;
            }
            // Filter the retired records
            if (WhereClause.Length > 0)
            {
                WhereClause += " AND Retired = 0";
            }
            else
            {
                WhereClause = "Retired = 0";
            }

            if (WhereClause.Length > 0)
            {
                source = Staff.LoadCollection(WhereClause, OrderBy, true);
            }
            else
            {
                source = Staff.LoadCollection(OrderBy, true);
            }

            Common.ComboList sourceList = new Common.ComboList();

            if (BlankLine)
            {
                sourceList.Add(new Common.ComboItem(BlankLineText, Guid.Empty));
            }

            foreach (Staff item in source)
            {
                bool filter = false;
                if (ParentFilter.Trim() != String.Empty)
                {
                    filter = true;
                    if (item.DeptId != Guid.Empty)
                    {
                        filter = IgnorThis(item, ParentFilter);
                    }
                }
                if (!(filter))
                {
                    string code = GetFormatedText(item, TextField, TextFormatString);
                    sourceList.Add(new Common.ComboItem(code, item.StaffId));
                }
            }

            ddList.DataSource    = sourceList;
            ddList.DisplayMember = "Code";
            ddList.ValueMember   = "Id";

            if (ddList.Items.Count > 0)
            {
                ddList.SelectedIndex = 0;
            }
        }