当前位置: 首页>>代码示例>>C#>>正文


C# DataAccess.ConnectToDatabase方法代码示例

本文整理汇总了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();
        }
    }
开发者ID:abdojobs,项目名称:paombonghealthcare,代码行数:27,代码来源:Program.cs

示例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;
 }
开发者ID:abdojobs,项目名称:paombonghealthcare,代码行数:13,代码来源:Barangay.cs

示例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;
 }
开发者ID:abdojobs,项目名称:paombonghealthcare,代码行数:14,代码来源:Patient.cs

示例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;
 }
开发者ID:abdojobs,项目名称:paombonghealthcare,代码行数:13,代码来源:Barangay.cs

示例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;
    }
开发者ID:abdojobs,项目名称:paombonghealthcare,代码行数:13,代码来源:Program.cs

示例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;
    }
开发者ID:abdojobs,项目名称:paombonghealthcare,代码行数:14,代码来源:Program.cs

示例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;
 }
开发者ID:abdojobs,项目名称:paombonghealthcare,代码行数:14,代码来源:Inventory.cs

示例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;
 }
开发者ID:abdojobs,项目名称:paombonghealthcare,代码行数:14,代码来源:Inventory.cs

示例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;
 }
开发者ID:abdojobs,项目名称:paombonghealthcare,代码行数:16,代码来源:Disease.cs

示例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;
 }
开发者ID:abdojobs,项目名称:paombonghealthcare,代码行数:16,代码来源:Disease.cs

示例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;
    }
开发者ID:abdojobs,项目名称:paombonghealthcare,代码行数:45,代码来源:WebService.cs

示例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;
 }
开发者ID:abdojobs,项目名称:paombonghealthcare,代码行数:18,代码来源:Reports.cs

示例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;
    }
开发者ID:abdojobs,项目名称:paombonghealthcare,代码行数:18,代码来源:Reports.cs

示例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;
    }
开发者ID:abdojobs,项目名称:paombonghealthcare,代码行数:21,代码来源:Inventory.cs

示例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;
    }
开发者ID:abdojobs,项目名称:paombonghealthcare,代码行数:42,代码来源:MedicalRecord.cs


注:本文中的DataAccess.ConnectToDatabase方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。