private void btnAddUnit_Click(object sender, EventArgs e) { try { Unit_DTO unit = new Unit_DTO(); unit.UnitID = txtUnitID.Text; unit.UnitName = txtUnitName.Text; unit.UnitPrice = txtUnitPrice.Text; if (txtUnitID.Text == "" || txtUnitName.Text == "" || txtUnitPrice.Text == "") { XtraMessageBox.Show("You have to fullfill unit information!", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Warning); ClearDisplay(); return; } if (Unit_BUS.InsertUnit(unit)) { XtraMessageBox.Show("Unit Info has been inserted sucessfully!", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadUnitList(); ClearDisplay(); return; } } catch { XtraMessageBox.Show("Insert Info Failed!", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }
public void btnDeleteUnit_Click(object sender, EventArgs e) { try { Unit_DTO unit = new Unit_DTO(); unit.UnitID = dtgvUnitInfoList.CurrentRow.Cells["UnitID"].Value.ToString(); unit.UnitName = txtUnitName.Text; if (txtUnitID.Text == "" || txtUnitName.Text == "" || txtUnitPrice.Text == "") { XtraMessageBox.Show("You have to choose at least one unit to delete!", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Warning); ClearDisplay(); return; } if (Unit_BUS.DeleteUnit(unit)) { LoadUnitList(); XtraMessageBox.Show("Unit Info has been deleted sucessfully!", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information); ClearDisplay(); return; } } catch { XtraMessageBox.Show("Delete Info Failed!", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }
private void LoadUnit() { List <Unit_DTO> loadUnit = Unit_BUS.LoadUnit(); cmbUnit.DataSource = loadUnit; cmbUnit.ValueMember = "UnitID"; cmbUnit.DisplayMember = "UnitName"; }
public void LoadUnitList() { List <Unit_DTO> unit = Unit_BUS.LoadUnit(); dtgvUnitInfoList.DataSource = unit; }