public bool AddFromMobile(object data) { List <SqlParameter> parameterList = new List <SqlParameter>(); string procName = "sp_T_Planing_Action_AfterAppliedCoating_Insert_Mobile"; string TPID = ""; SqlConnection conn = null; SqlTransaction transaction = null; isCan = true; try { if (data != null) { conn = OpenConnection(); transaction = conn.BeginTransaction(); T_Planing_Action_AfterAppliedCoatingMobileDTO obj = (T_Planing_Action_AfterAppliedCoatingMobileDTO)data; command = new SqlCommand(procName, conn, transaction); command.CommandType = CommandType.StoredProcedure; parameterList.AddRange(GetParametersExactly(procName, obj, transaction).ToArray()); command.Parameters.AddRange(parameterList.ToArray()); command.ExecuteNonQuery(); TPID = obj.TPID; if (obj.DeleteFiles != null && obj.DeleteFiles.Length > 0) { procName = "sp_T_Planing_Action_AfterAppliedCoating_Files_Delete_Mobile"; foreach (var fileNo in obj.DeleteFiles.Split(',')) { if (fileNo != null && fileNo != "") { command = new SqlCommand(procName, conn, transaction); command.CommandType = CommandType.StoredProcedure; T_PlaningFileMobileDTO file = new T_PlaningFileMobileDTO(); file.TPID = TPID; file.No = fileNo; parameterList = new List <SqlParameter>(); parameterList.AddRange(GetParametersExactly(procName, file, transaction).ToArray()); command.Parameters.AddRange(parameterList.ToArray()); command.ExecuteNonQuery(); } } } procName = "sp_T_Planing_Action_AfterAppliedCoating_Files_Insert_Mobile"; if (obj.UploadFileList != null && obj.UploadFileList.Count > 0) { foreach (T_PlaningFileMobileDTO file in obj.UploadFileList) { file.TPID = TPID; command = new SqlCommand(procName, conn, transaction); command.CommandType = CommandType.StoredProcedure; if (file != null) { parameterList = new List <SqlParameter>(); parameterList.AddRange(GetParametersExactly(procName, file, transaction).ToArray()); command.Parameters.AddRange(parameterList.ToArray()); } command.ExecuteNonQuery(); } } procName = "sp_T_Planing_Action_AfterAppliedCoating_DryFilmThickness_Insert_Mobile"; if (obj.DryFilmThicknessList != null && obj.DryFilmThicknessList.Count > 0) { foreach (T_Planing_Action_AfterAppliedCoating_DryFilmMobileDTO dto in obj.DryFilmThicknessList) { dto.TPID = TPID; dto.ClockPosition1 = dto.ClockPosition1 == "" ? null : dto.ClockPosition1; dto.ClockPosition2 = dto.ClockPosition2 == "" ? null : dto.ClockPosition2; dto.ClockPosition3 = dto.ClockPosition3 == "" ? null : dto.ClockPosition3; dto.ClockPosition4 = dto.ClockPosition4 == "" ? null : dto.ClockPosition4; command = new SqlCommand(procName, conn, transaction); command.CommandType = CommandType.StoredProcedure; if (dto != null) { parameterList = new List <SqlParameter>(); parameterList.AddRange(GetParametersExactly(procName, dto, transaction).ToArray()); command.Parameters.AddRange(parameterList.ToArray()); } command.ExecuteNonQuery(); } } transaction.Commit(); } } catch (Exception ex) { isCan = false; if (transaction != null) { transaction.Rollback(); } throw new Exception(ex.Message); } finally { CloseConnection(); } return(isCan); }
public bool AddFromMobile(object data) { List <SqlParameter> parameterList = new List <SqlParameter>(); string procName = "sp_T_Planing_Action_SiteSurvey_Mobile_Insert"; string TPID = ""; SqlConnection conn = OpenConnection(); SqlTransaction transaction = conn.BeginTransaction(); isCan = true; try { T_Planing_Action_SiteSurveyMobileDTO obj = (T_Planing_Action_SiteSurveyMobileDTO)data; command = new SqlCommand(procName, conn, transaction); command.CommandType = CommandType.StoredProcedure; if (obj != null) { parameterList.AddRange(GetParametersExactly(procName, obj, transaction).ToArray()); command.Parameters.AddRange(parameterList.ToArray()); command.ExecuteNonQuery(); TPID = obj.TPID; if (obj.DeleteFiles != null && obj.DeleteFiles.Length > 0) { procName = "sp_T_Planing_Action_SiteSurvey_Files_Delete_Mobile"; foreach (var fileNo in obj.DeleteFiles.Split(',')) { if (fileNo != "") { command = new SqlCommand(procName, conn, transaction); command.CommandType = CommandType.StoredProcedure; if (fileNo != null) { T_PlaningFileMobileDTO file = new T_PlaningFileMobileDTO(); file.TPID = TPID; file.No = fileNo; parameterList = new List <SqlParameter>(); parameterList.AddRange(GetParametersExactly(procName, file, transaction).ToArray()); command.Parameters.AddRange(parameterList.ToArray()); // command.Parameters[0].Value = ""; } command.ExecuteNonQuery(); } } } procName = "sp_T_Planing_Action_SiteSurvey_Files_Insert_Mobile"; if (obj.UploadFileList != null && obj.UploadFileList.Count > 0) { foreach (T_PlaningFileMobileDTO file in obj.UploadFileList) { file.TPID = TPID; command = new SqlCommand(procName, conn, transaction); command.CommandType = CommandType.StoredProcedure; if (file != null) { parameterList = new List <SqlParameter>(); parameterList.AddRange(GetParametersExactly(procName, file, transaction).ToArray()); command.Parameters.AddRange(parameterList.ToArray()); // command.Parameters[0].Value = ""; } command.ExecuteNonQuery(); } } } transaction.Commit(); } catch (Exception ex) { isCan = false; transaction.Rollback(); throw new Exception(ex.Message); } finally { CloseConnection(); } return(isCan); }