コード例 #1
0
ファイル: DataBase.cs プロジェクト: chota5511/ClassManager
 public void AddFundUsed(FundUsed fundUsed)
 {
     sqlString  = string.Format("EXEC NHAPCHI '{0}', '{1}', {2}", fundUsed.Date, fundUsed.Title, fundUsed.Fund);
     sqlCommand = new SqlCommand(sqlString, sqlConnection);
     sqlConnection.Open();
     sqlCommand.ExecuteNonQuery();
     sqlConnection.Close();
 }
コード例 #2
0
ファイル: DataBase.cs プロジェクト: chota5511/ClassManager
 public void DelFundUsed(FundUsed fundUsed)
 {
     sqlString  = string.Format("EXEC XOACHI {0}", fundUsed.ID);
     sqlCommand = new SqlCommand(sqlString, sqlConnection);
     sqlConnection.Open();
     sqlCommand.ExecuteNonQuery();
     sqlConnection.Close();
 }
コード例 #3
0
        private FundUsed TableToFundUsed(DataTable table, int location)
        {
            DataRow  row      = table.Rows[location];
            FundUsed fundUsed = new FundUsed();

            fundUsed.ID    = Convert.ToInt32(row[0]);
            fundUsed.Title = (string)row[1];
            fundUsed.Date  = Convert.ToDateTime(row[2]);
            fundUsed.Fund  = Convert.ToDouble(row[3]);
            return(fundUsed);
        }
コード例 #4
0
ファイル: Used.xaml.cs プロジェクト: chota5511/ClassManager
        private void btSave_Click(object sender, RoutedEventArgs e)
        {
            FundUsed fundUsed = new FundUsed();

            fundUsed.Title = txtTitle.Text;
            fundUsed.Fund  = Convert.ToDouble(txtUsed.Text);
            fundUsed.Date  = dpDate.SelectedDate.Value.Date;
            DataBase dataBase = new DataBase();

            dataBase.Connection();
            dataBase.AddFundUsed(fundUsed);
            this.Close();
        }
コード例 #5
0
        //Any reload process here
        private void Timer_Tick(object sender, EventArgs e)
        {
            lbClock.Content = DateTime.Now;

            //Refresh user info
            txtID.Text          = Convert.ToString(GlobalVariables.UserProfile.ID);
            txtName.Text        = GlobalVariables.UserProfile.Name;
            txtEmail.Text       = GlobalVariables.UserProfile.Email;
            txtEmer.Text        = Convert.ToString(GlobalVariables.UserProfile.Emer);
            txtPhoneNumber.Text = Convert.ToString(GlobalVariables.UserProfile.PhoneNumber);
            txtPosition.Text    = GlobalVariables.UserProfile.Position;

            //Studen
            if (lvStudentList.SelectedItems.Count > 0 && GlobalVariables.UserProfile.Position == "Lớp trưởng")
            {
                btDelStudent.IsEnabled = true;
                if (lvStudentList.SelectedItems.Count == 1)
                {
                    btEditStudent.IsEnabled = true;
                }
                else
                {
                    btEditStudent.IsEnabled = false;
                }
            }
            else
            {
                btDelStudent.IsEnabled  = false;
                btEditStudent.IsEnabled = false;
            }

            //Collect
            if (lvCollect.SelectedItems.Count > 0 && GlobalVariables.UserProfile.Position == "Thủ quỹ")
            {
                btDelCollect.IsEnabled = true;
                if (lvCollect.SelectedItems.Count == 1)
                {
                    btEditCollect.IsEnabled = true;
                }
                else
                {
                    btEditCollect.IsEnabled = false;
                }
            }
            else
            {
                btEditCollect.IsEnabled = false;
            }

            //Used
            if (lvUsedList.SelectedItems.Count > 0)
            {
                btDelUsed.IsEnabled = true;
            }
            else
            {
                btDelUsed.IsEnabled = false;
            }

            //Notification
            if (lvAll.SelectedItems.Count > 0 || lvImportant.SelectedItems.Count > 0 || lvNotification.SelectedItems.Count > 0 || lvFree.SelectedItems.Count > 0)
            {
                btDelNotification.IsEnabled = true;
            }
            else
            {
                btDelNotification.IsEnabled = false;
            }

            //Fund
            lbFundStatus.Content = "Tiền quỹ còn lại: " + dataBase.Fund() + " VND";

            //Refresh chat log
            if (chatLogCount < dataBase.ChatLogTable().Rows.Count)
            {
                for (int i = chatLogCount - 1; i < dataBase.ChatLogTable().Rows.Count; i++)
                {
                    DataRow row = dataBase.ChatLogTable().Rows[i];
                    txtData.Text += "[" + FindNameByID((int)row[1]) + "]" + (string)row[2];
                }
                chatLogCount = dataBase.ChatLogTable().Rows.Count;
            }
            if (chatLogCount > dataBase.ChatLogTable().Rows.Count) //reload chat log
            {
                txtData.Clear();
                ChatLogLoad();
                chatLogCount = dataBase.ChatLogTable().Rows.Count;
            }


            //Del Process
            if (GlobalVariables.isDel == true && GlobalVariables.isDelStudent == true) //Del Student
            {
                Student tmp = (Student)lvStudentList.SelectedItems[0];
                lvStudentList.Items.Remove(lvStudentList.SelectedItems[0]);
                dataBase.DelStudent(tmp.ID);
                GlobalVariables.isDel        = false;
                GlobalVariables.isDelStudent = false;
            }

            if (GlobalVariables.isDel == true && GlobalVariables.isDelNotification == true)    //Del Notification
            {
                Notification tmp;
                if (lvAll.SelectedItems.Count > 0)
                {
                    tmp = (Notification)lvAll.SelectedItems[0];
                    lvAll.Items.Remove(lvAll.SelectedItems[0]);
                    dataBase.DelNotification(tmp);
                }
                if (lvImportant.SelectedItems.Count > 0)
                {
                    tmp = (Notification)lvImportant.SelectedItems[0];
                    lvImportant.Items.Remove(lvImportant.SelectedItems[0]);
                    dataBase.DelNotification(tmp);
                }
                if (lvNotification.SelectedItems.Count > 0)
                {
                    tmp = (Notification)lvNotification.SelectedItems[0];
                    lvNotification.Items.Remove(lvNotification.SelectedItems[0]);
                    dataBase.DelNotification(tmp);
                }
                if (lvFree.SelectedItems.Count > 0)
                {
                    tmp = (Notification)lvFree.SelectedItems[0];
                    lvFree.Items.Remove(lvFree.SelectedItems[0]);
                    dataBase.DelNotification(tmp);
                }
                GlobalVariables.isDel             = false;
                GlobalVariables.isDelNotification = false;
            }

            if (GlobalVariables.isDel == true && GlobalVariables.isDelFundUsed == true)
            {
                FundUsed tmp = (FundUsed)lvUsedList.SelectedItems[0];
                lvUsedList.Items.Remove(lvUsedList.SelectedItems[0]);
                dataBase.DelFundUsed(tmp);
                GlobalVariables.isDel         = false;
                GlobalVariables.isDelFundUsed = false;
            }

            if (GlobalVariables.isDel == true && GlobalVariables.isDelFundCollect == true)
            {
                FundCollect tmp = (FundCollect)lvCollect.SelectedItems[0];
                lvCollect.Items.Remove(lvCollect.SelectedItems[0]);
                dataBase.DelFundCollect(tmp);
                GlobalVariables.isDel            = false;
                GlobalVariables.isDelFundCollect = false;
            }
        }