コード例 #1
0
        public static bool importFromXML(string path)
        {
            try
            {
                XDocument         doc            = XDocument.Load(path);
                List <Lek>        lekiList       = new List <Lek>();
                List <Refundacja> refundacjaList = new List <Refundacja>();

                foreach (XElement elem in doc.Element("Leki").Elements("Lek"))
                {
                    string  bl7         = elem.Attribute("BL7").Value;
                    string  ean         = elem.Attribute("EAN").Value;
                    bool    psychotrop  = Boolean.Parse(elem.Attribute("psychotrop").Value);
                    bool    senior      = Boolean.Parse(elem.Attribute("senior").Value);
                    bool    szczepionka = Boolean.Parse(elem.Attribute("szczepionka").Value);
                    decimal cena        = Decimal.Parse(elem.Attribute("cena").Value);
                    string  nazwa       = elem.Element("Nazwa").Value;
                    string  nazwaInt    = elem.Element("NazwaInt").Value;
                    string  postac      = elem.Element("Postać").Value;
                    string  dawka       = elem.Element("Dawka").Value;
                    string  opakowanie  = elem.Element("Opakowanie").Value;

                    Lek lek = new Lek(bl7, ean, psychotrop, senior, szczepionka, cena, nazwa, nazwaInt, postac, dawka,
                                      opakowanie);
                    lekiList.Add(lek);

                    if (elem.Element("Refundacja").HasElements)
                    {
                        foreach (XElement elemRef in elem.Element("Refundacja").Elements("Poziom"))
                        {
                            string poziom = elemRef.Attribute("poziom").Value;
                            string tekst  = elemRef.Value;

                            Refundacja refundacja = new Refundacja(poziom, tekst, lek);
                            refundacjaList.Add(refundacja);
                        }
                    }
                }
                insertToDb(lekiList, refundacjaList);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(false);
            }
            return(true);
        }
コード例 #2
0
        void addDrugToPrescription()
        {
            if (list.Count < 5)
            {
                string            bl7        = (string)dataGridView1[0, dataGridView1.CurrentRow.Index].Value;
                Lek               lek        = Lek.get(bl7);
                List <Refundacja> refundList = Refundacja.getRefunds(bl7);

                if (refundList.Count > 0)
                {
                    FrmRefundChoose frmRefundChoose = new FrmRefundChoose(refundList);
                    frmRefundChoose.ShowDialog();
                }

                list.Add(new DrugView(lek));
                dataGridView2.DataSource = null;
                dataGridView2.DataSource = list;
            }
            else
            {
                MessageBox.Show("Osiągnięto maksymalną ilość pozycji na recepcie");
            }
        }