Ejemplo n.º 1
0
        public USER(string arg)
        {
            Connect Data = new Connect();

            try
            {
                Data.OpenConnection();

                SqlCommand    command = Data.CreateSQLCmd("select FULLNAME, EMAIL from USERS where ID_USER='******'");
                SqlDataReader reader  = command.ExecuteReader();

                while (reader.HasRows)
                {
                    if (reader.Read() == false)
                    {
                        break;
                    }
                    this.sName  = reader.GetString(0);
                    this.sEmail = reader.GetString(1);
                }
                reader.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Đã xảy ra lỗi, vui lòng liên hệ đội ngũ phát triển!");
                ReportError rp = new ReportError(ex);
                rp.Show();
            }
            finally
            {
                Data.CloseConnection();
            }
            this.sID   = this.sPassword = this.sGender = this.sClass = "";
            this.Birth = DateTime.Today;
        }
Ejemplo n.º 2
0
        public void SetDataDefault()
        {
            try
            {
                string Query = "delete from DEADLINE where ID = '" + this.ID + "'";
                Query += "delete from LESSON where ID_USER = '******'";
                Query += "delete from TABLESCORE where ID_USER = '******'";
                Query += "delete from SEMESTER where ID = '" + this.ID + "'";
                Query += "delete from SUBJECTS where ID = '" + this.ID + "'";

                Connection.OpenConnection();
                SqlCommand command = this.Connection.CreateSQLCmd(Query);
                command.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Đã xảy ra lỗi, vui lòng liên hệ đội ngũ phát triển!");
                ReportError rp = new ReportError(ex);
                rp.Show();
            }
            finally
            {
                Connection.CloseConnection();
            }
        }
Ejemplo n.º 3
0
 public void LoadUserInfo()
 {
     try
     {
         string sLoadUserInfo = "SELECT * FROM USERS WHERE ID_USER = '******'";
         this.Connection.OpenConnection();
         SqlCommand    command = this.Connection.CreateSQLCmd(sLoadUserInfo);
         SqlDataReader reader  = command.ExecuteReader();
         while (reader.HasRows)
         {
             if (reader.Read() == false)
             {
                 break;
             }
             this.Email    = reader.GetString(1);
             this.Birthday = reader.GetDateTime(2);
             this.Password = reader.GetString(3);
             this.Name     = reader.GetString(4);
             this.Class    = reader.GetString(5);
             this.Gender   = reader.GetString(6);
         }
         reader.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show("Đã xảy ra lỗi, vui lòng liên hệ đội ngũ phát triển!");
         ReportError rp = new ReportError(ex);
         rp.Show();
     }
     finally
     {
         this.Connection.CloseConnection();
     }
 }
Ejemplo n.º 4
0
        public int UpdateUserInfo(string id, string[] newInfo)
        {
            Connect UpdateInfo = new Connect();

            try
            {
                UpdateInfo.OpenConnection();
                string sUpdateData = "UPDATE USERS " +
                                     "                 SET BIRTH='" + newInfo[1] + "' , FULLNAME=N'" + newInfo[0] +
                                     "' , GENDER=N'" + newInfo[2] + "' , CLASSNAME=N'" + newInfo[3] +
                                     "' WHERE ID_USER='******'";

                SqlCommand UpdateCommand = UpdateInfo.CreateSQLCmd(sUpdateData);
                UpdateCommand.ExecuteNonQuery();
                UpdateInfo.CloseConnection();
                return(1);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Đã xảy ra lỗi, vui lòng liên hệ đội ngũ phát triển!");
                ReportError rp = new ReportError(ex);
                rp.Show();
            }
            finally
            {
                UpdateInfo.CloseConnection();
            }
            return(0);
        }
