Esempio n. 1
0
 public void DelFundCollect(FundCollect fundCollect)
 {
     sqlString  = "EXEC XOATHU " + fundCollect.ID;
     sqlCommand = new SqlCommand(sqlString, sqlConnection);
     sqlConnection.Open();
     sqlCommand.ExecuteNonQuery();
     sqlConnection.Close();
 }
Esempio n. 2
0
        private void btSave_Click(object sender, RoutedEventArgs e)
        {
            FundCollect fundCollect = new FundCollect();

            fundCollect.Title     = txtTitle.Text;
            fundCollect.Fund      = Convert.ToDouble(txtMoney.Text);
            fundCollect.StartDate = dpStartDate.SelectedDate.Value;
            fundCollect.OutDate   = dpOutDate.SelectedDate.Value;
            fundCollect.Status    = cbStartus.Text;
            fundCollect.Count     = count;
            fundCollect.TotalCount();
            DataBase dataBase = new DataBase();

            dataBase.Connection();
            if (GlobalVariables.isEdit == true)
            {
                fundCollect.ID = GlobalVariables.TmpFundCollect.ID;
                dataBase.EditFundCollect(fundCollect);
                for (int i = 0; i < lvNotCollected.SelectedItems.Count; i++)
                {
                    FundOwe fundOwe = (FundOwe)lvNotCollected.SelectedItems[i];
                    dataBase.DelOwe(fundOwe);
                }
                GlobalVariables.isEdit = false;
            }
            else
            {
                dataBase.AddFundCollect(fundCollect);
                DataRow row = dataBase.FundCollectTable().Rows[dataBase.FundCollectTable().Rows.Count - 1];
                for (int i = 0; i < lvNotCollected.SelectedItems.Count; i++)
                {
                    lvNotCollected.Items.Remove(lvNotCollected.SelectedItems[i]);
                }
                for (int i = 0; i < lvNotCollected.Items.Count; i++)
                {
                    FundOwe tmp     = new FundOwe();
                    Student student = (Student)lvNotCollected.Items[i];
                    tmp.ID     = student.ID;
                    tmp.FundID = Convert.ToInt32(row[0]);
                    dataBase.AddOwe(tmp);
                }
            }
            this.Close();
        }
Esempio n. 3
0
        public void EditFundCollect(FundCollect fundCollect)
        {
            int status;

            //Trans status from string to bit
            if (fundCollect.Status == "Mở")
            {
                status = 1;
            }
            else
            {
                status = 0;
            }

            sqlString  = string.Format("EXEC CAPNHATTHU {0}, '{1}', {2}, '{3}', '{4}', {5}, {6}", fundCollect.ID, fundCollect.Title, fundCollect.Count, fundCollect.StartDate, fundCollect.OutDate, fundCollect.Fund, status);
            sqlCommand = new SqlCommand(sqlString, sqlConnection);
            sqlConnection.Open();
            sqlCommand.ExecuteNonQuery();
            sqlConnection.Close();
        }
Esempio n. 4
0
        private FundCollect TableToFundCollect(DataTable table, int location)
        {
            DataRow     row         = table.Rows[location];
            FundCollect fundCollect = new FundCollect();

            fundCollect.ID        = Convert.ToInt32(row[0]);
            fundCollect.Title     = (string)row[1];
            fundCollect.Count     = Convert.ToInt32(row[2]);
            fundCollect.StartDate = Convert.ToDateTime(row[3]);
            fundCollect.OutDate   = Convert.ToDateTime(row[4]);
            fundCollect.Fund      = Convert.ToDouble(row[5]);
            if (Convert.ToInt32(row[6]) == 1)
            {
                fundCollect.Status = "Mở";
            }
            else
            {
                fundCollect.Status = "Đóng";
            }
            fundCollect.TotalCount();
            return(fundCollect);
        }
Esempio n. 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;
            }
        }