Esempio n. 1
0
        private void btnNew_Click(object sender, RoutedEventArgs e)
        {
            vwInstitution newInstitution = new vwInstitution();

            newInstitution.ctrID = (int)cmbCountry.SelectedValue;
            NewInstitution ni = new NewInstitution {
                objInstitution = newInstitution
            };

            ni.ShowDialog();
            if (ni.result)
            {
                PopulateDatagrid(Int32.Parse(cmbCountry.SelectedValue.ToString()));
                MedaEntitiesDb mdb = new MedaEntitiesDb();
                dgInstitution.SelectedItem = mdb.vwInstitutions.FirstOrDefault(n => n.insID == ni.index);
                mdb.Dispose();
            }
        }
Esempio n. 2
0
        private void dgInstitution_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.F)
            {
                txtSearch.Focus();
                return;
            }
            string className = null;

            switch (cmbCountry.SelectedValue.ToString())
            {
            case "1":
                className = "vwInstitutionSerbia";
                break;

            case "3":
                className = "vwInstitutionCroatia";
                break;

            case "4":
                className = "vwInstitutionSlovenia";
                break;

            default:
                break;
            }
            if ((e.Key == Key.LeftCtrl && e.Key == Key.C) || (e.Key == Key.LeftShift || e.Key == Key.RightShift))
            {
                StringBuilder s   = new StringBuilder();
                Type          t   = Type.GetType("WpfMedaSlovenija." + className);
                var           row = Activator.CreateInstance(Type.GetType("WpfMedaSlovenija." + className));
                //vwInstution row = new vwInstution();
                if (dgInstitution.SelectedIndex > -1)
                {
                    //row = (vwInstution)dgInstitution.SelectedItem;
                    row = dgInstitution.SelectedItem;
                    List <PropertyInfo> listProperties = t.GetProperties().ToList();

                    s.Append(row.GetType().GetProperty("insID").GetValue(row, null) + "\t");
                    s.Append(row.GetType().GetProperty("insName").GetValue(row) + "\t");
                    s.Append(row.GetType().GetProperty("ctyName").GetValue(row) + "\t");
                    s.Append(row.GetType().GetProperty("insAddress").GetValue(row));
                    //s.Append(t.GetProperty("hdoName").GetValue(row));
                    //s.Append(row.insID + "\t");
                    //s.Append(row.insName + "\t");
                    //s.Append(row.ctyName + "\t");
                    //s.Append(row.insAddress + "\t");
                    //s.Append(row.hdoName);
                }
                Clipboard.SetText(s.ToString());
            }

            if (Keyboard.IsKeyDown(Key.LeftCtrl) && Keyboard.IsKeyDown(Key.N))
            {
                //Type t = Type.GetType("WpfMedaSlovenija." + className);
                //var selectedInstitution = Activator.CreateInstance(Type.GetType("WpfMedaSlovenija." + className));
                NewInstitution ni = new NewInstitution();
                if (dgInstitution.SelectedIndex > -1)
                {
                    vwInstitution vwi = (vwInstitution)dgInstitution.SelectedItem;
                    ni.objInstitution.insName    = vwi.insName;
                    ni.objInstitution.insAddress = vwi.insAddress;
                    ni.objInstitution.ctyID      = vwi.ctyID;
                    ni.objInstitution.ctyName    = vwi.ctyName;
                    ni.objInstitution.isbID      = vwi.isbID;
                    ni.objInstitution.isbName    = vwi.isbName;
                    ni.objInstitution.itpID      = vwi.itpID;
                    ni.objInstitution.itpName    = vwi.itpName;
                    ni.objInstitution.hdoID      = vwi.hdoID;
                    ni.objInstitution.hdoName    = vwi.hdoName;
                    ni.objInstitution.ctrID      = vwi.ctrID;
                }

                ni.ShowDialog();
                if (ni.result)
                {
                    PopulateDatagrid(Int32.Parse(cmbCountry.SelectedValue.ToString()));
                    MedaEntitiesDb mdb = new MedaEntitiesDb();
                    dgInstitution.SelectedItem = mdb.vwInstitutions.FirstOrDefault(n => n.insID == ni.index);
                    mdb.Dispose();
                }
            }
            if (Keyboard.IsKeyDown(Key.LeftCtrl) && Keyboard.IsKeyDown(Key.E))
            {
                //Type t = Type.GetType("WpfMedaSlovenija." + className);
                //var selectedInstitution = Activator.CreateInstance(Type.GetType("WpfMedaSlovenija." + className));
                NewInstitution ni = new NewInstitution();
                if (dgInstitution.SelectedIndex > -1)
                {
                    ni.objInstitution = (vwInstitution)dgInstitution.SelectedItem;
                }

                ni.ShowDialog();
                if (ni.result)
                {
                    PopulateDatagrid(Int32.Parse(cmbCountry.SelectedValue.ToString()));
                    MedaEntitiesDb mdb = new MedaEntitiesDb();
                    dgInstitution.SelectedItem = mdb.vwInstitutions.FirstOrDefault(n => n.insID == ni.index);
                    mdb.Dispose();
                }
            }
        }