Пример #1
0
        private void GetSumPregledi()
        {
            //SUM PLATENI
            double payed = 0;
            double notPayed = 0;
            using (var db = new DatabaseContext())
            {

                foreach (var listItem in lbPregledivoFirma.Items)
                {
                    var ReviewID = int.Parse((listItem as ListBoxItem).Tag.ToString());
                    var query = from b in db.Reviews
                                where b.ReviewID == ReviewID
                                select b;

                    foreach (var item in query)
                    {
                        if (item.ReviewIsPayed)
                        {
                            payed += item.ReviewPrice;
                        }
                        else
                        {
                            notPayed += item.ReviewPrice;
                        }
                    }
                    db.SaveChanges();

                    dolziinfo.Text = String.Format("Должи: {0:0.00} МКД",notPayed);

                    platenoinfo.Text = String.Format("Платено: {0:0.00} МКД", payed);

                }

            }

            //using (SQLiteConnection con = new SQLiteConnection(ConfigurationManager.ConnectionStrings["Database"].ToString()))
            //{
            //    con.Open();

            //    string command = "SELECT SUM(pregled.cena) AS cena, plateno FROM pregled,vraboten WHERE vraboten.naziv_firma = "
            //            + '"' + nazivFirma + '"' + " AND vraboten.id = pregled.id_vraboten GROUP BY plateno ORDER BY pregled.datum DESC;";

            //    using (SQLiteCommand cmd = new SQLiteCommand(command, con))
            //    {

            //        using (SQLiteDataReader reader = cmd.ExecuteReader())
            //        {

            //            var plateno = "0";
            //            var dolzi = "0";

            //            while (reader.Read())
            //            {
            //                if (reader["plateno"].ToString().Equals("True"))
            //                {
            //                    plateno = reader["cena"].ToString();
            //                }
            //                else
            //                {
            //                    dolzi = reader["cena"].ToString();
            //                }

            //            }

            //            dolziinfo.Text = "Должи: " + dolzi + ",00 MKD";

            //            platenoinfo.Text = "Платено: " + plateno + ",00 MKD";

            //        }

            //    }

            //    con.Close();

            //}
        }
Пример #2
0
        private void FillFirmaInfo(int id)
        {
            using (var db = new DatabaseContext())
            {

                var query = from b in db.Businesss
                            where b.BusinessID == id
                            select b;

                Console.WriteLine("All firmi in the database:");
                foreach (var item in query)
                {
                    imefirmainfo.Text = "Име на фирма: " + item.BusinessName;
                    adresafirmainfo.Text = "Адреса: " + item.BusinessAddress;
                    edbfirmainfo.Text = "ЕДБ: " + item.BusinessEdb;
                }

                db.SaveChanges();
            }
        }
Пример #3
0
        private void FillgboxVraboten(int id)
        {
            ToggleReadOnlyGboxVraboten(true);
            ClearGboxVraboteni();
            toggleCustomDatePicker(false);
            btnVnesiVraboten.IsEnabled = false;
            gbVraboten.IsEnabled = true;
            gbPregledi.IsEnabled = true;

            using (var db = new DatabaseContext())
            {

                var query = from b in db.Employees
                            where b.EmployeeID == id
                            select b;

                foreach (var item in query)
                {
                    tbImeVraboten.Text = item.EmployeeNameSurname;
                    tbMestoRagjanje.Text = item.EmployeeAddress;
                    tbProfesija.Text = item.EmployeeProffesion;
                    tbRabotnoMesto.Text = item.EmployeeWorks;

                    //Console.WriteLine(date[0]+" "+date[1]+" "+date[2]);
                    string dtm = Convert.ToDateTime(item.EmployeeBirthDate).ToString("dd/MM/yyyy");
                    SetCustomDate(dtm);
                }

                db.SaveChanges();
            }
        }
