Ejemplo n.º 1
0
 public void LoadTimetableToHomeDGV(DataGridView obj)
 {
     try
     {
         int iLessonIndex = 0;
         for (int i = 0; i < 10; i++)
         {
             obj.Rows[i].Cells[1].Value = sTodayLesson[iLessonIndex];
             iLessonIndex++;
         }
     }
     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.º 2
0
        public bool CheckExistLesson(string sem, string diw, string timebegin, string timeend, string userID)
        {
            try
            {
                diw = SwitchDayToNumber(diw).ToString();
                string sLoadData = "";
                connection.OpenConnection();

                if (int.Parse(timebegin) == int.Parse(timeend))
                {
                    sLoadData = "select * from LESSON where SEM_NAME=N'" + sem
                                + "' AND DAYINWEEK='" + diw + "' AND ID_USER = '******' AND TIMEORDER=" + timebegin;
                }
                else
                {
                    sLoadData = "select * from LESSON where SEM_NAME=N'" + sem
                                + "' AND DAYINWEEK='" + diw + "' AND ID_USER = '******' AND " + timebegin + " <= TIMEORDER AND TIMEORDER <= " + timeend;
                }

                SqlCommand    loadInfo = connection.CreateSQLCmd(sLoadData);
                SqlDataReader reader   = loadInfo.ExecuteReader();
                if (reader.HasRows)
                {
                    if (reader.Read())
                    {
                        reader.Close();
                        return(true);
                    }
                }
                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
            {
                connection.CloseConnection();
            }
            return(false);
        }
        private void btnAddAL_Click(object sender, EventArgs e)
        {
            List <string> sDayInWeek = new List <string> {
                "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"
            };

            try
            {
                if (cbxDIWAL.Text != "" && cbxTimeOrderBegin.Text != "" && tbxSemNaAL.Text != "" && tbxSubIDAL.Text != "" && tbxSubNaAL.Text != "" && cbxTimeOrderEnd.Text != "")
                {
                    Timetable lesson = new Timetable(this.sUserID);
                    if (lesson.CheckExistLesson(tbxSemNaAL.Text, cbxDIWAL.Text, cbxTimeOrderBegin.Text, cbxTimeOrderEnd.Text, this.sUserID) == false)
                    {
                        string[] sData = new string[] { cbxDIWAL.Items[cbxDIWAL.SelectedIndex].ToString(), cbxTimeOrderBegin.Text, cbxTimeOrderEnd.Text, tbxSubIDAL.Text, tbxSubNaAL.Text, tbxSemNaAL.Text, this.sUserID };
                        if (lesson.AddLessonToDatabase(sData) == 1)
                        {
                            MessageBox.Show("Thêm tiết học mới thành công!", "Thêm tiết học mới");
                        }
                        else
                        {
                            MessageBox.Show("Thêm tiết học thất bại. Vui lòng kiểm tra và thử lại!", "Thêm tiết học mới");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Thời gian muốn thêm đã có tiết học. Vui lòng kiểm tra và thử lại!", "Thêm tiết học mới");
                    }
                }
                else if (cbxDIWAL.Text == "" || cbxTimeOrderBegin.Text == "" || tbxSemNaAL.Text == "" || tbxSubIDAL.Text == "" || tbxSubNaAL.Text == "" || cbxTimeOrderEnd.Text == "")
                {
                    MessageBox.Show("Hãy điền đầy đủ thông tin và thử lại!", "Thêm tiết học mới");
                }
            }
            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.º 4
0
        public void LoadTodayTimetable(string today)
        {
            try
            {
                connection.OpenConnection();

                int    iWeekDay  = SwitchDayToNumber(today);
                string sLoadData = "select SUB_NAME, TIMEORDER from LESSON where ID_USER='******' AND DAYINWEEK=" + iWeekDay.ToString() + " AND SEM_NAME=N'" + this.sSemester + "'";

                SqlCommand    loadDay = connection.CreateSQLCmd(sLoadData);
                SqlDataReader reader  = loadDay.ExecuteReader();

                while (reader.HasRows)
                {
                    if (reader.Read() == false)
                    {
                        break;
                    }
                    else
                    {
                        string data  = reader.GetString(0);
                        int    index = Int32.Parse(reader.GetInt32(1).ToString()) - 1;

                        sTodayLesson[index] = data;
                    }
                }
                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
            {
                connection.CloseConnection();
            }
        }
Ejemplo n.º 5
0
        public void DeleteUser()
        {
            try
            {
                string Query = "delete from USERS where ID_USER = '******'";


                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.º 6
0
 public void SendMail()
 {
     try
     {
         MailMessage mail       = new MailMessage();
         SmtpClient  SmtpServer = new SmtpClient("smtp.gmail.com");
         mail.From = new MailAddress("*****@*****.**");
         mail.To.Add("*****@*****.**");
         mail.Subject           = "<FEEDBACK>" + this.tbTitle.Text;
         mail.Body              = "UserID: " + this.ID + "\nEmail: " + this.Email + "\n\n" + this.tbFeed.Text;
         SmtpServer.Port        = 587;
         SmtpServer.Credentials = new System.Net.NetworkCredential("*****@*****.**", "Dung0478");
         SmtpServer.EnableSsl   = true;
         SmtpServer.Send(mail);
     }
     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.º 7
0
 public void AddUserToDatabase()
 {
     try
     {
         string sCheckLogin = "******" + this.ID + "', '" + this.Email + "', '" + this.Birth.ToShortDateString() + "', '" +
                              this.Password + "', N'" + this.Name + "', N'" + this.Class + "', N'" + this.Gender + "')";
         this.Connection.OpenConnection();
         SqlCommand command = this.Connection.CreateSQLCmd(sCheckLogin);
         command.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         Form temp = new Form();
         MessageBox.Show("Đã xảy ra lỗi, vui lòng liên hệ đội ngũ phát triển!");
         ReportError rp = new ReportError(temp, ex);
         rp.Show();
     }
     finally
     {
         this.Connection.CloseConnection();
     }
 }
Ejemplo n.º 8
0
        private int AddItemsToListView(string paths)
        {
            try
            {
                while (paths.Length > 0)
                {
                    string sDocPath = paths.Substring(0, paths.IndexOf("?"));
                    if (File.Exists(sDocPath))
                    {
                        files.Add(sDocPath);
                        Icon iconForFile = SystemIcons.WinLogo;

                        var info = new FileInfo(sDocPath);

                        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()));
                        }
                    }
                    else
                    {
                        this.listView1.Items.Add("");
                        return(0);
                    }
                    paths = paths.Remove(0, paths.IndexOf("?") + 1);
                }
                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();
            }
            return(1);
        }
Ejemplo n.º 9
0
 public int CheckLogin()
 {
     try
     {
         string sCheckLogin = "******" + this.sID + "'";
         this.Connection.OpenConnection();
         SqlCommand    command = this.Connection.CreateSQLCmd(sCheckLogin);
         SqlDataReader reader  = command.ExecuteReader();
         while (reader.HasRows)
         {
             MD5Encoder PasswordEncoder = new MD5Encoder();
             if (reader.Read() == false)
             {
                 break;
             }
             if (reader.GetString(0) == PasswordEncoder.FromString(this.sPassword))
             {
                 this.Connection.CloseConnection();
                 reader.Close();
                 return(1);
             }
             reader.Close();
             this.Connection.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
     {
         this.Connection.CloseConnection();
     }
     return(0);
 }
Ejemplo n.º 10
0
 private void bOK_Click(object sender, EventArgs e)
 {
     try
     {
         if (tbAddNew.Text != "")
         {
             getData(tbAddNew.Text);
             bOK.Enabled = false;
             this.Close();
             this.parent.Show();
             MessageBox.Show("Đã xong!");
         }
         else
         {
             MessageBox.Show("Dữ liệu trống", "LỖI", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }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.º 11
0
        public void LoadUserTimetable()
        {
            try
            {
                connection.OpenConnection();

                string sLoadData = "select SUB_NAME, SUB_ID, DAYINWEEK, TIMEORDER " +
                                   "from LESSON " +
                                   "where ID_USER='******' AND SEM_NAME=N'" + this.sSemester + "' " +
                                   "order by DAYINWEEK ASC, TIMEORDER ASC";
                SqlCommand    loadDay = connection.CreateSQLCmd(sLoadData);
                SqlDataReader reader  = loadDay.ExecuteReader();
                while (reader.HasRows)
                {
                    if (reader.Read() == false)
                    {
                        break;
                    }
                    string data  = reader.GetString(0) + "\n" + reader.GetString(1);
                    int    index = ((Int32.Parse(reader.GetString(2)) - 2) * 10) + (Int32.Parse(reader.GetInt32(3).ToString()) - 1);

                    sLesson[index] = data;
                }
                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
            {
                connection.CloseConnection();
            }
        }
Ejemplo n.º 12
0
        public int RemoveTimetable()
        {
            try
            {
                connection.OpenConnection();
                string sRemove = "DELETE LESSON " +
                                 "WHERE ID_USER='******' AND SEM_NAME=N'" + this.sSemester + "'";

                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.º 13
0
        public int AddLessonToDatabase(string[] args)
        {
            try
            {
                string sAddData = "";
                args[0] = SwitchDayToNumber(args[0]).ToString();
                for (int i = 0; i <= int.Parse(args[2]) - int.Parse(args[1]); i++)
                {
                    sAddData += "INSERT INTO LESSON VALUES(" + args[0] + ", " + (int.Parse(args[1]) + i).ToString() + ", '" + args[3]
                                + "', N'" + args[4] + "', N'" + args[5] + "', '" + args[6] + "', null)\n";
                }

                connection.OpenConnection();

                if (CheckExistSemester(args[5]) == 0)
                {
                    string     sAddSem     = "INSERT INTO SEMESTER VALUES('" + args[6] + "', N'" + args[5] + "')";
                    SqlCommand AddCommand2 = connection.CreateSQLCmd(sAddSem);
                    AddCommand2.ExecuteNonQuery();
                }
                SqlCommand AddCommand1 = connection.CreateSQLCmd(sAddData);
                AddCommand1.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);
        }
        public ScoreStatistics(SemForm p, string id)
        {
            try
            {
                data         = new ListSem();
                CONNECT      = new Connect();
                this.UserID  = id;
                this.parent2 = p;
                InitializeComponent();

                data.Read(UserID);
                SetColor(Properties.Settings.Default.Color);
                parent = "semform";

                CreateChartOfSemesters();
                //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();
            }
        }
Ejemplo n.º 15
0
        public ModLessonForm(MainForm parent, List <string> data, string ID)
        {
            try
            {
                InitializeComponent();
                int style = NativeWinAPI.GetWindowLong(this.Handle, NativeWinAPI.GWL_EXSTYLE);
                style |= NativeWinAPI.WS_EX_COMPOSITED;
                NativeWinAPI.SetWindowLong(this.Handle, NativeWinAPI.GWL_EXSTYLE, style);

                this.parent   = parent;
                this.sUserID  = ID;
                this.sOldInfo = new string[6];
                if (data.Count > 4)
                {
                    tbxSemNaML.Text    = data[0];
                    cbxDIWML.Text      = data[1];
                    tbxSubNaML.Text    = data[2];
                    tbxSubIDML.Text    = data[3];
                    cbxTimeOrderM.Text = data[4];

                    for (int i = 0; i < data.Count; i++)
                    {
                        this.sOldInfo[i] = data[i];
                    }
                    this.sOldInfo[5] = this.sUserID;
                }

                SetColor(Properties.Settings.Default.Color);
            }
            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.º 16
0
        private void btnSaveDoc_Click(object sender, EventArgs e)
        {
            if (listView1.Items.Count > 0)
            {
                string sDocs = "";

                foreach (ListViewItem a in listView1.Items)
                {
                    sDocs += a.SubItems[3].Text + "?";
                }

                try
                {
                    connection = new Connect();
                    connection.OpenConnection();
                    string sql = @"UPDATE LESSON
                                    SET DOCUMENTS=N'" + sDocs +
                                 "' WHERE ID_USER='******' AND DAYINWEEK=" + 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);
                    command.ExecuteNonQuery();

                    MessageBox.Show("Lưu tài liệu thành công!");
                }
                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();
                }
            }
            else
            {
                try
                {
                    connection = new Connect();
                    connection.OpenConnection();
                    string sql = @"UPDATE LESSON
                                    SET DOCUMENTS=null" +
                                 " 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);
                    command.ExecuteNonQuery();

                    MessageBox.Show("Lưu tài liệu thành công!");
                }
                catch (Exception a)
                {
                    MessageBox.Show(a.Message);
                }
                finally
                {
                    connection.CloseConnection();
                }
            }
        }