예제 #1
0
        void Save()
        {
            if (SystemProperties.ShowMessage.MessageQuestion(SystemProperties.MessageNotification.YouWantToSave, "Message notification") == DialogResult.Yes)
            {
                if (CheckEmptyField())
                {
                    using (SMSNotification notify = new SMSNotification())
                    {
                        notify.Save(SetRoomType(), ref MsgReturned);

                        SystemProperties.ShowMessage.MessageInformation(MsgReturned, "Message notification");
                        SystemProperties.Cleared(this, false, true, true);
                        LoadSMS();
                    }
                }
                else
                {
                    SystemProperties.ShowMessage.MessageError(SystemProperties.MessageNotification.CheckInput + Environment.NewLine + Environment.NewLine + "Code" + Environment.NewLine + "Message", "Message notification");
                }
            }
        }
        void Save()
        {
            T_RegisteredStudentSemester ret = new T_RegisteredStudentSemester();
            var StudentSelected             = dgStudentList.Rows.Cast <DataGridViewRow>().Where(x => Convert.ToBoolean(x.Cells[6].Value)).ToList();
            var DaySelected  = dgDay.Rows.Cast <DataGridViewRow>().Where(d => Convert.ToBoolean(d.Cells[1].Value)).ToList();
            var TimeSelected = dgTime.Rows.Cast <DataGridViewRow>().Where(t => Convert.ToBoolean(t.Cells[2].Value)).ToList();

            if (StudentSelected.Count > 0)
            {
                StudentSelected.ForEach(s =>
                {
                    ret.StudentID = s.Cells[2].Value.ToString();

                    using (Students std = new Students())
                    {
                        var stud               = std.GetStudentInfo().Where(x => x.StudentID == s.Cells[2].Value.ToString()).FirstOrDefault();
                        ret.Active             = true;
                        ret.RFID               = stud.RFIDNo;
                        ret.RoomCode           = cmbRoomCode.Text;
                        ret.MessageID          = cmbMessage.Text;
                        ret.SubjectCode        = cmbSubjectCode.Text;
                        ret.SubjectDescription = txtSubjectDesc.Text;
                        ret.Semester           = SystemProperties.SemesterActive.Semester;
                        ret.SemStartDate       = SystemProperties.SemesterActive.Start;
                        ret.SemEndDate         = SystemProperties.SemesterActive.End;
                        ret.YearClass          = SystemProperties.SemesterActive.YearSemester;
                        using (Parents parent = new Parents())
                        {
                            var part      = parent.GetParentsInfo().Where(pp => pp.StudentID == stud.StudentID).FirstOrDefault();
                            ret.ParentsNo = !string.IsNullOrWhiteSpace(part.MomContactNo)?part.MomContactNo:part.DadContactNo;
                        }
                        if (DaySelected.Count > 0)
                        {
                            DaySelected.ForEach(dd =>
                            {
                                ret.Day = dd.Cells[0].Value.ToString();
                                if (TimeSelected.Count > 0)
                                {
                                    TimeSelected.ForEach(tt =>
                                    {
                                        var _tt = tt.Cells[3].Value.ToString();
                                        using (Maintenance maintain = new Maintenance())
                                        {
                                            var TimeStartEnd = maintain.GetTime().Where(ttt => ttt.TimeCode == _tt).FirstOrDefault();
                                            ret.TimeStart    = TimeStartEnd.TimeStart.Value;
                                            ret.TImeEnd      = TimeStartEnd.TimeEnd.Value;
                                            using (SMSNotification notify = new SMSNotification())
                                            {
                                                string msgRet = "";
                                                notify.Save(ret, ref msgRet);
                                                lblMessage.Text = msgRet;
                                            }
                                        }
                                    });
                                }
                                else
                                {
                                    SystemProperties.ShowMessage.MessageError("Select time first", "Time Error");
                                }
                            });
                        }
                        else
                        {
                            SystemProperties.ShowMessage.MessageError("Select day first", "Day Error");
                        }
                    }
                });
            }
            GetDayAndTime();
            GetRoomSubjectMessage();
            LoadStudent();
            ObjEnable(false);
            SystemProperties.Cleared(this, false, true, true);
            dgDay.Enabled = dgTime.Enabled = dgStudentList.Enabled = false;

            txtRoomDesc.ReadOnly    = true;
            txtSubjectDesc.ReadOnly = true;
        }