protected void btnCopy_Click(object sender, EventArgs e) { string id = string.Format("Id: {0} Uri: {1}", Guid.NewGuid(), HttpContext.Current.Request.Url); using (Utils utility = new Utils()) { utility.MethodStart(id, System.Reflection.MethodBase.GetCurrentMethod()); } _bill_Sys_ProcedureCode_BO = new Bill_Sys_ProcedureCode_BO(); try { ArrayList arrObj = new ArrayList(); for (int i = 0; i < grdEmployerProcedure.Rows.Count; i++) { CheckBox chkDelete1 = (CheckBox)grdEmployerProcedure.Rows[i].FindControl("chkDelete"); if (chkDelete1.Checked) { //_bill_Sys_ProcedureCode_BO.Copy_EmployerProcedureCode(hdninsurancecode.Value, hdnToinsurancecode.Value, grdEmployerProcedure.DataKeys[i]["SZ_PROCEDURE_ID"].ToString()); EmployerCopyTo objEmployerCopyTo = new EmployerCopyTo(); objEmployerCopyTo.EmployerFrom = grdEmployerProcedure.DataKeys[i]["SZ_EMPLOYER_ID"].ToString(); objEmployerCopyTo.EmployerTO = hdnToinsurancecode.Value; objEmployerCopyTo.ProcedureCodeID = grdEmployerProcedure.DataKeys[i]["I_PROCEDURE_ID"].ToString(); objEmployerCopyTo.CompanyID = txtCompanyID.Text; arrObj.Add(objEmployerCopyTo); } } if (arrObj.Count == 0) { usrMessage.PutMessage("No Recored is Selected"); usrMessage.SetMessageType(UserControl_ErrorMessageControl.DisplayType.Type_ErrorMessage); usrMessage.Show(); return; } EmployerCopyTo objEmployerCopy = new EmployerCopyTo(); objEmployerCopy = objEmployerCopy.Copy_EmployerProcedureCode(arrObj); if (objEmployerCopy.SucessMsg != "Error") { grdEmployerProcedure.XGridBindSearch(); usrMessage.PutMessage("Procedure codes copied successfully ..."); usrMessage.SetMessageType(UserControl_ErrorMessageControl.DisplayType.Type_UserMessage); usrMessage.Show(); if (objEmployerCopy.DuplicateMsg != "") { ScriptManager.RegisterClientScriptBlock((Page)this, base.GetType(), "Done", "alert('" + objEmployerCopy.DuplicateMsg.ToString() + "');", true); } } else { usrMessage.PutMessage("unable to save procedure codes"); usrMessage.SetMessageType(UserControl_ErrorMessageControl.DisplayType.Type_ErrorMessage); usrMessage.Show(); } } catch (Exception ex) { Elmah.ErrorSignal.FromCurrentContext().Raise(ex); using (Utils utility = new Utils()) { utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod()); } string str2 = "Error Request=" + id + ".Please share with Technical support."; base.Response.Redirect("../Bill_Sys_ErrorPage.aspx?ErrMsg=" + str2); } //Method End using (Utils utility = new Utils()) { utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod()); } }
public EmployerCopyTo Copy_EmployerProcedureCode(ArrayList arrObj) { EmployerCopyTo objEmployerCopyTo = new EmployerCopyTo(); conn = new SqlConnection(strConn); string dupMsg = ""; conn.Open(); SqlTransaction sqlTrn; sqlTrn = conn.BeginTransaction(); try { for (int i = 0; i < arrObj.Count; i++) { EmployerCopyTo objEmployerCopy = (EmployerCopyTo)arrObj[i]; comm = new SqlCommand("SP_GET_COPY_EMPLOYER_PROCEDURE_CODES", conn); comm.CommandTimeout = Convert.ToInt32(ConfigurationManager.AppSettings["CommandTimeOut"].ToString()); comm.Transaction = sqlTrn; comm.CommandType = CommandType.StoredProcedure; comm.Parameters.AddWithValue("@SZ_FROM_EMPLOYER_ID", objEmployerCopy.EmployerFrom); comm.Parameters.AddWithValue("@SZ_TO_EMPLOYER_ID", objEmployerCopy.EmployerTO); comm.Parameters.AddWithValue("@SZ_PROCEDURE_ID", objEmployerCopy.ProcedureCodeID); comm.Parameters.AddWithValue("@SZ_COMPANY_ID", objEmployerCopy.CompanyID); SqlDataReader dr = comm.ExecuteReader(); while (dr.Read()) { if (dr[0].ToString().Contains("DUP-")) { if (dupMsg == "") { dupMsg = "Duplicate Code(s): " + dr[0].ToString(); } else { dupMsg = dupMsg + " ," + dr[0].ToString(); } } } dr.Close(); } sqlTrn.Commit(); objEmployerCopyTo.DuplicateMsg = dupMsg; objEmployerCopyTo.SucessMsg = "Procedure codes copied successfully ..."; } catch (Exception ex) { Elmah.ErrorSignal.FromCurrentContext().Raise(ex); sqlTrn.Rollback(); objEmployerCopyTo.SucessMsg = "Error"; }finally { if (conn.State == ConnectionState.Open) { conn.Close(); } } return(objEmployerCopyTo); }