コード例 #1
0
ファイル: DBContext.cs プロジェクト: GDLMadushanka/Test
        public List <InquiryModel> findInquries(string value)
        {
            DbConnection.Open();
            MySqlCommand command = DbConnection.CreateCommand();

            command.CommandText = "select * from inquiry where noticeid=@value";
            command.Parameters.AddWithValue("@value", value);
            MySqlDataReader     reader  = command.ExecuteReader();
            List <InquiryModel> inqList = new List <InquiryModel>();

            while (reader.Read())
            {
                InquiryModel inq = new InquiryModel();
                inq.Question = reader.GetString("question");
                try
                {
                    inq.Answer = reader.GetString("answer");
                }
                catch
                {
                    inq.Answer = "";
                }
                inqList.Add(inq);
            }
            DbConnection.Close();
            return(inqList);
        }
コード例 #2
0
ファイル: DBContext.cs プロジェクト: GDLMadushanka/Test
        public List <InquiryModel> FindAllInquiries(String tenderID)
        {
            DbConnection.Open();
            MySqlCommand command = DbConnection.CreateCommand();

            command.CommandText = "SELECT * FROM inquiry where noticeid =@value";
            command.Parameters.AddWithValue("@value", tenderID);
            MySqlDataReader     reader  = command.ExecuteReader();
            List <InquiryModel> inqList = new List <InquiryModel>();

            while (reader.Read())
            {
                InquiryModel inq = new InquiryModel();
                try { reader.GetString("answer"); }
                catch
                {
                    inq.InquiryId = reader.GetInt32("inquiryId");
                    inq.Question  = reader.GetString("question");
                    inq.User      = reader.GetString("user");
                    inqList.Add(inq);
                }
            }
            DbConnection.Close();
            return(inqList);
        }
コード例 #3
0
ファイル: DBContext.cs プロジェクト: GDLMadushanka/Test
        public void createInquiry(InquiryModel inq)
        {
            DbConnection.Open();
            MySqlCommand command = DbConnection.CreateCommand();

            command.CommandText = "INSERT INTO inquiry (noticeid,user,question) values(@noticeid,@user,@question)";
            command.Parameters.AddWithValue("@user", inq.User);
            command.Parameters.AddWithValue("@noticeid", inq.NoticeId);
            command.Parameters.AddWithValue("@question", inq.Question);
            command.ExecuteNonQuery();
            DbConnection.Close();
        }
コード例 #4
0
ファイル: DBContext.cs プロジェクト: GDLMadushanka/Test
 public void createInquiry(InquiryModel inq)
 {
     DbConnection.Open();
     MySqlCommand command = DbConnection.CreateCommand();
     command.CommandText = "INSERT INTO inquiry (noticeid,user,question) values(@noticeid,@user,@question)";
     command.Parameters.AddWithValue("@user",inq.User);
     command.Parameters.AddWithValue("@noticeid", inq.NoticeId);
     command.Parameters.AddWithValue("@question", inq.Question);
     command.ExecuteNonQuery();
     DbConnection.Close();
 }
コード例 #5
0
ファイル: DBContext.cs プロジェクト: GDLMadushanka/Test
 public List<InquiryModel> findInquries(string value)
 {
     DbConnection.Open();
     MySqlCommand command = DbConnection.CreateCommand();
     command.CommandText = "select * from inquiry where noticeid=@value";
     command.Parameters.AddWithValue("@value", value);
     MySqlDataReader reader = command.ExecuteReader();
     List<InquiryModel> inqList = new List<InquiryModel>();
     while (reader.Read())
     {
         InquiryModel inq = new InquiryModel();
         inq.Question = reader.GetString("question");
         try
         {
             inq.Answer = reader.GetString("answer");
         }
         catch
         {
             inq.Answer = "";
         }
         inqList.Add(inq);
     }
     DbConnection.Close();
     return inqList;
 }
コード例 #6
0
ファイル: DBContext.cs プロジェクト: GDLMadushanka/Test
 public List<InquiryModel> FindAllInquiries(String tenderID)
 {
     DbConnection.Open();
     MySqlCommand command = DbConnection.CreateCommand();
     command.CommandText = "SELECT * FROM inquiry where noticeid =@value";
     command.Parameters.AddWithValue("@value", tenderID);
     MySqlDataReader reader = command.ExecuteReader();
     List<InquiryModel> inqList = new List<InquiryModel>();
     while (reader.Read())
     {
         InquiryModel inq = new InquiryModel();
         try { reader.GetString("answer"); }
         catch
         {
             inq.InquiryId = reader.GetInt32("inquiryId");
             inq.Question = reader.GetString("question");
             inq.User = reader.GetString("user");
             inqList.Add(inq);
         }
     }
     DbConnection.Close();
     return inqList;
 }