private void btnDelete_Click(object sender, EventArgs e) { try { UOMConversions uc = uom.Get(int.Parse(txtUOMCode.Text)); uom.Delete(uc); MessageBox.Show("Selected UOM Conversion Successfully Deleted"); RowFocusedIndex = 0; FRM_UOM_Load(null, null); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnModify_Click(object sender, EventArgs e) { try { UOMConversions uc = uom.Get(int.Parse(txtUOMCode.Text)); uc.Unit_Code_From = int.Parse(UnitFrom.EditValue.ToString()); uc.Unit_Code_To = int.Parse(UnitTo.EditValue.ToString()); uc.Factor = spFactor.Value; uc.IsSpecial = radUOMType.SelectedIndex == 0 ? false : true; uc.ProductCode = radUOMType.SelectedIndex == 0 ? null : (int?)int.Parse(Product.EditValue.ToString()); uom.Update(uc); int ModifiedRowIndex = RowFocusedIndex; MessageBox.Show("Selected UOM Conversion Successfully Modified"); FRM_UOM_Load(null, null); GetFocusedRowData(ModifiedRowIndex); UOMView.FocusedRowHandle = ModifiedRowIndex; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void GetFocusedRowData(int index) { if (index >= 0 && UOMView.RowCount > 0) { UOMView.FocusedRowHandle = index; btnSave.Enabled = false; btnAddNew.Enabled = btnModify.Enabled = true; txtUOMCode.Text = UOMView.GetRowCellValue(index, UOMConversionsManager.UOMDetails.ID.ToString()).ToString(); UnitFrom.EditValue = UOMView.GetRowCellValue(index, UOMConversionsManager.UOMDetails.UnitFromCode.ToString()).ToString(); UnitTo.EditValue = UOMView.GetRowCellValue(index, UOMConversionsManager.UOMDetails.UnitToCode.ToString()).ToString(); spFactor.Value = decimal.Parse(UOMView.GetRowCellValue(index, UOMConversionsManager.UOMDetails.Factor.ToString()).ToString()); UOMConversions c = uom.Get(int.Parse(txtUOMCode.Text)); if (c.IsSpecial == true) { radUOMType.SelectedIndex = 1; Product.EditValue = c.ProductCode; } else { radUOMType.SelectedIndex = 0; } } }