private bool Save() { if (txtProductNatureCode.Text.Length == 0) { errorProvider.SetError(txtProductNatureCode, "Cannot be blank!"); return(false); } else { ProductNature oProductNature = ProductNature.Load(this.ProductNatureId); if (oProductNature == null) { oProductNature = new ProductNature(); if (CodeExists()) { errorProvider.SetError(txtProductNatureCode, "Duplicated Product Nature Code!"); return(false); } else { oProductNature.NatureCode = txtProductNatureCode.Text; errorProvider.SetError(txtProductNatureCode, string.Empty); } } oProductNature.NatureName = txtProductNatureName.Text; oProductNature.NatureName_Chs = txtProductNatureNameChs.Text; oProductNature.NatureName_Cht = txtProductNatureNameCht.Text; oProductNature.ParentNature = (cboParentNature.SelectedValue == null)? System.Guid.Empty:new System.Guid(cboParentNature.SelectedValue.ToString()); oProductNature.Save(); return(true); } }
private void Delete() { ProductNature oNature = ProductNature.Load(this.ProductNatureId); if (oNature != null) { try { oNature.Delete(); } catch { MessageBox.Show("Cannot delete the record being used by other record!", "Delete Warning"); } } }
void lvProductNatureList_CellClick(object sender, System.Windows.Forms.DataGridViewCellEventArgs e) { DataGridViewRow natureIdRow = lvProductNatureList.Rows[e.RowIndex]; if (DAL.Common.Utility.IsGUID(natureIdRow.Cells["colProductNatureId"].Value.ToString())) { ProductNature oProductNature = ProductNature.Load(new System.Guid(natureIdRow.Cells["colProductNatureId"].Value.ToString())); if (oProductNature != null) { this.ProductNatureId = oProductNature.NatureId; FillParentNatureList(); txtProductNatureCode.Text = oProductNature.NatureCode; txtProductNatureName.Text = oProductNature.NatureName; txtProductNatureNameChs.Text = oProductNature.NatureName_Chs; txtProductNatureNameCht.Text = oProductNature.NatureName_Cht; cboParentNature.SelectedValue = oProductNature.ParentNature; SetCtrlEditable(); } } }