Пример #4
0
        private void btnNaplati_Click(object sender, RoutedEventArgs e)
        {
            if (lboxFirmi.SelectedIndex != -1)
            {

                using (var db = new DatabaseContext())
                {

                    foreach (var listItem in lbPregledivoFirma.Items)
                    {
                        var ReviewID = int.Parse((listItem as ListBoxItem).Tag.ToString());
                        var query = from b in db.Reviews
                                    where b.ReviewID == ReviewID
                                    select b;

                        foreach (var item in query)
                        {
                            item.ReviewIsPayed = true;
                        }
                        db.SaveChanges();
                    }

                }
                RefreshLists();
            }
        }
Пример #5
0
        private static void EmptyTables()
        {
            using (var db = new DatabaseContext())
            {
                var rows = from o in db.Employees
                           select o;
                foreach (var row in rows)
                {
                    db.Employees.Remove(row);
                }
                db.SaveChanges();

            }

            using (var db = new DatabaseContext())
            {
                var rows = from o in db.Reviews
                           select o;
                foreach (var row in rows)
                {
                    db.Reviews.Remove(row);
                }
                db.SaveChanges();

            }

            using (var db = new DatabaseContext())
            {
                var rows = from o in db.Businesss
                           select o;
                foreach (var row in rows)
                {
                    db.Businesss.Remove(row);
                }
                db.SaveChanges();
            }
        }
Пример #6
0
        protected void KreirajDir(object sender, EventArgs e)
        {
            TextBox TextBox1 = (TextBox)vnesinaziv;
            String str = TextBox1.Text;
            if (str.Equals("")) { MessageBox.Show("Називот на фирмата не смее да биде празен!", "Грешка"); return; }
            System.IO.Directory.CreateDirectory("Правни лица/" + str);
            String path = "Правни лица/" + str + "/Инфо.txt";

            File.Create(path).Dispose();

            MessageBox.Show("Успешно е креиран директориум за фирма со назив '" + str + "'.", "Внесување фирма");

            String[] linii = new String[] { vnesinaziv.Text, vnesiadresa.Text, vnesiedb.Text, vnesiemb.Text, vnesizabeleska.Text };
            File.WriteAllLines(path, linii);

            using (var db = new DatabaseContext())
            {
                var business = new Business { BusinessName = vnesinaziv.Text.ToString(), BusinessAddress = vnesiadresa.Text.ToString(), BusinessEdb = vnesiedb.Text.ToString(), BusinessEmb = vnesiemb.Text.ToString(), BusinessRemark = vnesizabeleska.Text.ToString() };
                db.Businesss.Add(business);
                db.SaveChanges();
            }

            //vnesuvanje vo baza

            vnesinaziv.Clear();
            vnesiadresa.Clear();
            vnesiedb.Clear();
            vnesiemb.Clear();
            vnesizabeleska.Clear();

            FillLboxFirmi();
            FillCboxFirmi();
        }
