public void DelOwe(FundOwe fundOwe) { sqlString = string.Format("EXEC XOANOTHU {0}, {1}", fundOwe.FundID, fundOwe.ID); sqlCommand = new SqlCommand(sqlString, sqlConnection); sqlConnection.Open(); sqlCommand.ExecuteNonQuery(); sqlConnection.Close(); }
private FundOwe TableToFundOwe(DataTable table, int location) { DataRow row = table.Rows[location]; FundOwe fundOwe = new FundOwe(); fundOwe.FundID = Convert.ToInt32(row[0]); fundOwe.ID = Convert.ToInt32(row[1]); fundOwe.FindName(); return(fundOwe); }
public Collect() { InitializeComponent(); //Timer DispatcherTimer timer = new DispatcherTimer(); timer.Interval = TimeSpan.FromSeconds(0.1); timer.Tick += Timer_Tick; timer.Start(); //Button load btSave.IsDefault = true; //Textbox load txtTitle.Focus(); //Student list load if (GlobalVariables.isEdit == false) { PassArrayListToListView(GlobalVariables.studentList, lvNotCollected); } else { //Load ListView if (GlobalVariables.fundOweList.Count > 0) { int i = 0; while (i < GlobalVariables.fundOweList.Count) { FundOwe tmp = (FundOwe)GlobalVariables.fundOweList[i]; if (tmp.FundID == GlobalVariables.TmpFundCollect.ID) { lvNotCollected.Items.Add(tmp); } i++; } } //Load info of Fund Collect txtTitle.Text = GlobalVariables.TmpFundCollect.Title; txtMoney.Text = Convert.ToString(GlobalVariables.TmpFundCollect.Fund); dpStartDate.SelectedDate = GlobalVariables.TmpFundCollect.StartDate; dpOutDate.SelectedDate = GlobalVariables.TmpFundCollect.OutDate; cbStartus.Text = GlobalVariables.TmpFundCollect.Status; } }
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(); }