public DataTable Select(ref string error, TableName table, object selectType, string strValue = "") { string strTableName = table.ToString(); string strType = selectType.ToString(); string sql = ""; SqlParameter[] sqlParameters = new SqlParameter[] { }; switch (selectType) { case EnumConst.NhanVien.All: case EnumConst.SinhVien.All: case EnumConst.Phong.All: case EnumConst.PhieuDK.All: case EnumConst.HoaDon.All: case EnumConst.DichVu.All: case EnumConst.LoaiPhong.All: sql = $"SELECT * FROM {strTableName}"; break; default: strValue = "%" + strValue + "%"; sql = $"SELECT * FROM {strTableName} WHERE {strType} LIKE @Value"; sqlParameters = new SqlParameter[] { new SqlParameter("Value", strValue) }; break; } return(db.ExecuteQuery(sql, sqlParameters, CommandType.Text, ref error)); }
public bool Select(string TenDN, string MatKhau, ref string MaNV, ref AccountType accountType, ref string error) { string sql = "SELECT * FROM DANGNHAP WHERE TenDN = @TenDN AND MatKhau = @MatKhau"; SqlParameter[] sqlParameters = new SqlParameter[] { new SqlParameter("TenDN", TenDN), new SqlParameter("MatKhau", MatKhau) }; DataTable table = db.ExecuteQuery(sql, sqlParameters, CommandType.Text, ref error); if (table.Rows.Count > 0) { MaNV = table.Rows[0]["MaNV"].ToString(); string err = "", MaNQL = "zzz"; var tmp = FrmMain.bS_Layer.Select(ref err, BS_layer.TableName.NhanVien, EnumConst.NhanVien.MaNV, MaNV); if (err == "") { MaNQL = tmp.Rows[0]["MaNQL"].ToString(); } accountType = (MaNQL != "") ? AccountType.Employee : AccountType.Addmin; return(true); } else { return(false); } }