Пример #1
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            int flag = 0;

            if (SaveButton.Text.Equals("Leave"))
            {
                UserFacade.UpdateGroupStudent(LoginPanel.albumNumber, secID, false);
                this.Hide();
            }
            else
            {
                Sections sec = new Sections();
                sec.ID = secID;
                if (SaveButton.Text != "Save")
                {
                    if (StatusTextbox.Text == "Open")
                    {
                        MessageBox.Show("Joining this section will cause leaving current section!", "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                        stdgrp = UserFacade.GetGroupStudentID(UserFacade.GetSingleStudent(LoginPanel.albumNumber).ID);
                        if (stdgrp != null)
                        {
                            //for(int i = 0; i < stdgrp.Length; i++)
                            //{
                            //    if (stdgrp[i].Active == true)
                            //    {
                            //        UserFacade.UpdateGroupStudent(LoginPanel.albumNumber, 0, false);
                            //        flag = 1;
                            //    }
                            //    if (stdgrp[i].GroupID == secID)
                            //    {
                            //        UserFacade.UpdateGroupStudent(LoginPanel.albumNumber, secID, true);
                            //        flag = 0;
                            //    }
                            //}
                            //if(flag == 1)
                            //{
                            DependencyFacade.SetStudentSection(LoginPanel.albumNumber, sec);
                            //flag = 0;
                            //}
                        }
                        else
                        {
                            DependencyFacade.SetStudentSection(LoginPanel.albumNumber, sec);
                        }
                    }
                    else
                    {
                        MessageBox.Show("You can't join to closed section!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    this.Hide();
                }
                else
                {
                    if (!PlacesTexbox.Text.Equals(""))
                    {
                        sec.ID        = id;
                        sec.GroupSize = Convert.ToByte(PlacesTexbox.Text);

                        if (StatusCombobox.Text == "Open")
                        {
                            sec.Status = "opn";
                        }
                        else if (StatusCombobox.Text == "Closed")
                        {
                            sec.Status = "cls";
                        }
                        else
                        {
                            sec.Status = "fin";
                        }

                        if (topID != 0)
                        {
                            sec.TopicID = topID;
                        }
                        DependencyFacade.UpdateSection(sec);
                    }
                }
                this.Hide();
            }
        }