private void btnAdd_Click(object sender, EventArgs e) { string errMsg = string.Empty; if (!CheckInsInfoValid(ref errMsg, true)) { BaseMessageBox.ShowCustomerMessage(MessageBoxIcon.Error, "", errMsg); } else { //insert a new row, db and datatable DbMaintainment operDb = new DbMaintainment(); int insId = 0; operDb.InsertInsInfo(ref insId, (int)(EnumDef.INS_KINDS)(cmbINSType.SelectedItem.GetType().GetProperty("Key").GetValue(cmbINSType.SelectedItem, null)), tbProductName.Text, tbCommonName.Text, tbCode.Text, tbSpec.Text, txtINSUnit.Text, tbInputcode.Text); DataRow newRow = ((DataTable)dgv.DataSource).NewRow(); newRow[DBConstDef.INS_ID] = insId; newRow[ConstDef.TEXT_CONST_IND_KIND] = cmbINSType.Text; newRow[ConstDef.TEXT_INS_NAME] = tbProductName.Text; newRow[ConstDef.TEXT_INS_PRODUCT_NAME] = tbCommonName.Text; newRow[DBConstDef.TEXT_INS_CODE] = tbCode.Text; newRow[DBConstDef.TEXT_INS_SPECIFICATION] = tbSpec.Text; newRow[DBConstDef.TEXT_INS_UNIT] = txtINSUnit.Text; newRow[ConstDef.TEXT_INS_INPUTCODE] = tbInputcode.Text; ((DataTable)dgv.DataSource).Rows.Add(newRow); } }
private void btnAdd_Click(object sender, EventArgs e) { string errMsg = string.Empty; if (!CheckInsInfoValid(ref errMsg, true)) { BaseMessageBox.ShowCustomerMessage(MessageBoxIcon.Error, "", errMsg); } else { //insert a new row, db and datatable DbMaintainment operDb = new DbMaintainment(); int insId = 0; operDb.InsertInsInfo(ref insId, (int)(EnumDef.INS_KINDS)(cmbINSType.SelectedItem.GetType().GetProperty("Key").GetValue(cmbINSType.SelectedItem, null)), tbProductName.Text, tbCommonName.Text, tbCode.Text, tbSpec.Text, txtINSUnit.Text, tbInputcode.Text); DataRow newRow = ((DataTable) dgv.DataSource).NewRow(); newRow[DBConstDef.INS_ID] = insId; newRow[ConstDef.TEXT_CONST_IND_KIND] = cmbINSType.Text; newRow[ConstDef.TEXT_INS_NAME] = tbProductName.Text; newRow[ConstDef.TEXT_INS_PRODUCT_NAME] = tbCommonName.Text; newRow[DBConstDef.TEXT_INS_CODE] = tbCode.Text; newRow[DBConstDef.TEXT_INS_SPECIFICATION] = tbSpec.Text; newRow[DBConstDef.TEXT_INS_UNIT] = txtINSUnit.Text; newRow[ConstDef.TEXT_INS_INPUTCODE] = tbInputcode.Text; ((DataTable) dgv.DataSource).Rows.Add(newRow); } }