private void InsertEvent_Load(object sender, EventArgs e) { DataTable dtLoc = new DataTable(); DataTable dtCat = new DataTable(); DataTable dtUse = new DataTable(); Category cat = new Category(); User use = new User(); BusinessLayer.Location loc = new Location(); dtLoc = loc.getLocaitonPickList(); dtCat = cat.getCategoryPickList(); dtUse = use.getPersonList(); cboCat.DataSource = dtCat; cboLoc.DataSource = dtLoc; cboUser.DataSource = dtUse; cboCat.DisplayMember = "Descr"; cboCat.ValueMember = "CategoryID"; cboLoc.DisplayMember = "Descr"; cboLoc.ValueMember = "LocationID"; cboUser.DisplayMember = "Display"; cboUser.ValueMember = "UserID"; }
private void cmdAdd_Click(object sender, EventArgs e) { if (txtCategoryID.Text.Trim() == "") { MessageBox.Show("กรุณาป้อนรหัสประเภทสินค้าก่อน !!!", "ผลการตรวจสอบ", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtCategoryID.Focus(); return; } if (txtCategoryName.Text.Trim() == "") { MessageBox.Show("กรุณาป้อนชื่อประเภทสินค้าก่อน !!!", "ผลการตรวจสอบ", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtCategoryName.Focus(); return; } if (MessageBox.Show("คุณต้องการเพิ่มประเภทสินค้าใหม่ ใช่หรือไม่?", "คำยืนยัน", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { try { Category category = serviceCategory.getByCode(txtCategoryID.Text.Trim()); if (category == null) { Category newCategory = new Category(); newCategory.CategoryCode = txtCategoryID.Text.Trim(); newCategory.CategoryName = txtCategoryName.Text.Trim(); bool saveCategory = serviceCategory.Save(newCategory); if (saveCategory) { MessageBox.Show("เพิ่มประเภทสินค้าใหม่ เรียบร้อยแล้ว !!!", "ผลการทำงาน", MessageBoxButtons.OK, MessageBoxIcon.Information); loadData(); } else { MessageBox.Show("ไม่สามารถ เพิ่มประเภทสินค้าใหม่ได้!!!", "ผลการทำงาน", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("มีประเภทสินค้านี้อยู่แล้ว!!!", "ผลการทำงาน", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show("ไม่สามารถ เพิ่มประเภทสินค้าใหม่ได้ เนื่องจาก !!! : "+ex.Message, "ผลการทำงาน", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
public void loadDefault() { Category servicCategory = new Category(); IList<Category> categorys = servicCategory.getCategoryAll(); cboCategory.BeginUpdate(); cboCategory.DisplayMember = "CategoryName"; cboCategory.ValueMember = "CategoryCode"; cboCategory.DataSource = categorys; cboCategory.EndUpdate(); Unit serviceUnit = new Unit(); IList<Unit> units = serviceUnit.getUnitAll(); cboUnit.BeginUpdate(); cboUnit.DisplayMember = "UName"; cboUnit.ValueMember = "UCode"; cboUnit.DataSource = units; cboUnit.EndUpdate(); }
public void loadDefault() { WareHouse servicewareHouse = new WareHouse(); IList<WareHouse> warehouses = servicewareHouse.getWareHouseAll(); cbowarhouse.BeginUpdate(); cbowarhouse.DisplayMember = "WHName"; cbowarhouse.ValueMember = "WHCode"; cbowarhouse.DataSource = warehouses; cbowarhouse.EndUpdate(); Category servicCategory = new Category(); IList<Category> categorys = servicCategory.getCategoryAll(); cbocategory.BeginUpdate(); cbocategory.DisplayMember = "CategoryName"; cbocategory.ValueMember = "CategoryCode"; cbocategory.DataSource = categorys; cbocategory.EndUpdate(); }