示例#1
0
 private void btnSearch_Click(object sender, EventArgs e)
 {
     if (rndSearchID.Checked)
     {
         DT.Rows.Clear();
         String ST = @"SELECT Expense.ExpID,Expense.DateCreated,ExpenseType.ExpDesc,ExpenseDetail.ExpDes,ExpenseDetail.ExpDate,ExpenseDetail.Amount FROM Expense JOIN ExpenseDetail ON ExpenseDetail.ExpID=Expense.ExpID JOIN ExpenseType ON ExpenseDetail.ExpTypeID=ExpenseType.ExpTypeID WHERE LOWER(Expense.ExpID)='" + txtSearch.Text + "';";
         DT = Dom_SqlClass.retriveDataMultiTable(ST);
         GeneratData();
         DataExpense.ClearSelection();
     }
     else if (rndSearcAll.Checked)
     {
         DT.Rows.Clear();
         String Statement = @" SELECT Expense.ExpID,Expense.DateCreated,ExpenseType.ExpDesc,ExpenseDetail.ExpDes,ExpenseDetail.ExpDate,ExpenseDetail.Amount FROM Expense JOIN ExpenseDetail ON Expense.ExpID=ExpenseDetail.ExpID JOIN ExpenseType ON ExpenseType.ExpTypeID=ExpenseDetail.ExpTypeID; ";
         DT = Dom_SqlClass.retriveDataMultiTable(Statement);
         GeneratData();
         DataExpense.ClearSelection();
     }
     else
     {
         DT.Rows.Clear();
         String ST = @"SELECT Expense.ExpID,Expense.DateCreated,ExpenseType.ExpDesc,ExpenseDetail.ExpDes,ExpenseDetail.ExpDate,ExpenseDetail.Amount FROM Expense JOIN ExpenseDetail ON ExpenseDetail.ExpID=Expense.ExpID JOIN ExpenseType ON ExpenseDetail.ExpTypeID=ExpenseType.ExpTypeID WHERE Expense.DateCreated='" + DateSearch.Value.ToShortDateString() + "'or ExpenseDetail.ExpDate='" + DateSearch.Value.ToShortDateString() + "';";
         DT = Dom_SqlClass.retriveDataMultiTable(ST);
         GeneratData();
         DataExpense.ClearSelection();
     }
 }
示例#2
0
 void Clear()
 {
     DataExpense.ClearSelection();
     DateNote.Value       = DateTime.Now;
     cmType.SelectedIndex = -1;
     txtName.Text         = "";
     datePay.Value        = DateTime.Now;
     txtAmount.Text       = "";
     txtID.Text           = ID;
 }
示例#3
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     if (DataExpense.SelectedRows.Count < 1)
     {
         if (cmType.SelectedIndex != -1 && txtName.Text != "" && txtAmount.Text != "")
         {
             String   EID    = txtID.Text;
             DateTime DN     = DateNote.Value;
             String   Type   = cmType.SelectedItem.ToString();
             String   Name   = txtName.Text;
             DateTime DP     = datePay.Value;
             float    Amount = float.Parse(txtAmount.Text);
             Statement1 = @"INSERT INTO Expense Values( '" + EID + "'," + "'" + DN.ToShortDateString() + "');";
             Statement2 = @"INSERT INTO ExpenseDetail Values('" + EID + "', " + "'" + cmType.ValueMember + "', " + "'" + Name + "'," + "" + ((float)Amount) + "," + "'" + DP.ToShortDateString() + "');";
             MessageBox.Show(Statement1 + "\n" + Statement2);
             if (Dom_SqlClass.SQLMultiTable(new string[] { Statement1, Statement2 }) == true)
             {
                 DataExpense.Rows.Add(new object[] { EID, DN, Type, Name, DP, Amount });
                 n++;
             }
             DataExpense.ClearSelection();
             ID = dom_Design.SetID(6, ID, "EXP_00");
             Clear();
         }
         else
         {
             MessageBox.Show("Please Input Importan Information!");
         }
     }
     else
     {
         DialogResult dialog = MessageBox.Show("You are selecting one or more rows!\nDo you want to clear selection?", "Warning", MessageBoxButtons.YesNo);
         if (dialog == DialogResult.Yes)
         {
             DataExpense.ClearSelection();
         }
     }
 }