Пример #7
0
        protected void addPregled(object sender, EventArgs e)
        {
            if (rbSistematski.IsChecked == false && rbDopolnitelen.IsChecked == false &&
                rbSpecifichen.IsChecked == false && rbNasochen.IsChecked == false && rbProshiren.IsChecked == false)
            {
                string pom1 = rbSistematski.IsChecked.ToString();
                MessageBox.Show("Мора да изберете тип на преглед за пациентот " + pom1, "Грешка!");
                return;
            }

            if (lboxVraboteni.SelectedIndex < 0)
            {
                return;
            }

            ListBoxItem employeeItem = lboxVraboteni.SelectedItem as ListBoxItem;
            var EmployeeID = int.Parse(employeeItem.Tag.ToString());

            using (var db = new DatabaseContext())
            {
                var review = new Review();

                int tip = 0;
                int cena = 0;
                if (rbSistematski.IsChecked == true) { tip = 1; cena = 800; }
                else if (rbDopolnitelen.IsChecked == true) { tip = 2; cena = 1000; }
                else if (rbProshiren.IsChecked == true) { tip = 3; cena = 1200; }
                else if (rbSpecifichen.IsChecked == true) { tip = 4; cena = 1500; }
                else if (rbNasochen.IsChecked == true) { tip = 5; cena = 1000; }

                review.ReviewPrice = cena;
                review.ReviewType = String.Format("{0}",tip);
                review.ReviewIsPayed = false;

                //TODO CHECK STRING FORMAT BEFORE PARSING !
                try
                {
                    var shortDate = dpDatumPregled.Text.ToString().Split(' ')[0].Split('.');
                    var year = int.Parse(shortDate[2]);
                    var month = int.Parse(shortDate[1]);
                    var day = int.Parse(shortDate[0]);
                    review.ReviewDate = new DateTime(year, month, day);
                }
                catch (Exception err)
                {
                    MessageBox.Show("Погрешен формат за датум (dd.mm.yyyy)", "Грешка!");
                }
                review.ReviewDate = DateTime.Now;

                review.EmployeeID = EmployeeID;

                db.Reviews.Add(review);
                creator.Review = review;
                db.SaveChanges();
                var BusinessID = -1;

                var eQuery = from employee in db.Employees
                            where employee.EmployeeID == EmployeeID
                            select employee;

                foreach (var eItem in eQuery)
                {
                    creator.Employee = eItem;
                    BusinessID = eItem.BusinessID;
                }

                var bQuery = from business in db.Businesss
                            where business.BusinessID == BusinessID
                            select business;

                foreach (var bItem in bQuery)
                {
                    creator.Business = bItem;
                }

            }
            FillLboxPregledi(EmployeeID);

            //creator.ime_vraboten = tbImeVraboten.Text.ToString();
            //creator.mesto_ragjanje = tbMestoRagjanje.Text.ToString();
            //creator.vrab_profesija = tbProfesija.Text.ToString();
            //creator.vrab_rabmesto = tbRabotnoMesto.Text.ToString();
            //creator.datum_rag = cboxDay.SelectedValue.ToString() + "." + cboxMonth.SelectedValue.ToString() +
            //    "." + cboxYear.SelectedValue.ToString();
            //var cbxit = cboxFirmi.SelectedItem as ComboBoxItem;
            //creator.naziv_firma = cbxit.Content.ToString();
            //creator.id_pregled = pregledID;
            //string[] str5 = dpDatumPregled.Text.ToString().Split(' ')[0].Split('-');
            //creator.datum_pregled = str5[2] + "." + str5[1] + "." + str5[0];
            creator.GenerateDocs();
        }
Пример #8
0
        protected void addEmployee(object sender, EventArgs e)
        {
            if (tbImeVraboten.Equals("")) { MessageBox.Show("Полето за име на вработениот не смее да биде празно", "Грешка!"); return; }
            //TODO check DATE VALUES and tb fields

            ComboBoxItem b = cboxFirmi.SelectedItem as ComboBoxItem;
            int BusinessID = int.Parse(b.Tag.ToString());

            using (var db = new DatabaseContext())
            {
                var employee = new Employee();
                employee.EmployeeNameSurname = tbImeVraboten.Text.ToString();
                employee.EmployeeWorks = tbRabotnoMesto.Text.ToString();
                employee.EmployeeProffesion = tbProfesija.Text.ToString();
                employee.EmployeeAddress = tbMestoRagjanje.Text.ToString();
                int year = Int32.Parse(cboxYear.SelectedItem.ToString());
                int month = Int32.Parse(cboxMonth.SelectedItem.ToString());
                int day = Int32.Parse(cboxDay.SelectedItem.ToString());
                DateTime dateTime = new DateTime(year,month,day);
                employee.EmployeeBirthDate = dateTime;

                employee.BusinessID = BusinessID;

                db.Employees.Add(employee);
                db.SaveChanges();
            }

            MessageBox.Show(tbImeVraboten.Text + " e внесен во базата.", "Успешно е внесен нов вработен во фирмата " + cboxFirmi.SelectedValue.ToString());

            lboxVraboteni.SelectedIndex = lboxVraboteni.Items.Count;

            FillEmployees(BusinessID);
            RefreshLists();
        }