private bool CheckLogin()
        {
            bool result = false;

            string sql = @"SELECT A.STCODE,A.FULLNAME AS STNAME, A.DPCODE
           FROM MAS_USER_SYSTEM A
            WHERE A.STCODE = @STCODE
            AND A.PASS = @STPASSWORD
            AND FLAG = 1";

            using (SqlConnection conn = new SqlConnection(_cBeauty.GetConnectionBS()))
            {
                conn.Open();
                try
                {
                    using (SqlCommand comm = new SqlCommand())
                    {
                        comm.CommandType    = CommandType.Text;
                        comm.CommandTimeout = 1000;
                        comm.Connection     = conn;

                        comm.CommandText = sql;
                        comm.Parameters.Clear();
                        comm.Parameters.AddWithValue("@STCODE", txtUser.Text);
                        comm.Parameters.AddWithValue("@STPASSWORD", txtPassword.Text);
                        var dataReader = comm.ExecuteReader();
                        var dataTable  = new DataTable();
                        dataTable.Load(dataReader);

                        if (dataTable.Rows.Count > 0)
                        {
                            //string sql_t = @"SELECT STCODE,TITLE FROM COMMISSION_STCODE_TITLE where CFLAG = 0 and stcode = '"+ txtUser.Text +"'";
                            //DataSet ds = cData.getDataSetWithSqlCommand(_cBeauty.GetConnectionBeautySystem(), sql_t, 10000, true);

                            //if (ds.Tables[0].Rows.Count > 0)
                            //{
                            //    foreach (DataRow dr in ds.Tables[0].Rows)
                            //    {
                            //        _cBeauty._STCODE_LOG_TITLE = dr["TITLE"].ToString();
                            //    }
                            //}

                            _cBeauty._STCODE_LOG_Main = dataTable.Rows[0]["STCODE"].ToString();
                            _cBeauty._DPCODE_LOG_Main = dataTable.Rows[0]["DPCODE"].ToString();
                            _cBeauty._STNAME_LOG_Main = dataTable.Rows[0]["STNAME"].ToString();
                            result = true;
                        }
                    }
                }
                catch (Exception ex)
                {
                    cMessage.Error_NotCaption(ex.Message);
                }
            }
            return(result);
        }
Пример #2
0
        private bool CheckLogin()
        {
            bool result = false;

            string sql = @"SELECT A.STCODE,A.FULLNAME AS STNAME, A.DPCODE
           FROM MAS_USER_SYSTEM A
            WHERE A.STCODE = @STCODE
            AND A.PASS = @STPASSWORD
            AND FLAG = 1";

            using (SqlConnection conn = new SqlConnection(_cBeauty.GetConnectionBS()))
            {
                conn.Open();
                try
                {
                    using (SqlCommand comm = new SqlCommand())
                    {
                        comm.CommandType    = CommandType.Text;
                        comm.CommandTimeout = 1000;
                        comm.Connection     = conn;

                        comm.CommandText = sql;
                        comm.Parameters.Clear();
                        comm.Parameters.AddWithValue("@STCODE", txtUser.Text);
                        comm.Parameters.AddWithValue("@STPASSWORD", txtPassword.Text);
                        var dataReader = comm.ExecuteReader();
                        var dataTable  = new DataTable();
                        dataTable.Load(dataReader);

                        if (dataTable.Rows.Count > 0)
                        {
                            _cBeauty._STCODE_LOG = dataTable.Rows[0]["STCODE"].ToString();
                            _cBeauty._DPCODE_LOG = dataTable.Rows[0]["DPCODE"].ToString();
                            _cBeauty._STNAME_LOG = dataTable.Rows[0]["STNAME"].ToString();
                            if (_DPCODE == _cBeauty._DPCODE_LOG)
                            {
                                result = true;
                            }
                            else
                            {
                                result = false;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    cMessage.Error_NotCaption(ex.Message);
                }
            }
            return(result);
        }