private void btnDodajPacijenta_Click(object sender, EventArgs e)
        {
            var baza = new DataDataContext();

            if (baza.Zaposlenis.Where(x => x.Id == Int16.Parse(txtIDLek.Text)).SingleOrDefault() != null)
            {
                pac.Ime       = txtIme.Text;
                pac.Prezime   = txtPrezime.Text;
                pac.JMBG      = txtJMBG.Text;
                pac.Id_Lekara = Int16.Parse(txtIDLek.Text);

                baza.Pacijents.InsertOnSubmit(pac);
                baza.SubmitChanges();
                this.Close();
                MessageBox.Show("Uspesno dodat pacijent", "Obavestenje", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("Ne postoji lekar sa tim ID-jem!", "Greska!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #2
0
 public bool ThemPhong(string idphong, string gia, string tinhtrang, string ghichu)
 {
     try
     {
         DataDataContext data = new DataDataContext();
         phong           ph   = new phong();
         ngph            ngph = new ngph();
         diennuoc        dn   = new diennuoc();
         tienno          no   = new tienno();
         ph.idphong   = Convert.ToInt32(idphong);
         ph.gia       = gia; ph.tinhtrang = tinhtrang; ph.ghichu = ghichu;
         ngph.idphong = Convert.ToInt32(idphong);
         dn.idphong   = Convert.ToInt32(idphong);
         no.idphong   = Convert.ToInt32(idphong);
         data.phongs.InsertOnSubmit(ph);
         data.ngphs.InsertOnSubmit(ngph); data.diennuocs.InsertOnSubmit(dn); data.tiennos.InsertOnSubmit(no);
         data.SubmitChanges();
         return(true);
     }
     catch { return(false); }
 }
        private void button1_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count != 0)
            {
                var             baza = new DataDataContext();
                BazaN.Zaposleni z    = new BazaN.Zaposleni();
                z = (BazaN.Zaposleni)dataGridView1.CurrentRow.DataBoundItem;
                BazaN.Zaposleni zap = baza.Zaposlenis.Where(x => x.Id == z.Id).SingleOrDefault();
                if (zap != null)
                {
                    azf = new DodajZaposlenogForma(zap);
                    azf.Show();
                    baza.SubmitChanges();
                }
            }
            else
            {
                MessageBox.Show("Selektujte zaposlenog!", "Greska!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            LoadGrid();
        }
Beispiel #4
0
 protected void fbit_Click(object sender, EventArgs e)
 {
     if (FileUpload1.FileName == "" || FileUpload1.FileName == null)
         return;
     string File_N = FileUpload1.FileName.ToString();
     string[] File_Path = File_N.Split('\\');
     File_N = File_Path[File_Path.Length - 1];
     string webDir = Server.MapPath("Play/.") + "\\music\\";
     if (!Directory.Exists(webDir))
         Directory.CreateDirectory(webDir);
     FileUpload1.SaveAs(webDir + File_N);
     DataDataContext Mdata = new DataDataContext();
     var yy = new Music();
     yy.Name = name.Text;
     yy.Who = who.Text;
     yy.Url = "/Play/music/" + File_N;
     yy.Date = DateTime.Now;
     Mdata.Music.InsertOnSubmit(yy);
     Mdata.SubmitChanges();
     GridView1.DataBind();
     name.Text = "";
     who.Text = "";
 }
Beispiel #5
0
        private void btnZakazi_Click(object sender, EventArgs e)
        {
            if (txtJMBG.Text == "" || txtJMBG.TextLength != 13)
            {
                MessageBox.Show("Popunite JMBG");
                clear();
                return;
            }
            string   JMBG          = txtJMBG.Text;
            string   ime           = txtIme.Text;
            string   prezime       = txtPrezime.Text;
            string   id            = textBox1.Text;
            DateTime vremePregleda = dateTimePicker1.Value;


            if (vremePregleda < DateTime.Now)
            {
                MessageBox.Show("Nevalidan datum");
                return;
            }

            var baza = new DataDataContext();

            BazaN.Pacijent pacijent = new BazaN.Pacijent();
            BazaN.Pregled  pregled  = new BazaN.Pregled();

            pacijent = baza.Pacijents.Where(x => x.JMBG.Equals(JMBG)).SingleOrDefault();


            BazaN.Zaposleni lekar = new BazaN.Zaposleni();

            BazaN.Zaposleni izabrani = baza.Zaposlenis.Where(x => x.Id == pacijent.Id_Lekara).SingleOrDefault();

            int idPregleda = baza.Pregleds.ToList().Last().Id;

            if (!cbIzabrani.Checked)
            {
                if (dataGridView1.SelectedRows.Count != 0)
                {
                    lekar = (BazaN.Zaposleni)dataGridView1.CurrentRow.DataBoundItem;
                    pregled.Id_Pacijenta = pacijent.Id;
                    pregled.Id_Lekara    = lekar.Id;
                    pregled.Id_ZS        = lekar.Id_ZS;
                    pregled.Datum        = vremePregleda;
                    idPregleda++;
                    pregled.Opis = "Pregled";
                    pregled.Id   = idPregleda;
                    MessageBox.Show("Pacijent " + pacijent.Ime + " " + pacijent.Prezime + " je uspesno zakazao pregled.\nDatum pregleda: "
                                    + pregled.Datum + " \nLekar: " + lekar.Ime + " " + lekar.Prezime, "Obavestenje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Niste selektovali lekara!", "Greska!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            else
            {
                pregled.Id           = ++idPregleda;
                pregled.Id_Pacijenta = pacijent.Id;
                pregled.Id_Lekara    = izabrani.Id;
                pregled.Id_ZS        = izabrani.Id_ZS;
                pregled.Datum        = vremePregleda;
                pregled.Opis         = "Pregled";
                MessageBox.Show("Pacijent " + pacijent.Ime + " " + pacijent.Prezime + " je uspesno zakazao pregled kod svog lekara.\nDatum pregleda: "
                                + pregled.Datum + " \nLekar: " + baza.Zaposlenis.Where(x => x.Id == pacijent.Id_Lekara).SingleOrDefault().Ime + " " + baza.Zaposlenis.Where(x => x.Id == pacijent.Id_Lekara).SingleOrDefault().Prezime, "Obavestenje", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            baza.Pregleds.InsertOnSubmit(pregled);
            baza.SubmitChanges();
        }
Beispiel #6
0
        //search--------------
        public List <nguoi> Search(string type, string word)
        {
            DataDataContext data = new DataDataContext();
            var             find = (from ng in data.nguois
                                    where ng.hoten == word
                                    select ng).Distinct();

            switch (type)
            {
            case "idnguoi":
                find = (from ng in data.nguois
                        where ng.idnguoi == Convert.ToInt32(word)
                        select ng).Distinct();
                break;

            case "hoten":
                break;

            case "cmnd":
                find = (from ng in data.nguois
                        where ng.cmnd == word
                        select ng).Distinct();
                break;

            case "diachi":
                find = (from ng in data.nguois
                        where ng.diachi == word
                        select ng).Distinct();
                break;

            case "quequan":
                find = (from ng in data.nguois
                        where ng.quequan == word
                        select ng).Distinct();
                break;

            case "tuoi":
                find = (from ng in data.nguois
                        where ng.tuoi == word
                        select ng).Distinct();
                break;

            case "sdt":
                find = (from ng in data.nguois
                        where ng.sdt == word
                        select ng).Distinct();
                break;

            case "tennguoithan":
                find = (from ng in data.nguois
                        where ng.tennguoithan == word
                        select ng).Distinct();
                break;

            case "sdtnguoithan":
                find = (from ng in data.nguois
                        where ng.sdtnguoithan == word
                        select ng).Distinct();
                break;
            }

            if (find != null)
            {
                data.SubmitChanges();
            }
            return(find.ToList());
        }