Example #1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            DialogResult Dir = MessageBox.Show("តើអ្នកចង់លុបទិន្នន័យនេះឫទេ?", "ទិន្នន័យនឹងត្រូវបានលុប", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (Dir == DialogResult.Yes)
            {
                Statement1 = @"DELETE FROM Expense WHERE ExpID in(";
                for (int i = 0; i < DataExpense.SelectedRows.Count; i++)
                {
                    Statement1 += "'" + DataExpense.SelectedRows[i].Cells[0].Value.ToString() + "',";
                }
                Statement1 = Statement1.TrimEnd(',') + ");";
                MessageBox.Show(Statement1);
                if (Dom_SqlClass.SQLMultiTable(new string[] { Statement1 }) == true)
                {
                    while (DataExpense.SelectedRows.Count > 0)
                    {
                        int i = DataExpense.SelectedRows[0].Index;
                        DataExpense.Rows.RemoveAt(i);
                        if (n != 0)
                        {
                            n--;
                        }
                    }
                }
            }
            //ID = dom_Design.GenerateID(ID.Substring(6), "Cus_00");
            //txtID.Text = ID;
            Clear();
        }
Example #2
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();
         }
     }
 }
Example #3
0
 private void btnEdit_Click(object sender, EventArgs e)
 {
     if (DataExpense.SelectedRows.Count == 1)
     {
         Statement1 = @"UPDATE Expense Set ExpID='" + txtID.Text + "', DateCreated='" + DateNote.Value.ToShortDateString() + "' WHERE ExpID='" + txtID.Text + "';";
         Statement2 = @"UPDATE ExpenseDetail Set ExpID='" + txtID.Text + "', ExpTypeID='" + cmType.ValueMember + "', ExpDes='" + txtName.Text + "', ExpDate='" + datePay.Value.ToShortDateString() + "', Amount=" + txtAmount.Text + " WHERE ExpID='" + txtID.Text + "';";
         // MessageBox.Show(Statement1 + "\n" + Statement2);
         if (Dom_SqlClass.SQLMultiTable(new string[] { Statement1, Statement2 }) == true)
         {
             int i = DataExpense.SelectedRows[0].Index;
             DataExpense.Rows[i].Cells[0].Value = txtID.Text;
             DataExpense.Rows[i].Cells[1].Value = DateNote.Value;
             DataExpense.Rows[i].Cells[2].Value = cmType.SelectedItem.ToString();
             DataExpense.Rows[i].Cells[3].Value = txtName.Text;
             DataExpense.Rows[i].Cells[4].Value = datePay.Value;
             DataExpense.Rows[i].Cells[5].Value = txtAmount.Text;
         }
     }
     else
     {
         MessageBox.Show("Please Select any Rows in List");
     }
     Clear();
 }