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(); } }
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(); }
private void expensType_Load(object sender, EventArgs e) { DT = Dom_SqlClass.retriveData("ExpenseType", "Where 1=1", new string[] { "*" }); dataTypeExpens.DataSource = DT; dom_Design.GenerateColumHeader(new string[] { "លេខកូដសម្គាល់", "ឈ្មោះប្រភេទចំណាយ" }, dataTypeExpens.ColumnCount, dataTypeExpens); ID = dom_Design.GenerateID(Dom_SqlClass.GetIDFromDB("ExpTypeID", "_", "ExpenseType"), "EXT_00"); txtID.Text = ID; dataTypeExpens.ClearSelection(); }
private void Customer_Load(object sender, EventArgs e) { string[] columnHeaderName = { "លេខកូដសម្គាល់", "នាមត្រកូល", "គោត្តនាម-នាមខ្លួន", "ភេទ", "លេខអត្តសញ្ញាណប័ណ្ណ", "លេខទូរស័ព្ទ" }; DT = Dom_SqlClass.retriveData("Customer", "Where 1=1", new string[] { "*" }); dataCustomer.DataSource = DT; String[] Name = { "CusID", "FName", "LName", "Gender", "IDNum", "Tel" }; dom_Design.ColumnName(dataCustomer, 6, Name); dom_Design.GenerateColumHeader(columnHeaderName, dataCustomer.ColumnCount, dataCustomer); Dom_SqlClass.GetIDFromDB("cusID", "_", "customer"); ID = dom_Design.GenerateID(Dom_SqlClass.GetIDFromDB("cusID", "_", "customer"), "Cus_00"); txtID.Text = ID; dataCustomer.ClearSelection(); txtFname.Focus(); }
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(); } } }
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(); }
private void cmCustomer_TextChanged(object sender, EventArgs e) { if (cmCustomer.SelectedIndex == -1) { foreach (String S in cmCustomer.Items) { if (cmCustomer.Text.ToLower() != S.ToLower()) { if (IDCus == "") { IDCus = dom_Design.GenerateID(Dom_SqlClass.GetIDFromDB("cusID", "_", "customer"), "Cus_00"); } else { IDCus = dom_Design.GenerateID(IDCus, "Cus_00"); } txtIDCus.Text = IDCus; } } } else { } }
private void bunifuThinButton21_Click(object sender, EventArgs e) { Dom_SqlClass.UpdateDate(DT); }
private void Expense_Load(object sender, EventArgs e) { ID = dom_Design.GenerateID(Dom_SqlClass.GetIDFromDB("ExpID", "_", "Expense"), "EXP_00"); txtID.Text = ID; Dom_SqlClass.FillItemToCombobox("SELECT ExpTypeID,ExpDesc FROM ExpenseType", "ExpTypeID", "ExpDesc", cmType); }
void FillItem() { Dom_SqlClass.FillItemToCombobox(@"SELECT CusID,CONCAT(Customer.Fname,' ',Customer.Lname) AS 'fullName' FROM Customer;", "CusID", "fullName", cmCustomer); }