Ejemplo n.º 1
0
        private void bt_them_Click(object sender, EventArgs e)
        {
            Add_newData Infor_add = new Add_newData();

            Infor_add.ID    = idbx.Text;
            Infor_add.Name  = namebx.Text;
            Infor_add.Age   = agebx.Text;
            Infor_add.Major = majorbx.Text;
            Infor_add.MSSV  = mssvbx.Text;
            Infor_add.Phone = phonebx.Text;

            var Bson = JsonConvert.SerializeObject(Infor_add);
            var tmp  = BsonSerializer.Deserialize <BsonDocument>(Bson);

            mongo.Insert_document(tmp);

            try
            {
                OpenFileDialog open = new OpenFileDialog();
                open.Filter = "Image Files(*.jpg; *.jpeg; *.gif; *.bmp)|*.jpg; *.jpeg; *.gif; *.bmp";
                if (open.ShowDialog() == DialogResult.OK)
                {
                    Bitmap bit = new Bitmap(open.FileName);
                    //pictureBox1.Image = bit;
                }
            }
            catch (Exception)
            {
                throw new ApplicationException("Failed loading image");
            }
        }
Ejemplo n.º 2
0
        private void bt_xoa_Click(object sender, EventArgs e)
        {
            Add_newData Infor_add = new Add_newData();

            Infor_add.ID    = idbx.Text;
            Infor_add.Name  = namebx.Text;
            Infor_add.Age   = agebx.Text;
            Infor_add.Major = majorbx.Text;
            Infor_add.MSSV  = mssvbx.Text;
            Infor_add.Phone = phonebx.Text;

            var Bson = JsonConvert.SerializeObject(Infor_add);
            var tmp  = BsonSerializer.Deserialize <BsonDocument>(Bson);

            mongo.Delete_document(tmp);
        }