Ejemplo n.º 5
0
 private void bChange_Click(object sender, EventArgs e)
 {
     try
     {
         MessageBoxButtons buttons = MessageBoxButtons.OK;
         if (CheckPassword() == 1 && CheckCode() == 1)
         {
             string newPass = encoder.FromString(tbNewPass1.Text);
             string Query   = "UPDATE USER SET PASS='******' WHERE EMAIL='" + tbEmail.Text + "'";
             this.connect.OpenConnection();
             SqlCommand cmd = this.connect.CreateSQLCmd(Query);
             cmd.ExecuteNonQuery();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Đã xảy ra lỗi, vui lòng liên hệ đội ngũ phát triển!");
         ReportError rp = new ReportError(this, ex);
         rp.Show();
     }
     finally
     {
         connect.CloseConnection();
     }
 }
Ejemplo n.º 6
0
 public int CheckEmail()
 {
     try
     {
         string sCheckLogin = "******" + this.sEmail + "'";
         this.Connection.OpenConnection();
         SqlCommand    command = this.Connection.CreateSQLCmd(sCheckLogin);
         SqlDataReader reader  = command.ExecuteReader();
         if (reader.HasRows)
         {
             reader.Close();
             return(0);
         }
         else
         {
             reader.Close();
             return(1);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Đã xảy ra lỗi, vui lòng liên hệ đội ngũ phát triển!");
         ReportError rp = new ReportError(ex);
         rp.Show();
     }
     finally
     {
         Connection.CloseConnection();
     }
     return(1);
 }
 void DeadlineStatisticBySubject(string Query, string Series)
 {
     try
     {
         Connection.OpenConnection();
         SqlCommand    cmd    = Connection.CreateSQLCmd(Query);
         SqlDataReader reader = cmd.ExecuteReader();
         while (reader.HasRows)
         {
             if (!reader.Read())
             {
                 break;
             }
             chartStatistic.Series[Series].Points.AddXY(reader.GetString(0), reader.GetInt32(1));
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Đã xảy ra lỗi, vui lòng liên hệ đội ngũ phát triển!");
         ReportError rp = new ReportError(this, ex);
         rp.Show();
     }
     finally
     {
         Connection.CloseConnection();
     }
 }
        public DeadlineStatistic(MainForm parent, string ID_User)
        {
            try
            {
                Connection    = new Connect();
                this.parent   = parent;
                this.ID_User  = ID_User;
                TimeCondition = " AND DATEDIFF(DAY, DATESUBMIT, GETDATE()) <= 30";
                UpdateTimeCondition();
                InitializeComponent();

                SetColor(Properties.Settings.Default.Color);
                chartStatistic.Titles.Add("THỐNG KÊ DEADLINE THEO MÔN HỌC");
                DeadlineStatisticBySubject(Queries[0], "Số lượng deadline");
                DeadlineStatisticBySubject(Queries[1], "Số deadline đã hoàn thành");
                DeadlineStatisticBySubject(Queries[2], "Số deadline chưa hoàn thành");

                int style = NativeWinAPI.GetWindowLong(this.Handle, NativeWinAPI.GWL_EXSTYLE);
                style |= NativeWinAPI.WS_EX_COMPOSITED;
                NativeWinAPI.SetWindowLong(this.Handle, NativeWinAPI.GWL_EXSTYLE, style);
                bExit.BackColor = Color.Transparent;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Đã xảy ra lỗi, vui lòng liên hệ đội ngũ phát triển!");
                ReportError rp = new ReportError(this, ex);
                rp.Show();
            }
        }
Ejemplo n.º 9
0
 private void GetEncodedPasswd()
 {
     try
     {
         string sGetPass = "******" + this.sID + "'";
         this.Connection.OpenConnection();
         SqlCommand    command = this.Connection.CreateSQLCmd(sGetPass);
         SqlDataReader reader  = command.ExecuteReader();
         while (reader.HasRows)
         {
             if (reader.Read() == false)
             {
                 break;
             }
             if (reader.GetString(0) != null)
             {
                 this.sPasswd = reader.GetString(0);
             }
         }
         reader.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show("Đã xảy ra lỗi, vui lòng liên hệ đội ngũ phát triển!");
         ReportError rp = new ReportError(this, ex);
         rp.Show();
     }
     finally
     {
         Connection.CloseConnection();
     }
 }
Ejemplo n.º 10
0
        private int CheckExistID()
        {
            Connect connection = new Connect();

            try
            {
                connection.OpenConnection();

                SqlCommand    command = connection.CreateSQLCmd("select ID_USER from USERS");
                SqlDataReader reader  = command.ExecuteReader();

                while (reader.HasRows)
                {
                    if (reader.Read() == false)
                    {
                        break;
                    }
                    if (reader.GetString(0) == tbxID.Text)
                    {
                        return(1);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Đã xảy ra lỗi, vui lòng liên hệ đội ngũ phát triển!");
                ReportError rp = new ReportError(this, ex);
                rp.Show();
            }
            finally
            {
                connection.CloseConnection();
            }
            return(0);
        }
        void CreateChart()
        {
            try
            {
                chartStatistic.Name = this.sNameOfSem;
                chartStatistic.Series.Add("Điểm số");
                //chartStatistic.Palette = Properties.Settings.Default.Color;

                ScoreTable table  = data.GetSemester(data.FindSem(this.sNameOfSem)).SCORETABLE;
                int        amount = data.GetSemester(data.FindSem(this.sNameOfSem)).SCORETABLE.Amount;

                for (int i = 0; i < amount; i++)
                {
                    chartStatistic.Series["Điểm số"].Points.AddXY((table.SCOREOFSUB(i).SUBJECT.Name), table.SCOREOFSUB(i).Average);
                }

                chartStatistic.Titles.Add("THỐNG KÊ ĐIỂM: " + this.sNameOfSem);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Đã xảy ra lỗi, vui lòng liên hệ đội ngũ phát triển!");
                ReportError rp = new ReportError(this, ex);
                rp.Show();
            }
        }
Ejemplo n.º 12
0
        public int CheckExistSemester(string input)
        {
            try
            {
                string        sQuery  = "select distinct SEM_NAME from SEMESTER where ID='" + this.user.ID + "'";
                SqlCommand    command = connection.CreateSQLCmd(sQuery);
                SqlDataReader reader  = command.ExecuteReader();

                while (reader.HasRows)
                {
                    if (reader.Read() == false)
                    {
                        reader.Close();
                        break;
                    }
                    if (reader.GetString(0) == input)
                    {
                        reader.Close();
                        return(1);
                    }
                }
                reader.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Đã xảy ra lỗi, vui lòng liên hệ đội ngũ phát triển!");
                ReportError rp = new ReportError(ex);
                rp.Show();
            }
            return(0);
        }
Ejemplo n.º 13
0
        public int UpdateLessonInfo(string[] oldInfo, string[] newInfo)
        {
            try
            {
                connection.OpenConnection();
                string sUpdateData = "UPDATE LESSON " +
                                     "              SET DAYINWEEK=" + newInfo[0] + " , TIMEORDER=" + newInfo[1] +
                                     " , SUB_ID='" + newInfo[2] + "' , SUB_NAME=N'" + newInfo[3] +
                                     "' , SEM_NAME=N'" + newInfo[4] +
                                     "' WHERE ID_USER='******' AND DAYINWEEK=" + oldInfo[1] +
                                     " AND TIMEORDER=" + oldInfo[4] + " AND SUB_ID='" + oldInfo[3].Remove(0, 1) +
                                     "' AND SUB_NAME=N'" + oldInfo[2] + "' AND SEM_NAME=N'" + oldInfo[0] + "'";

                SqlCommand UpdateCommand = connection.CreateSQLCmd(sUpdateData);
                UpdateCommand.ExecuteNonQuery();
                return(1);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Đã xảy ra lỗi, vui lòng liên hệ đội ngũ phát triển!");
                ReportError rp = new ReportError(ex);
                rp.Show();
            }
            finally
            {
                connection.CloseConnection();
            }
            return(0);
        }
Ejemplo n.º 14
0
        public void Modify(string value)
        {
            try
            {
                string s = "";
                foreach (DataGridViewRow row in dtgvSem.SelectedRows)
                {
                    s = row.Cells[0].Value.ToString();
                    row.Cells[0].Value = value;
                }

                data.SEMESTERS.Clear();
                data.Read(UserID);

                CONNECT.OpenConnection();
                string     sql     = @"UPDATE SEMESTER SET SEM_NAME=N'" + value + "' where SEM_NAME=N'" + s + "' AND ID = '" + this.UserID + "'";
                SqlCommand command = CONNECT.CreateSQLCmd(sql);
                command.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                MessageBox.Show("Đã xảy ra lỗi, vui lòng liên hệ đội ngũ phát triển!");
                ReportError rp = new ReportError(this, e);
                rp.Show();
                this.Hide();
            }
            finally
            {
                CONNECT.CloseConnection();
            }
        }
Ejemplo n.º 15
0
        public SemForm(MainForm p, string id)
        {
            try
            {
                data        = new ListSem();
                CONNECT     = new Connect();
                this.UserID = id;
                this.parent = p;

                InitializeComponent();

                int style = NativeWinAPI.GetWindowLong(this.Handle, NativeWinAPI.GWL_EXSTYLE);
                style |= NativeWinAPI.WS_EX_COMPOSITED;
                NativeWinAPI.SetWindowLong(this.Handle, NativeWinAPI.GWL_EXSTYLE, style);

                data.Read(UserID);
                data.ShowSemToGridView(dtgvSem);
                lSum.Text  = "Số tín chỉ: " + data.SumOfCre.ToString();
                lAver.Text = "Điểm TB: " + data.Average.ToString();

                bMod.Visible = bDel.Visible = false;
                data.SEMESTERS.Clear();

                SetColor(Properties.Settings.Default.Color);
            }
            catch (Exception err)
            {
                MessageBox.Show("Đã xảy ra lỗi, vui lòng liên hệ đội ngũ phát triển!");
                ReportError rp = new ReportError(this, err);
                rp.Show();
            }
        }
Ejemplo n.º 16
0
        public void GetValue(string value)
        {
            try
            {
                string sText = value;

                Semester sem = new Semester(sText);

                data.SEMESTERS.Clear();
                data.Read(UserID);
                sem.Add(dtgvSem);

                data.SEMESTERS.Add(sem);

                CONNECT.OpenConnection();
                string     sql     = "Insert Into SEMESTER(SEM_NAME, ID) values (N'" + value + "', '" + this.UserID + "')";
                SqlCommand command = CONNECT.CreateSQLCmd(sql);
                command.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                MessageBox.Show("Đã xảy ra lỗi, vui lòng liên hệ đội ngũ phát triển!");
                ReportError rp = new ReportError(this, e);
                rp.Show();
                this.Hide();
            }
            finally
            {
                CONNECT.CloseConnection();
            }
        }
Ejemplo n.º 17
0
 private void bSendCode_Click(object sender, EventArgs e)
 {
     try
     {
         USER temp = new USER();
         temp.Email = this.tbxEmail.Text;
         if (CheckEmail() == 0)
         {
             lbValidEmail.Show();
         }
         else if (temp.CheckEmail() == 1)
         {
             this.EmailVerify = new EmailVerify(tbxEmail.Text);
             this.EmailVerify.GetRandomCode();
             this.EmailVerify.SendMail();
             lbCodeSent.Show();
             this.IsCodeSent = true;
         }
         else
         {
             lbUsedMail.Show();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Đã xảy ra lỗi, vui lòng liên hệ đội ngũ phát triển!");
         ReportError rp = new ReportError(this, ex);
         rp.Show();
     }
 }
Ejemplo n.º 18
0
        private void bDel_Click(object sender, EventArgs e)
        {
            try
            {
                string s = "";
                foreach (DataGridViewRow row in dtgvSem.SelectedRows)
                {
                    s = row.Cells[0].Value.ToString();
                    dtgvSem.Rows.RemoveAt(row.Index);
                }

                data.SEMESTERS.Clear();

                CONNECT.OpenConnection();
                string sql = @"Delete FROM SEMESTER WHERE(SEM_NAME= '" + s + "' and ID='" + this.UserID + "')";
                sql += "Delete FROM TABLESCORE WHERE(SEM_NAME= '" + s + "' and ID_USER='******')";
                SqlCommand command = CONNECT.CreateSQLCmd(sql);
                command.ExecuteNonQuery();
            }
            catch (Exception err)
            {
                MessageBox.Show("Đã xảy ra lỗi, vui lòng liên hệ đội ngũ phát triển!");
                ReportError rp = new ReportError(this, err);
                rp.Show();
                this.Hide();
            }
            finally
            {
                CONNECT.CloseConnection();
            }
        }
Ejemplo n.º 19
0
        private void btnAddDoc_Click(object sender, EventArgs e)
        {
            try
            {
                OpenFileDialog ofd = new OpenFileDialog();

                ofd.Filter   = "All Files (*.*)|*.*";
                ofd.FileName = "Choose a file";

                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    string fileName = ofd.FileName;
                    files.Add(fileName);
                    Icon iconForFile = SystemIcons.WinLogo;

                    var info = new FileInfo(fileName);
                    if ((info.Attributes & FileAttributes.System) != FileAttributes.System)
                    {
                        iconForFile = System.Drawing.Icon.ExtractAssociatedIcon(info.FullName);
                        imgList.Images.Add(info.Extension, iconForFile);
                        this.listView1.Items.Add(new ListViewItem(new string[] { info.Name, info.Extension, info.LastWriteTime.Date.ToShortDateString(), info.FullName }, info.Extension.ToString()));
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Đã xảy ra lỗi, vui lòng liên hệ đội ngũ phát triển!");
                ReportError rp = new ReportError(this, ex);
                rp.Show();
            }
        }
Ejemplo n.º 20
0
 private void btnOpenDoc_Click(object sender, EventArgs e)
 {
     try
     {
         int index = 0;
         if (listView1.SelectedItems.Count > 0)
         {
             foreach (ListViewItem lvi in listView1.SelectedItems)
             {
                 foreach (string a in files)
                 {
                     if (a.Contains(lvi.Text))
                     {
                         index = files.IndexOf(a);
                         break;
                     }
                 }
                 System.Diagnostics.Process.Start(files[index]);
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Đã xảy ra lỗi, vui lòng liên hệ đội ngũ phát triển!");
         ReportError rp = new ReportError(this, ex);
         rp.Show();
     }
 }
        public ScoreStatistics(MainForm p, string id, string name)
        {
            try
            {
                data            = new ListSem();
                CONNECT         = new Connect();
                this.UserID     = id;
                this.parent1    = p;
                this.sNameOfSem = name;
                InitializeComponent();
                int style = NativeWinAPI.GetWindowLong(this.Handle, NativeWinAPI.GWL_EXSTYLE);
                style |= NativeWinAPI.WS_EX_COMPOSITED;
                NativeWinAPI.SetWindowLong(this.Handle, NativeWinAPI.GWL_EXSTYLE, style);

                data.Read(UserID);
                SetColor(Properties.Settings.Default.Color);
                CreateChart();

                parent = "mainform";
                //var canvas = new Bunifu.DataViz.Canvas();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Đã xảy ra lỗi, vui lòng liên hệ đội ngũ phát triển!");
                ReportError rp = new ReportError(this, ex);
                rp.Show();
            }
        }
        void CreateChartOfSemesters()
        {
            try
            {
                chartStatistic.Series.Add("Điểm trung bình");
                chartStatistic.Series.Add("Số tín chỉ");
                //chartStatistic.Palette = Properties.Settings.Default.Color;

                int amount = data.Amount;

                for (int i = 0; i < amount; i++)
                {
                    chartStatistic.Series["Điểm trung bình"].Points.AddXY((data.GetSemester(i).Name), data.GetSemester(i).SCORETABLE.Average);
                    chartStatistic.Series["Số tín chỉ"].Points.AddXY((data.GetSemester(i).Name), data.GetSemester(i).SCORETABLE.SumOfCred);
                }

                chartStatistic.Titles.Add("THỐNG KÊ ĐIỂM CÁC HỌC KÌ");
            }
            catch (Exception e)
            {
                MessageBox.Show("Đã xảy ra lỗi, vui lòng liên hệ đội ngũ phát triển!");
                ReportError rp = new ReportError(this, e);
                rp.Show();
            }
        }
Ejemplo n.º 23
0
 private void tbAdd_Click(object sender, EventArgs e)
 {
     try
     {
         string[] sTempString = new string[8];
         sTempString[1] = btbSubID.Text;
         sTempString[2] = btbSubject.Text;
         sTempString[3] = btbDetails.Text;
         int min  = int.Parse(btbMinute.Text);
         int hour = int.Parse(btbHour.Text);
         TurnTime(ref hour, ref min);
         if (hour == -1 || min == -1)
         {
             labelTimeFormat.Show();
         }
         else
         {
             DateTime TempDateTime = new DateTime(bDateTime.Value.Year, bDateTime.Value.Month, bDateTime.Value.Day, hour, min, 0);
             sTempString[4] = TempDateTime.ToString();
             sTempString[5] = btbStatus.Text;
             sTempString[6] = "";
             sTempString[7] = "0";
             addItem(sTempString);
             this.Hide();
             this.parent.Show();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Đã xảy ra lỗi, vui lòng liên hệ đội ngũ phát triển!");
         ReportError rp = new ReportError(this, ex);
         rp.Show();
         this.Hide();
     }
 }
Ejemplo n.º 24
0
        public int RemoveLesson(List <string> lessonInfo)
        {
            try
            {
                connection.OpenConnection();
                string sRemove = "DELETE LESSON " +
                                 "WHERE ID_USER='******' AND DAYINWEEK=" + lessonInfo[1] +
                                 " AND TIMEORDER=" + lessonInfo[4] + " AND SUB_ID='" + lessonInfo[3].Remove(0, 1) +
                                 "' AND SUB_NAME=N'" + lessonInfo[2] + "' AND SEM_NAME=N'" + lessonInfo[0] + "'";

                SqlCommand RemoveCommand = connection.CreateSQLCmd(sRemove);
                RemoveCommand.ExecuteNonQuery();
                return(1);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Đã xảy ra lỗi, vui lòng liên hệ đội ngũ phát triển!");
                ReportError rp = new ReportError(ex);
                rp.Show();
            }
            finally
            {
                connection.CloseConnection();
            }
            return(0);
        }
Ejemplo n.º 25
0
        private void btnChangeEmailF_Click(object sender, EventArgs e)
        {
            MD5Encoder PasswdEncoder = new MD5Encoder();

            try
            {
                if (tbxCurPass.Text == "" | tbxChangeMailVC.Text == "" | tbxNewEmail.Text == "")
                {
                    MessageBox.Show("vui lòng không để trống thông tin!", "Đổi email");
                }
                else
                {
                    if (PasswdEncoder.FromString(tbxCurPass.Text) == this.sPasswd && CheckCode() == 1)
                    {
                        try
                        {
                            Connection.OpenConnection();

                            string     sql     = @"UPDATE USERS SET EMAIL ='" + tbxNewEmail.Text + "' WHERE(ID_USER= '******')";
                            SqlCommand command = Connection.CreateSQLCmd(sql);
                            command.ExecuteNonQuery();

                            MessageBox.Show("Đổi email thành công!", "Đổi email");
                        }
                        catch (Exception a)
                        {
                            MessageBox.Show(a.Message);
                        }
                        finally
                        {
                            Connection.CloseConnection();
                        }
                    }
                    else if (tbxCurPass.Text != this.sPasswd && CheckCode() == 1)
                    {
                        lbWrongPasswd.Visible = true;
                    }
                    else if (tbxCurPass.Text == this.sPasswd && CheckCode() == 0)
                    {
                        lbWrongVeriCode.Visible = true;
                    }
                    else
                    {
                        lbWrongVeriCode.Visible = true;
                        lbWrongPasswd.Visible   = true;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Đã xảy ra lỗi, vui lòng liên hệ đội ngũ phát triển!");
                ReportError rp = new ReportError(this, ex);
                rp.Show();
            }
        }
Ejemplo n.º 26
0
        private void btnSaveML_Click(object sender, EventArgs e)
        {
            Timetable lesson = new Timetable(this.sUserID);

            try
            {
                if (cbxDIWML.Text != "" && cbxTimeOrderM.Text != "" && tbxSemNaML.Text != "" && tbxSubIDML.Text != "" && tbxSubNaML.Text != "")
                {
                    if (this.IsTimeChanged == true)
                    {
                        if (lesson.CheckExistLesson(tbxSemNaML.Text, cbxDIWML.Text, cbxTimeOrderM.Text, cbxTimeOrderM.Text, this.sUserID) == false)
                        {
                            string[] sData = new string[] { lesson.SwitchDayToNumber(cbxDIWML.Text).ToString(), cbxTimeOrderM.Text, tbxSubIDML.Text.Remove(0, 1), tbxSubNaML.Text, tbxSemNaML.Text, this.sUserID };
                            if (lesson.UpdateLessonInfo(sOldInfo, sData) == 1)
                            {
                                MessageBox.Show("Chỉnh sửa thành công!", "Chỉnh sửa thông tin tiết học");
                            }
                            else
                            {
                                MessageBox.Show("Chỉnh sửa thất bại. Vui lòng kiểm tra và thử lại!", "Chỉnh sửa thông tin tiết học");
                            }
                        }
                        else
                        {
                            MessageBox.Show("Thời gian muốn sửa đã có tiết học. Vui lòng kiểm tra và thử lại!", "Chỉnh sửa thông tin tiết học");
                        }
                    }
                    else if (this.IsTimeChanged == false && this.IsNameIDChanged == true)
                    {
                        string[] sData = new string[] { lesson.SwitchDayToNumber(cbxDIWML.Text).ToString(), cbxTimeOrderM.Text, tbxSubIDML.Text.Remove(0, 1), tbxSubNaML.Text, tbxSemNaML.Text, this.sUserID };
                        if (lesson.UpdateLessonInfo(sOldInfo, sData) == 1)
                        {
                            MessageBox.Show("Chỉnh sửa thành công!", "Chỉnh sửa thông tin tiết học");
                        }
                        else
                        {
                            MessageBox.Show("Chỉnh sửa thất bại. Vui lòng kiểm tra và thử lại!", "Chỉnh sửa thông tin tiết học");
                        }
                    }
                }
                else if (cbxDIWML.Text == "" || cbxTimeOrderM.Text == "" || tbxSemNaML.Text == "" || tbxSubIDML.Text == "" || tbxSubNaML.Text == "")
                {
                    MessageBox.Show("Hãy điền đầy đủ thông tin và thử lại!", "Chỉnh sửa thông tin tiết học");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Đã xảy ra lỗi, vui lòng liên hệ đội ngũ phát triển!");
                ReportError rp = new ReportError(this, ex);
                rp.Show();
            }
        }
Ejemplo n.º 27
0
 public void CloseConnection()
 {
     try
     {
         Connection.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show("Đã xảy ra lỗi, vui lòng liên hệ đội ngũ phát triển!");
         ReportError rp = new ReportError(ex);
         rp.Show();
     }
 }
Ejemplo n.º 28
0
        private void Documents_Load(object sender, EventArgs e)
        {
            string sDocs = "";

            try
            {
                connection = new Connect();
                connection.OpenConnection();
                string sql = @"SELECT DOCUMENTS
                                FROM LESSON" +
                             " WHERE ID_USER='******' AND DAYINWEEK=N'" + sLessonInfo[1] +
                             "' AND TIMEORDER=" + sLessonInfo[4] + " AND SUB_ID='" + sLessonInfo[3].Remove(0, 1) +
                             "' AND SUB_NAME=N'" + sLessonInfo[2] + "' AND SEM_NAME=N'" + sLessonInfo[0] + "'";
                SqlCommand    command = connection.CreateSQLCmd(sql);
                SqlDataReader reader  = command.ExecuteReader();

                if (reader.HasRows)
                {
                    if (reader.Read())
                    {
                        if (reader.IsDBNull(0) == false)
                        {
                            sDocs = reader.GetString(0);
                            if (AddItemsToListView(sDocs) == 0)
                            {
                                MessageBox.Show("Một số file có thể đã không còn ở nơi lưu trữ ban đầu. Hãy kiểm tra lại!");
                            }
                            reader.Close();
                        }
                        else
                        {
                            reader.Close();
                        }
                    }
                }
                else
                {
                    reader.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Đã xảy ra lỗi, vui lòng liên hệ đội ngũ phát triển!");
                ReportError rp = new ReportError(this, ex);
                rp.Show();
            }
            finally
            {
                connection.CloseConnection();
            }
        }
Ejemplo n.º 29
0
 private void SemForm_FormClosed(object sender, FormClosedEventArgs e)
 {
     try
     {
         data.Read(UserID);
         this.parent.AddItemToComboBoxSemester();
         this.parent.Show();
     }
     catch (Exception err)
     {
         MessageBox.Show("Đã xảy ra lỗi, vui lòng liên hệ đội ngũ phát triển!");
         ReportError rp = new ReportError(this, err);
         rp.Show();
         this.Hide();
     }
 }
Ejemplo n.º 30
0
 private void bSignUp_Click(object sender, EventArgs e)
 {
     try
     {
         MessageBoxButtons buttons = MessageBoxButtons.OK;
         if (CheckPassword() == 1 && CheckCode() == 1 && CheckFullInfo() == 1 && CheckExistID() == 0)
         {
             USER user = new USER();
             user.ID = tbxID.Text;
             MD5Encoder PasswordEncoder = new MD5Encoder();
             user.Password    = PasswordEncoder.FromString(tbxPass.Text);
             user.Birthday    = dateBirth.Value;
             user.Email       = tbxEmail.Text;
             user.Name        = tbxName.Text;
             user.Class       = tbxClass.Text;
             user.Gender      = tbxGender.Text;
             this.EmailVerify = new EmailVerify(user.Email);
             user.AddUserToDatabase();
             MessageBox.Show("Đăng ký thành công!", "StudentSupportApp", buttons);
             this.Close();
             this.parent.Show();
         }
         else if (CheckCode() == 0)
         {
             MessageBox.Show("Mã xác nhận không đúng! Vui lòng thử lại!", "StudentSupportApp", buttons);
             lbCodeSent.Hide();
         }
         else if (CheckPassword() == 2)
         {
             lbShortPass.Visible = true;
         }
         else if (CheckPassword() == 3)
         {
             lbConfirmWrong.Visible = true;
         }
         else if (CheckExistID() == 1)
         {
             lbUsedID.Visible = true;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Đã xảy ra lỗi, vui lòng liên hệ đội ngũ phát triển!");
         ReportError rp = new ReportError(this, ex);
         rp.Show();
     }
 }