private void CRUD_Product(int? proId, UnileverObject.BLL.CRUDOPTION option) { Product p = new Product(); string name = this.txtpName.Text; string price = this.txtpPrice.Text; string remain = this.txtpRemain.Text; string descript = this.txtpDescript.Text; string catid = null; try { catid = ((Category)this.cbxpCategory.SelectedItemValue).ID.ToString(); } catch (Exception) { UnileverError.Show("Choose a category for this product", UnileverError.WARN_CAPTION, System.Windows.Forms.MessageBoxIcon.Warning); return; } string importdate = this.depImportDate.EditValue.ToString(); if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(price) || string.IsNullOrEmpty(remain) || string.IsNullOrEmpty(descript) || string.IsNullOrEmpty(catid) || string.IsNullOrEmpty(importdate)) { UnileverError.Show("Missing field !", UnileverError.WARN_CAPTION, System.Windows.Forms.MessageBoxIcon.Warning ); } else { try { if (this.UnileverBll.SaveChangesProduct(proId.Value, name, catid, price, importdate, remain, descript, option)) { LoadProductToControl(); } } catch (Exception) // lưu dữ liệu bị lỗi { UnileverError.Show("Something fail, try again!", UnileverError.ERR_CAPTION, System.Windows.Forms.MessageBoxIcon.Warning ); } } }
private void CRUD_Distributor(int? distribId, UnileverObject.BLL.CRUDOPTION option) { string name = this.txtdbName.Text; string email = this.txtdbEmail.Text; string phone = this.txtdbPhone.Text; string addr = this.txtdbAddr.Text; if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(email) || string.IsNullOrEmpty(phone) || string.IsNullOrEmpty(addr)) { Handle.UnileverError.Show("Missing field.", Handle.UnileverError.WARN_CAPTION, System.Windows.Forms.MessageBoxIcon.Warning); } else { try { if (this.UnileverBll.SaveChangesDistributor(distribId.Value, name, email, phone, addr, option)) { LoadDistributorToControl(); } ClearTextBox(); } catch (Exception) // có lỗi trong quá trình lưu vào db { UnileverError.Show(UnileverError.SAVE_DB_ERRORMSG, UnileverError.WARN_CAPTION); } } }