private void btnSave_Click_1(object sender, EventArgs e) { try { HSNMapping map = new HSNMapping(); ProductHSNMappingDB mapDB = new ProductHSNMappingDB(); if (txtHSNCode.Text.Trim().Length == 0) { MessageBox.Show("Fill HSN COde"); return; } map.StockItemID = txtStockItemID.Text.Trim(); map.ModelNo = txtModelNo.Text.Trim(); map.HSNCode = txtHSNCode.Text.Trim(); map.Status = getStatusCode(cmbStatus.SelectedItem.ToString()); map.RowID = prevmap.RowID; System.Windows.Forms.Button btn = sender as System.Windows.Forms.Button; string btnText = btn.Text; if (mapDB.validateHSNMapping(map)) { if (btnText.Equals("Update")) { if (mapDB.updateHSNCode(map)) { MessageBox.Show("HSNCode updated"); closeAllPanels(); ListHSNMApping(); } else { MessageBox.Show("Failed to update HSNCode"); } } else if (btnText.Equals("Save")) { if (mapDB.insertHSNCOde(map)) { MessageBox.Show("HSNCode Added"); closeAllPanels(); ListHSNMApping(); } else { MessageBox.Show("Failed to Insert HSNCode"); } } } else { MessageBox.Show("HSNCode Data Validation failed"); } } catch (Exception) { MessageBox.Show("Failed Adding / Editing HSNCode"); } }
public void clearUserData() { try { txtStockItemID.Text = ""; txtStockITemName.Text = ""; txtModelNo.Text = ""; txtModelName.Text = ""; txtHSNCode.Text = ""; cmbStatus.SelectedIndex = 0; prevmap = new HSNMapping(); } catch (Exception) { } }