本文整理汇总了C#中DataAccess.ConnectToDatabase方法的典型用法代码示例。如果您正苦于以下问题:C# DataAccess.ConnectToDatabase方法的具体用法?C# DataAccess.ConnectToDatabase怎么用?C# DataAccess.ConnectToDatabase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataAccess
的用法示例。
在下文中一共展示了DataAccess.ConnectToDatabase方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadIndicator
public void LoadIndicator(string Program, DropDownList dropdownIndicator)
{
data = new DataAccess();
data.ConnectToDatabase();;
try
{
SqlCommand cmdTxt = new SqlCommand("SELECT IndicatorData FROM Indicator WHERE ProgramCategoryID ="+
"(SELECT ProgramCategoryID FROM ProgramCategory WHERE ProgramData = @Program)",data.Connection);
cmdTxt.Parameters.Add("@Program", SqlDbType.Char).Value = Program;
SqlDataReader dr = cmdTxt.ExecuteReader();
while (dr.Read())
{
dropdownIndicator.Items.Add(dr.GetString(0).Trim());
}
dr.Close();
}
catch (Exception)
{
}
finally
{
data.CloseDatabase();
}
}
示例2: GetBarangayName
public string GetBarangayName(int BarangayID)
{
data = new DataAccess();
data.ConnectToDatabase();;
SqlCommand cmdTxt = new SqlCommand("SELECT BarangayName FROM Barangays WHERE BarangayID = @BarangayID",data.Connection);
cmdTxt.Parameters.Add("@BarangayID", SqlDbType.VarChar).Value = BarangayID;
SqlDataReader dr = cmdTxt.ExecuteReader();
dr.Read();
string BarangayName = dr.GetString(0);
dr.Close();
data.CloseDatabase();
return BarangayName;
}
示例3: HasSamePhilhealth
//Check Birthdate Also
public bool HasSamePhilhealth(string PhilhealthNumber)
{
data = new DataAccess();
data.ConnectToDatabase(); ;
SqlCommand cmdTxt = new SqlCommand("SELECT COUNT(*) FROM Patients WHERE PtFaxNumber = @philhealthNum", data.Connection);
cmdTxt.Parameters.Add("@philhealthNum", SqlDbType.VarChar).Value = PhilhealthNumber;
int check = (int)cmdTxt.ExecuteScalar();
data.CloseDatabase();
if (check > 0)
return true;
else
return false;
}
示例4: GetBarangayID
public int GetBarangayID(string BarangayName)
{
data = new DataAccess();
data.ConnectToDatabase();;
SqlCommand cmdTxt = new SqlCommand("SELECT BarangayID FROM Barangays WHERE BarangayName = @BarangayName",data.Connection);
cmdTxt.Parameters.Add("@BarangayName", SqlDbType.VarChar).Value = BarangayName;
SqlDataReader dr = cmdTxt.ExecuteReader();
dr.Read();
int id = dr.GetInt32(0);
dr.Close();
data.CloseDatabase();
return id;
}
示例5: CountIndicatorPerProgram
public int CountIndicatorPerProgram(string Program)
{
int count = 0;
data = new DataAccess();
data.ConnectToDatabase();;
SqlCommand cmdTxt = new SqlCommand("SELECT COUNT(*) FROM Indicator WHERE ProgramCategoryID = " +
"(SELECT ProgramCategoryID FROM ProgramCategory WHERE ProgramData = @data)",data.Connection);
cmdTxt.Parameters.Add("@data", SqlDbType.VarChar).Value = Program;
count = (int)cmdTxt.ExecuteScalar();
data.CloseDatabase();
return count;
}
示例6: GetIndicatorId
public int GetIndicatorId(string IndicatorData)
{
data = new DataAccess();
data.ConnectToDatabase();;
SqlCommand cmdTxt = new SqlCommand("SELECT IndicatorID FROM Indicator WHERE IndicatorData = @IndicatorData",data.Connection);
cmdTxt.Parameters.Add("@IndicatorData", SqlDbType.Char).Value = IndicatorData.Trim();
SqlDataReader dr = cmdTxt.ExecuteReader();
dr.Read();
int id = dr.GetInt32(0);
dr.Close();
data.CloseDatabase();
return id;
}
示例7: GetMedicineQuantity
public int GetMedicineQuantity(int MedicineId)
{
data = new DataAccess();
data.ConnectToDatabase();
SqlCommand cmdTxt = new SqlCommand("SELECT Quantity FROM Medicine WHERE MedicineId = @aa",data.Connection);
cmdTxt.Parameters.Add("@aa", SqlDbType.Int).Value = MedicineId;
SqlDataReader id = cmdTxt.ExecuteReader();
id.Read();
int quantity = Int32.Parse(id["Quantity"].ToString());
id.Close();
data.CloseDatabase();
return quantity;
}
示例8: GetMedicineId
public int GetMedicineId(string MedicineName)
{
data = new DataAccess();
data.ConnectToDatabase();
SqlCommand cmdTxt = new SqlCommand("SELECT MedicineId FROM Medicine WHERE MedicineName = @aa",data.Connection);
cmdTxt.Parameters.Add("@aa", SqlDbType.Char).Value = MedicineName;
SqlDataReader id = cmdTxt.ExecuteReader();
id.Read();
int retId = id.GetInt32(0);
id.Close();
data.CloseDatabase();
return retId;
}
示例9: GetDiseaseCategory
public List<string> GetDiseaseCategory()
{
List<string> category;
data = new DataAccess();
data.ConnectToDatabase();
category = new List<string>();
SqlCommand cmdTxt = new SqlCommand("Select DiseaseCategoryName From DiseaseCategory",data.Connection);
SqlDataReader dr = cmdTxt.ExecuteReader();
while (dr.Read())
{
category.Add(dr.GetString(0).ToString().Trim());
}
dr.Close();
data.CloseDatabase();
return category;
}
示例10: SavePatientDisease
public bool SavePatientDisease(string PatientID, string DiseaseName, DateTime encTimeSaved)
{
data = new DataAccess();
data.ConnectToDatabase();;
SqlCommand cmdTxt = new SqlCommand("SaveDiseases",data.Connection);
cmdTxt.CommandType = CommandType.StoredProcedure;
cmdTxt.Parameters.Add("@encDateTime", SqlDbType.DateTime).Value = encTimeSaved;
cmdTxt.Parameters.Add("@DiseaseName", SqlDbType.VarChar).Value = DiseaseName;
cmdTxt.Parameters.Add("@PatientID", SqlDbType.VarChar).Value = PatientID;
int checker = cmdTxt.ExecuteNonQuery();
data.CloseDatabase();
if (checker > 0)
return true;
else
return false;
}
示例11: GetLastNames
public string[] GetLastNames(string prefixText)
{
int count = 0;
string[] items = null;
DataTable dt = null;
try
{
string sql = "SELECT DISTINCT PtLname FROM Patients WHERE PtLname LIKE @prefixText";
// string sql = "SELECT Distinct PtLname + ',' + PtFname + ' ' + PtMname AS PtFullName FROM Patients WHERE PtLname LIKE @prefixText";
data = new DataAccess();
data.ConnectToDatabase();
SqlDataAdapter da = new SqlDataAdapter(sql, data.Connection);
da.SelectCommand.Parameters.Add("@prefixText", SqlDbType.VarChar, 50).Value = "%" + prefixText + "%";
dt = new DataTable();
da.Fill(dt);
count = (dt.Rows.Count == 0 ? 1 : dt.Rows.Count);
items = new string[count];
if (dt.Rows.Count == 0)
{
string v = "No match Found";
items.SetValue(v, 0);
}
else
{
int i = 0;
foreach (DataRow dr in dt.Rows)
{
items.SetValue(dr["PtLname"].ToString(), i);
i++;
}
}
}
catch (Exception ex)
{
}
//finally
//{
// data.CloseDatabase();
//}
return items;
}
示例12: HasPopulationData
public bool HasPopulationData(int Year, string Month, int BarangayID)
{
int count = 0;
mc = new MonthConverter();
data = new DataAccess();
data.ConnectToDatabase();
SqlCommand cmdTxt = new SqlCommand("SELECT COUNT(*) FROM Population WHERE Year = " +
"@year AND BarangayID = @barangayID AND Month = @month", data.Connection);
cmdTxt.Parameters.Add("@year", SqlDbType.Int).Value = Year;
cmdTxt.Parameters.Add("@month", SqlDbType.Int).Value = mc.MonthNameToIndex(Month);
cmdTxt.Parameters.Add("@barangayID", SqlDbType.Int).Value = BarangayID;
count = (int)cmdTxt.ExecuteScalar();
data.CloseDatabase();
if (count > 0)
return true;
else
return false;
}
示例13: DeleteRecord
public bool DeleteRecord(string Month,int Year, int BarangayID)
{
bool isDeleted = false;
data = new DataAccess();
data.ConnectToDatabase();
SqlCommand cmdTxt = new SqlCommand("DELETE FROM Population WHERE BarangayID = @barangayId AND Year = @year AND Month = @month",data.Connection);
cmdTxt.Parameters.Add("@barangayID", SqlDbType.Int).Value = BarangayID;
cmdTxt.Parameters.Add("@year", SqlDbType.Int).Value = Year;
cmdTxt.Parameters.Add("@month", SqlDbType.VarChar).Value = Month;
int rowsAffected = cmdTxt.ExecuteNonQuery();
data.CloseDatabase();
if (rowsAffected > 0)
isDeleted = true;
else
isDeleted = false;
return isDeleted;
}
示例14: AddMedicine
/*Add Medicine Finished - Lakhi 10/10/2010*/
public bool AddMedicine(string MedicineName, string CategoryName, int Quantity)
{
data = new DataAccess();
data.ConnectToDatabase();
SqlCommand cmdTxt = new SqlCommand("AddMedicine",data.Connection);
cmdTxt.CommandType = CommandType.StoredProcedure;
cmdTxt.Parameters.Add("@MedicineName", SqlDbType.Char).Value = MedicineName;
cmdTxt.Parameters.Add("@Quantity", SqlDbType.Int).Value = Quantity;
cmdTxt.Parameters.Add("@CategoryName", SqlDbType.Char).Value = CategoryName;
int checker = cmdTxt.ExecuteNonQuery();
data.CloseDatabase();
if (checker > 0)
return true;
else
return false;
}
示例15: GetValuesConsultation
public DataTable GetValuesConsultation(string Patient_Id)
{
data = new DataAccess();
SqlDataReader dtrPatient;
DataTable patientData = new DataTable();
patientData.Columns.Add("PatientID");
patientData.Columns.Add("PatientLName");
patientData.Columns.Add("PatientFName");
patientData.Columns.Add("PatientMName");
patientData.Columns.Add("PatientBirthdate");
patientData.Columns.Add("PatientAddress");
patientData.Columns.Add("PatientFaxNumber");
patientData.Columns.Add("PatientBarangay");
data.ConnectToDatabase();;
try
{
SqlCommand cmdTxt = new SqlCommand("GetPatientData2",data.Connection);
cmdTxt.CommandType = CommandType.StoredProcedure;
cmdTxt.Parameters.Add("@Patient_Id", SqlDbType.Char).Value = Patient_Id;
dtrPatient = cmdTxt.ExecuteReader();
dtrPatient.Read();
patientData.Rows.Add(dtrPatient["PatientID"].ToString(),
dtrPatient["PtLname"].ToString().Trim(),
dtrPatient["PtFname"].ToString().Trim(),
dtrPatient["PtMname"].ToString().Trim(),
dtrPatient["PtBdate"].ToString().Trim(),
dtrPatient["PtAddress"].ToString().Trim(),
dtrPatient["PtFaxNumber"].ToString().Trim(),
dtrPatient["BarangayName"].ToString().Trim());
}
catch (Exception)
{
}
finally
{
data.CloseDatabase();
}
return patientData;
}