Beispiel #1
0
        public bool LoadCommentsFromDb(string esttype, long obj)
        {
            try
            {
                MySqlConnection con = new MySqlConnection(Connect);
                con.Open();
                MySqlCommand cmd = new MySqlCommand("SELECT Rc_id, Rc_agent, Rc_mail, Rc_data, Rc_comment from rcomments WHERE ((Rc_object = @Val1) AND (Rc_estate_type = @Val2) ORDER by Rc_data)", con);
                cmd.Parameters.AddWithValue("@Val1", obj);
                cmd.Parameters.AddWithValue("@Val2", esttype);
                cmd.CommandType = System.Data.CommandType.Text;
                MySqlDataReader reader = cmd.ExecuteReader();
                DataTable result = new DataTable();
                result.Load(reader);
                for (int i = 0; i < result.Rows.Count - 1;i++ )
                {
                    Comment cmt = new Comment();
                    cmt.Id = Convert.ToInt64(result.Rows[i][0]);
                    cmt.Author = result.Rows[i][1].ToString();
                    cmt.Email = result.Rows[i][2].ToString();
                    cmt.Date = Convert.ToDateTime(result.Rows[i][3]);
                    cmt.Text = result.Rows[i][4].ToString();
                    cmt.IsNew = false;
                    CommentsList.Add(cmt);

                }
                    con.Close();
                return true;

            }
            catch
            {
                return false;
            }
        }
Beispiel #2
0
 private void simpleButton3_Click(object sender, EventArgs e)
 {
     if (textBox21.Text=="")
     {
         MessageBox.Show("Текст комментария пуст.", "Внимание", MessageBoxButtons.OK);
     }
     else
     {
         Comment cmt = new Comment();
         cmt.Author = Program.user.FIO;
         cmt.Date = DateTime.Now;
         cmt.Email = Program.user.email;
         cmt.Text = textBox21.Text;
         dbcomm.CommentsList.Add(cmt);
         dbcomm.InsertCommentInDb(dbcomm.CommentsList.Count - 1, Program.objectedit.record.Restate_type, Program.objectedit.record.Rid);
         ListViewItem item = new ListViewItem();
         item.SubItems.Add(cmt.Author);
         item.SubItems.Add(cmt.Email);
         item.SubItems.Add(cmt.Date.ToShortDateString());
         item.SubItems.Add(cmt.Text);
         listView1.Items.Add(item);
         textBox21.Text = "";
     }
 }