Beispiel #1
0
        //返回权限
        public int CheckLogin(string username, string password)
        {
            using (SqlConnection conn = new SqlConnection(Globals.ConnectionString))
            {
                //string password_md5 = CommonBLL.GetMD5Password(password);
                //get user password
                CommonDAL cdal = new CommonDAL(conn);
                DataRow dr = cdal.GetDR("select * from Server_D_UserInfor where UserName='******' ");


                if (null == dr) return -1;
                
                if (dr["UserPassWord"].Equals(password))
                {
                    //get total right value 
                    //get totalrightvalue ,isnull(dbo.f_GetUserTotalRightValue(id),0) as totalrightvalue
                    string sql = "select isnull(dbo.f_GetUserTotalRightValue('"+username+"'),0) as totalrightvalue ";
                    int totalrightvalue = Functions.ParseInt(cdal.GetFieldValueStringBySQL(sql, "totalrightvalue"), 0);
                    return totalrightvalue;
                }
                else
                {
                    return -2;
                }

          
            }

        }
Beispiel #2
0
        public bool IsUsernameExist(string username)
        {

            using (SqlConnection conn = new SqlConnection(Globals.ConnectionString))
            {
                CommonDAL cdal = new CommonDAL(conn);
                DataRow dr = cdal.GetDR("select * from Server_D_UserInfor where UserName='******' ");
                if (dr != null) return true;
                return false;
            }

        }
        // db-->ui
        private void DataFromDBToUI( )
        {
            if (PersonID.Equals("")) return;

            //PersonDAL pd = new PersonDAL(_conn);
            //DataRow p = pd.GetAPerson(PersonID);
            string sql = string.Format(_fieldsInfo.SQL, PersonID);//sql 中含有一个变量'{0}'
            CommonDAL cd = new CommonDAL(_conn);
            DataRow p = cd.GetDR(sql);

            //循环界面的ui元素
            for (int x = 0; x < FieldsHolderTable.Rows.Count; x++)
            {
                TableRow row = FieldsHolderTable.Rows[x];

                TextBox tb = (TextBox)row.Cells[1].Controls[0];
                string fieldName = tb.ID.Substring(4);
                string dbfield = _fieldsInfo.GetItem(fieldName).DBField;
                if (dbfield.Equals("")) continue;
                tb.Text = Functions.ParseStr(p[dbfield]);

            }
        }