private void btnSave_Click(object sender, EventArgs e) { try { if (!string.IsNullOrWhiteSpace(txtFieldName.Text)) { ComArugments args = new ComArugments(); args.ParamList[clsLabCommon.Laboratory.TestField.TestFieldId] = FieldId; args.ParamList[clsLabCommon.Laboratory.TestField.TestFieldName] = txtFieldName.Text.Replace("'", "''"); args.ParamList[clsLabCommon.Laboratory.TestField.TestFieldTypeId] = cboFieldType.SelectedValue; args.ParamList[clsLabCommon.Laboratory.TestField.Unit] = txtUnit.Text.Replace("'", "''");; args.ParamList[clsLabCommon.Laboratory.TestField.ReferenceValue] = rtxtReferenceValue.Text.Replace("'", "''"); int rowsAffected = objBusinessFacade.AddEditTestField(args); if (rowsAffected > 0) { if (cboFieldType.Text.Equals("ComboBox")) { int lastInsertedFieldId = 0; if (FieldId == 0) { lastInsertedFieldId = objBusinessFacade.getLastInsertedId(); } for (int i = 0; i < dgvTestItem.Rows.Count - 1; i++) { ComArugments argsTestItems = new ComArugments(); argsTestItems.ParamList[clsLabCommon.Laboratory.TestItem.TestItemId] = dgvTestItem.Rows[i].Cells["Id"].FormattedValue.ToString() == "" ? 0 : dgvTestItem.Rows[i].Cells["Id"].FormattedValue; argsTestItems.ParamList[clsLabCommon.Laboratory.TestItem.TestItemName] = dgvTestItem.Rows[i].Cells["Item"].Value; argsTestItems.ParamList[clsLabCommon.Laboratory.TestItem.TestFieldId] = FieldId == 0 ? lastInsertedFieldId : FieldId; int flag = objBusinessFacade.AddEditTestItems(argsTestItems); } } if (FieldId == 0) { MessageBox.Show("Test Field is saved", "Test Field", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Test Field is updated", "Test Field", MessageBoxButtons.OK, MessageBoxIcon.Information); } ClearControls(); } objBusinessFacade.commitTransction(); } else { MessageBox.Show("Please enter Test Field", "Test Field", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show(ex.Message + " " + ex.StackTrace); } }
private void save_data() { try { List <LabDynamicControl> lstCtrl = new List <LabDynamicControl>(); foreach (Control c in panel4.Controls) { foreach (Control ctrl in c.Controls) { LabDynamicControl obj = new LabDynamicControl(); obj.ctrlName = ctrl.Name; obj.ctrlValue = ctrl.Text; lstCtrl.Add(obj); } } int flag = 0; int iSaved = 0; //Save Lab Test Result ComArugments args = new ComArugments(); args.ParamList[clsLabCommon.Laboratory.TestResultEntry.ResultEntryId] = ResultEntryId; args.ParamList[clsLabCommon.Laboratory.TestResultEntry.BillId] = BillId; args.ParamList[clsLabCommon.Laboratory.TestResultEntry.ReceivedDateTime] = dtpReceivedDateTime.Value; args.ParamList[clsLabCommon.Laboratory.TestResultEntry.ReportedDateTime] = dtpReportedDateTime.Value; if (ResultEntryId == 0) { ResultEntryId = objBusiness.SaveResultEntryInfo(args); } else { iSaved = objBusiness.SaveResultEntryInfo(args); } //Delete all the entries in Test_Result_Entry Table and Save the Details int iDeleted = objBusiness.DeletePatientResultEntry(ResultEntryId); foreach (DataRow row in dtResultEntry.Rows) { LabDynamicControl obj = lstCtrl.Find(ctrl => ctrl.ctrlName.Equals("txt" + row["test_field_id"].ToString() + "_" + row["investigation_id"].ToString())); string resultValue = string.Empty; if (obj != null) { resultValue = obj.ctrlValue; } ComArugments argsDetail = new ComArugments(); argsDetail.ParamList[clsLabCommon.Laboratory.TestResultEntry.ResultEntryId] = ResultEntryId; argsDetail.ParamList[clsLabCommon.Laboratory.TestResultEntry.InvestigationId] = row["investigation_id"].ToString(); argsDetail.ParamList[clsLabCommon.Laboratory.TestResultEntry.TestFieldId] = row["test_field_id"].ToString(); //argsDetail.ParamList[clsLabCommon.Laboratory.TestResultEntry.ResultValue] = resultValue; argsDetail.ParamList[clsLabCommon.Laboratory.TestResultEntry.ResultValue] = resultValue.Replace("'", "''"); flag = objBusiness.SaveResultEntryDetailInfo(argsDetail); } objBusiness.commitTransction(); if (flag > 0) { MessageBox.Show("Result Entry is saved", "Result Entry", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Result Entry", MessageBoxButtons.OK, MessageBoxIcon.Error); objBusiness.rollBackTransation(); } }
private void btnSave_Click(object sender, EventArgs e) { try { if (dgvUserActivities.Rows.Count > 0) { int count = 0; DataGridViewCheckBoxCell ch = new DataGridViewCheckBoxCell(); foreach (DataGridViewRow row in dgvUserActivities.Rows) { ch = (DataGridViewCheckBoxCell)row.Cells[3]; if (ch.Value == null) { ch.Value = false; } switch (ch.Value.ToString()) { case "1": //Selected User Activity { count++; break; } case "0": { if (row.Cells["Activity"].Value.ToString() == "User Rights") { if (cboUser.Text == "Admin") { MessageBox.Show("Please select User rights Activity!", "Map User Activity", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } break; } } } if (count > 0) { int iDeleted = objBusiness.DeleteUserRoleActities(Convert.ToInt32(cboUser.SelectedValue)); int iSaved = 0; DataGridViewCheckBoxCell ch1 = new DataGridViewCheckBoxCell(); foreach (DataGridViewRow row in dgvUserActivities.Rows) { ch1 = (DataGridViewCheckBoxCell)row.Cells[3]; if (ch1.Value == null) { ch1.Value = false; } switch (ch1.Value.ToString()) { case "1": //Selected User Activity { ComArugments args = new ComArugments(); args.ParamList[CIS.Common.User.UserMapRoleAction.RoleId] = cboUser.SelectedValue; args.ParamList[CIS.Common.User.UserMapRoleAction.ActionId] = row.Cells["action_id"].Value.ToString(); iSaved = objBusiness.SaveUserRoleActivity(args); break; } } //if (Convert.ToInt32(row.Cells[3].Value.ToString()) == 1) } if (iSaved > 0) { MessageBox.Show("Activities are mapped successfully", "Map User Activity", MessageBoxButtons.OK, MessageBoxIcon.Information); } objBusiness.commitTransction(); } else { MessageBox.Show("Activities are not selected!", "Map User Activity", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } catch (Exception ex) { objBusiness.rollBackTransation(); MessageBox.Show(ex.Message); } }