protected void ButtonUpdate_Click(object sender, EventArgs e)
        {
            //so do it?
            ExamComponent ec1 = new ExamComponent(); ec1.Load(new Guid(DropDownList_Component.SelectedValue.ToString()));

            ec1.m_MaximumMark = TextBoxValue.Text;
            ec1.Save();
        }
Exemplo n.º 2
0
        public Guid Find_Component(string c_file, string component, string ExamBoard, string season, string year, bool forceupdate)
        {
            ExamComponent com1   = new ExamComponent();
            Guid          com1ID = new Guid(); com1ID = Guid.Empty;
            Stream        myStream;
            string        line        = "";
            int           JCQ_Version = 0;

            //try to find in db
            com1ID = com1.Find_ComponentID(component, ExamBoard, season, year);
            if ((com1ID != Guid.Empty) && !forceupdate)
            {
                return(com1ID);
            }
            //so not in db... find in c_file and make...
            try
            {
                if ((myStream = File.Open(c_file, FileMode.Open)) != null)
                {
                    using (StreamReader sr = new StreamReader(myStream))
                    {
                        ExamComponent examcom1 = new ExamComponent();
                        ExamComponent examcom2 = new ExamComponent();//used for forced update
                        while ((line = sr.ReadLine()) != null)
                        {
                            if (line.Substring(0, 2) == "C1")
                            {
                                JCQ_Version = System.Convert.ToInt32(line.Substring(24, 2));
                            }
                            if ((line.Substring(0, 2) == "C5") && (line.Substring(2, 12) == component))
                            {
                                examcom1.m_ComponentCode = component;
                                examcom1.LoadFromBaseData(line, JCQ_Version, ExamBoard);
                                examcom1.m_season = season; examcom1.m_year = year;
                                if (com1ID != Guid.Empty)
                                {
                                    // we are doing a forced update..... and already know the ID....
                                    examcom2.Load(com1ID);//has current db version.....
                                    //now if any significant changes need to delete current scheduled components...
                                    examcom1.m_ComponentID = com1ID;
                                    if (!examcom1.EqualTo(examcom2))
                                    {
                                        ScheduledComponentList scl1 = new ScheduledComponentList();
                                        scl1.LoadList(com1ID);
                                        foreach (ScheduledComponent sc1 in scl1.m_List)
                                        {
                                            sc1.Delete();
                                        }
                                    }
                                    examcom1.Save();
                                }
                                else
                                {
                                    examcom1.Create();
                                }
                                return(Find_Component("", component, ExamBoard, season, year, false));
                            }
                        }
                    }
                }
            }
            catch (Exception e1)
            {
                System.Windows.Forms.MessageBox.Show("Error writing the component file... " + e1.Message, "File Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
            }
            //not found - this could be a poblem
            System.Windows.Forms.MessageBox.Show("Warning.... Can't find a component: " + component, "Warning", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
            return(com1ID);
        }