Ejemplo n.º 1
0
        public MainMenu(Kuvar k)
        {
            kuvar = k;
            InitializeComponent();
            this.StartPosition = FormStartPosition.CenterScreen;

            dataGridView1.Columns["ObjectId"].Visible  = false;
            dataGridView2.Columns["ObjectId2"].Visible = false;
        }
Ejemplo n.º 2
0
        public Recept(Kuvar k, string id)
        {
            kuvar = k;
            InitializeComponent();
            this.StartPosition = FormStartPosition.CenterScreen;

            this.Id = id;

            Inicialize(id);
        }
Ejemplo n.º 3
0
        private void registerDoctorOrSister_Click(object sender, EventArgs e)
        {
            var connectionString = "mongodb://localhost/?safe=true";
            var server           = MongoServer.Create(connectionString);
            var db = server.GetDatabase("CookingBook");


            var   collection = db.GetCollection <Kuvar>("kuvari");
            Kuvar k          = new Kuvar();

            k.ime        = name.Text.ToString();
            k.prezime    = surname.Text.ToString();
            k.ID_Kartice = IdCard.Text.ToString();
            k.sifra      = password.Text.ToString();

            collection.Insert(k);

            this.Close();
        }
Ejemplo n.º 4
0
        public void Inicialize(string id)
        {
            if (id != String.Empty)
            {
                button3.Visible = true;
                var      connectionString = "mongodb://localhost/?safe=true";
                var      server           = MongoServer.Create(connectionString);
                var      db = server.GetDatabase("CookingBook");
                var      kuvariCollection = db.GetCollection <Kuvar>("kuvari");
                var      collection       = db.GetCollection <Recepts>("Recepts");
                ObjectId objectId         = new ObjectId(id);
                var      query            = Query.And(
                    (Query.EQ("_id", objectId))

                    );
                var recept = collection.Find(query);
                if (recept.Count() == 1)
                {
                    foreach (Recepts r in recept)
                    {
                        naziv.Text  = r.naziv;
                        opis.Text   = r.opis;
                        zacini.Text = r.zacini;
                        vreme.Text  = r.vreme;
                        dodaci.Text = r.dodaci;

                        Kuvar KUVA = db.FetchDBRefAs <Kuvar>(r.radnik);
                        label7.Text = "Kuvar " + KUVA.ime + " " + KUVA.prezime;
                        ObjectId oid  = new ObjectId(r.ImageId.ToString());
                        var      file = db.GridFS.FindOne(Query.EQ("_id", oid));
                        sFileName = newFileName + "\\" + System.IO.Path.GetFileName(file.Name);
                        if (!File.Exists(sFileName))
                        {
                            using (var stream = file.OpenRead())
                            {
                                var bytes = new byte[stream.Length];
                                stream.Read(bytes, 0, (int)stream.Length);
                                var filestream = new FileStream(newFileName + "\\" + System.IO.Path.GetFileName(file.Name), FileMode.Create);

                                using (var newFs = filestream)
                                {
                                    newFs.Write(bytes, 0, bytes.Length);
                                }
                            }
                            pictureBox1.Image = new Bitmap(newFileName + "\\" + System.IO.Path.GetFileName(file.Name));

                            pictureBox1.Height = 150;
                            pictureBox1.Width  = 150;
                        }
                        else
                        {
                            using (FileStream fs = File.OpenRead(sFileName))
                            {
                                // Byte[] info = new UTF8Encoding(true).GetBytes("This is some text in the file.");

                                // Add some information to the file.
                                // fs.Write(info, 0, info.Length);
                                pictureBox1.Image = new Bitmap(fs.Name);

                                pictureBox1.Height = 150;
                                pictureBox1.Width  = 150;
                            }
                        }
                    }
                }
            }

            else
            {
                button3.Visible = false;
            }
        }