/// <summary>
 /// When creates a new class
 /// </summary>
 /// <param name="del"></param>
 public Window_SetMember(SimpleDelegate del)
 {
     curclass = new SClass();
     InitializeComponent();
     this.Title = "반 정보 추가";
     setMemberCallback = del;
 }
 /// <summary>
 /// When modifys existing class
 /// </summary>
 /// <param name="curclass"></param>
 /// <param name="del"></param>
 public Window_SetMember(SClass curclass, SimpleDelegate del)
 {
     InitializeComponent();
     this.Title = "반 정보 수정";
     this.setMemberCallback = del;
     this.curclass = curclass;
     tb_ClassMember.Text = YangpaData.ConvertArrayToComma(curclass.Students);
     tb_ClassCaptain.Text = YangpaData.ConvertArrayToComma(curclass.Captains);
     tb_ClassName.Text = curclass.Name;
 }
Exemple #3
0
 private void OpenSetmemberW(SClass cls)
 {
     Window_SetMember wsm = new Window_SetMember(cls, new Window_SetMember.SimpleDelegate(SetMember_Finished));
     wsm.ShowDialog();
 }
Exemple #4
0
 /// <summary>
 /// callback function for member alteration command
 /// </summary>
 /// <param name="newclass"></param>
 private void SetMember_Finished(SClass newclass)
 {
     bool flag = false;
     foreach (SClass cl in core.Classes)
     {
         if (cl.Name.Equals(newclass.Name))
         {
             MessageBox.Show("수정 완료", YangpaConstants.AppTitle, MessageBoxButton.OK, MessageBoxImage.Information);
             flag = true;
             cl.Students = newclass.Students;
             cl.Captains = newclass.Captains;
         }
     }
     cb_Class.Text = newclass.Name;
     if (!flag)
     {
         MessageBox.Show("추가 완료", YangpaConstants.AppTitle, MessageBoxButton.OK, MessageBoxImage.Information);
         core.Classes.Add(newclass);
         cb_Class.Items.Add(newclass);
     }
     core.SaveClasses();
 }
Exemple #5
0
        public static List<SClass> GetConfigFromDB()
        {
            if (!CheckFileExists())
                throw new FileNotFoundException("File not exists.");

            List<SClass> classes = new List<SClass>();

            string[] rawdata = File.ReadAllText(CONST_CONFIG_FILEPATH, CONST_DEFAULT_ENCODING).Split(Environment.NewLine.ToCharArray());
            SClass scl = null;

            for (int i = 0; i < rawdata.Length; i++)
            {
                string line = rawdata[i];
                if (line.StartsWith("#") || line == "") continue;
                else
                {
                    if (line.StartsWith(YangpaConstants.Class))
                    {
                        scl = new SClass();
                        scl.Name = Raw(line);
                    }
                    else if (line.StartsWith(YangpaConstants.ClassEnd))
                    {
                        if (scl.Captains == null || scl.Students == null)
                            throw new FileLoadException();
                        else
                            classes.Add(scl);
                    }
                    else if (line.StartsWith(YangpaConstants.Students))
                        scl.Students = ConvertCommaToArray(Raw(line));
                    else if (line.StartsWith(YangpaConstants.CaptainPresent))
                        scl.isCaptainPresent = Boolean.Parse(Raw(line));
                    else if (line.StartsWith(YangpaConstants.Captains))
                        scl.Captains = ConvertCommaToArray(Raw(line));
                    else throw new FileLoadException("Invalid config file");
                }
            }
            return classes;
        }