private static bool handleSQLException(SqlException ex, MethodBase Method) { Logging.Logger("ERROR: MethodName=" + Method.Name + " Type: " + ex.GetType().Name + " #:" + ex.Number + " Message:" + ex.Message); switch (ex.Number) { case 18456: PromptUser("Error connecting to MUNIS Database. Your username may not have access.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, "MUNIS Error"); return(false); case 102: PromptUser("ERROR: MethodName=" + Method.Name + " Type: " + ex.GetType().Name + " #:" + ex.Number + " Message:" + ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, "ERROR"); return(false); case 121: PromptUser("Could not connect to MUNIS database.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, "Network Error"); return(false); case 245: return(false); case 248: PromptUser("ERROR: MethodName=" + Method.Name + " Type: " + ex.GetType().Name + " #:" + ex.Number + " Message:" + ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, "ERROR"); return(false); case 53: PromptUser("Could not connect to MUNIS database.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, "Network Error"); suppressAdditionalMessages = true; return(true); default: UnHandledError(ex, ex.Number, Method); return(false); } }
public static void WriteToLogFileSql(SqlException exp) { FileStream stream = null; StreamWriter writer = null; try { stream = File.Open(Application.StartupPath + @"\SqlException.log", FileMode.OpenOrCreate, FileAccess.Write, FileShare.None); stream.Seek(0L, SeekOrigin.End); writer = new StreamWriter(stream); writer.WriteLine(DateTime.Now.ToString() + ":\tException \t" + exp.GetType().ToString()); writer.WriteLine("ExceptionMessage :\t " + exp.Message); writer.WriteLine("ExceptionSource :\t" + exp.Source); writer.WriteLine("ExceptionStackTrace:\t " + exp.StackTrace); writer.WriteLine("ExceptionNum :\t" + exp.Number.ToString()); writer.WriteLine("\n"); } catch (Exception) { } finally { if (writer != null) { writer.Close(); } if (stream != null) { stream.Close(); } } }
public static ReturnValor mSqlException(Exception ex) { ReturnValor oReturn = new ReturnValor(); SqlException sqlex = (SqlException)ex; StringBuilder sb = new StringBuilder(); sb.AppendLine(sqlex.GetType().FullName); sb.AppendLine("Error Number: " + sqlex.Number.ToString()); sb.AppendLine("Source SQL: " + sqlex.Source); sb.AppendLine("Server: " + sqlex.Server); sb.AppendLine("Procedure: " + sqlex.Procedure); sb.AppendLine("LineNumber: " + sqlex.LineNumber.ToString()); sb.AppendLine(sqlex.Message.ToString()); if (TExcep == "USER") { //oReturn.Message = HelpMessages.ResourceManager.GetString(sqlex.Number.ToString()); //if (string.IsNullOrEmpty(oReturn.Message)) oReturn.Message = HelpMessages.GeneralAPP_MensajeErrorUser.ToString(); } else if (TExcep == "ADMIN") { oReturn.Message = sb.ToString(); } return(oReturn); }
public void Erreur_SqlException_Num18456_Bien_Traite() { SqlException ex = SqlExceptionHelper.GenerateMain(18456); GestionErreur.GerrerErreur(ex); msbs.Verify(mm => mm.ShowError(AxLanguage.Languages.REAplan_Erreur_Sql_Mdp)); log.Verify(ll => ll.Error(ex.GetType().Name + " | " + ex.Message + " |" + ex.StackTrace)); }
public void Erreur_SqlException_Num4060_Bien_Traite() { SqlException ex = SqlExceptionHelper.GenerateMain(4060); GestionErreur.GerrerErreur(ex); msbs.Verify(mm => mm.ShowError("Impossible d'ouvrir la base de données !")); log.Verify(ll => ll.Error(ex.GetType().Name + " | " + ex.Message + " |" + ex.StackTrace)); }
public void Erreur_SqlException_Autres_Num_Bien_Traite() { SqlException ex = SqlExceptionHelper.GenerateMain(5); GestionErreur.GerrerErreur(ex); msbs.Verify(mm => mm.ShowError("Erreur avec la base données !")); log.Verify(ll => ll.Error(ex.GetType().Name + " | " + ex.Message + " |" + ex.StackTrace)); }
private void graba_datos() { int rowSel = this.fg.RowSel; empresas empresas = new empresas(); this.cnn.Open(); SqlTransaction sqlTransaction = this.cnn.BeginTransaction(); SqlCommand command = this.cnn.CreateCommand(); command.Transaction = sqlTransaction; string str1 = Conversions.ToString(Microsoft.VisualBasic.CompilerServices.Operators.AddObject(this.fg[rowSel, 1], this.fg[rowSel, 2])); if (str1.Length > 0) { str1 = Strings.Mid(str1, 1, 30); } try { string str2 = Conversions.ToString(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject((object)"UPDATE UPC SET T1 ='", this.upc[1, 1]), (object)"', T2 = '"), this.upc[1, 2]), (object)"', T3 ='"), this.upc[1, 3]), (object)"', T4 ='"), this.upc[1, 4]), (object)"', T5 ='"), this.upc[1, 5]), (object)"', T6 = '"), this.upc[1, 6]), (object)"', T7 ='"), this.upc[1, 7]), (object)"', T8 ='"), this.upc[1, 8]), (object)"', T9 ='"), this.upc[1, 9]), (object)"', T0 = '"), this.upc[1, 10]), (object)"' "), (object)" WHERE CLIENTE = '"), (object)this.cliente.Text), (object)"' AND ESTILO = '"), this.fg[rowSel, 1]), (object)"' AND COLOR = '"), this.fg[rowSel, 2]), (object)"'")); command.CommandText = str2; if (command.ExecuteNonQuery() == 0) { string str3 = Conversions.ToString(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject((object)("INSERT INTO UPC (CLIENTE,ESTILO,COLOR,MATERIAL,ESCALA,T1,T2,T3,T4,T5,T6,T7,T8,T9,T0,USUARIO,FECHA) VALUES ('" + this.cliente.Text + "','"), this.fg[rowSel, 1]), (object)"','"), this.fg[rowSel, 2]), (object)"','"), (object)str1), (object)"','"), this.fg[rowSel, 3]), (object)"','"), this.upc[1, 1]), (object)"','"), this.upc[1, 2]), (object)"','"), this.upc[1, 3]), (object)"','"), this.upc[1, 4]), (object)"','"), this.upc[1, 5]), (object)"','"), this.upc[1, 6]), (object)"','"), this.upc[1, 7]), (object)"','"), this.upc[1, 8]), (object)"','"), this.upc[1, 9]), (object)"','"), this.upc[1, 10]), (object)"','"), (object)empresas.usuario), (object)"',GETDATE() )")); command.CommandText = str3; command.ExecuteNonQuery(); } sqlTransaction.Commit(); int num = (int)Interaction.MsgBox((object)"Actualización Exitosa.", MsgBoxStyle.Exclamation, (object)"Datos Actualizados."); } catch (Exception ex1) { ProjectData.SetProjectError(ex1); try { int num = (int)Interaction.MsgBox((object)"Inconsistencia en Datos", MsgBoxStyle.Critical, (object)"Por favor revise !!!!"); sqlTransaction.Rollback(); } catch (SqlException ex2) { ProjectData.SetProjectError((Exception)ex2); SqlException sqlException = ex2; if (sqlTransaction.Connection != null) { Console.WriteLine("Ocurrió un error de tipo " + sqlException.GetType().ToString() + " se generó cuando se trato de eliminar la transacción."); } ProjectData.ClearProjectError(); } ProjectData.ClearProjectError(); } finally { this.cnn.Close(); } }
/// <summary> /// Format exception /// </summary> /// <param name="exception"></param> /// <returns></returns> static public string Format(System.Exception exception) { string tmp = string.Empty; StringBuilder msg = null; DateTime dateTime = DateTime.Now; try { msg = new StringBuilder(); msg.AppendLine(); msg.AppendLine("==============[System Error Tracing]=============="); msg.AppendLine("[CallStackTrace]"); msg.AppendLine(exception.StackTrace); //msg에 현재 트래이싱된 시간을 담도록 한다. msg.AppendLine("\r\n[DateTime] : " + dateTime.ToString("yyyy-MM-dd HH:mm:ss")); //만약 Sql관련 Exception이면 추가항목을 넣어주도록 한다. if (exception.GetType() == typeof(System.Data.SqlClient.SqlException)) { SqlException sqlErr = (SqlException)exception; msg.Append("\r\n[SqlException] "); msg.Append("\r\nException Type: ").Append(sqlErr.GetType()); msg.Append("\r\nErrors: ").Append(sqlErr.Errors); msg.Append("\r\nClass: ").Append(sqlErr.Class); msg.Append("\r\nLineNumber: ").Append(sqlErr.LineNumber); msg.Append("\r\nMessage: ").Append("{" + sqlErr.Message + "}"); msg.Append("\r\nNumber: ").Append(sqlErr.Number); msg.Append("\r\nProcedure: ").Append(sqlErr.Procedure); msg.Append("\r\nServer: ").Append(sqlErr.Server); msg.Append("\r\nState: ").Append(sqlErr.State); msg.Append("\r\nSource: ").Append(sqlErr.Source); } //Sql관련Exception외에 작업들.. else { msg.Append("\r\n[Exception] "); msg.Append("\r\n" + "DetailMsg: {" + exception.Message + "}"); } } catch { //throw ex; } return(msg.ToString()); }
/// <summary> /// Given the error, this will attempt to format it and save it into the database. /// </summary> /// <param name="pvSQLException">The actual exception that happened.</param> /// <param name="pvsLocation">The location of the error.</param> /// <param name="pvsCmd">The SQL Command that was run.</param> /// <param name="pvsAddInfo">Any additional info you want displayed.</param> public void ProcessError(SqlException pvSQLException, string pvsLocation, SqlCommand pvsCmd, string pvsAddInfo, string sSessionID) { // First make the error string. We will always do this. string lsErrorText = ""; string lsErrorType = pvSQLException.GetType().ToString(); ErrorRoutines lobjRoutines = new ErrorRoutines(); lsErrorText = lobjRoutines.FormatError(lsErrorType, pvSQLException, pvsLocation); string lsSQLCmd = lobjRoutines.FormatSQLCmd(pvsCmd); if ((!String.IsNullOrEmpty(pvsAddInfo)) && (pvsAddInfo != "")) { lsSQLCmd += "<br>" + pvsAddInfo.Replace(Environment.NewLine, "<BR>"); } HandleError(lsErrorType, lsErrorText, pvsLocation, pvSQLException.StackTrace, lsSQLCmd, sSessionID); }
private void elimina() { empresas empresas = new empresas(); Strings.Format((object)DateAndTime.Now, "yyyy-MM-dd hh:mm:ss"); this.cnn.Open(); SqlTransaction sqlTransaction = this.cnn.BeginTransaction(); SqlCommand command = this.cnn.CreateCommand(); command.Transaction = sqlTransaction; try { string str = "DELETE UPC WHERE CLIENTE = '" + this.cliente + "' AND ESTILO = '" + this.estil.Text + "' AND COLOR = '" + this.colo.Text + "'"; command.CommandText = str; command.ExecuteNonQuery(); sqlTransaction.Commit(); this.ec[this.ec.RowSel, 5] = (object)""; } catch (Exception ex1) { ProjectData.SetProjectError(ex1); try { sqlTransaction.Rollback(); } catch (SqlException ex2) { ProjectData.SetProjectError((Exception)ex2); SqlException sqlException = ex2; if (sqlTransaction.Connection != null) { Console.WriteLine("Ocurrió un error de tipo " + sqlException.GetType().ToString() + " se generó cuando se trato de eliminar la transacción."); } ProjectData.ClearProjectError(); } ProjectData.ClearProjectError(); } finally { this.cnn.Close(); } }
private static SqlMessage SqlException(SqlException ex) { SqlMessage meResul = new SqlMessage { Status = sqlMessagerType.SystemError, Title = ex.GetType().FullName, Message = ex.Message, ExceptionMesseger = ex.ToString() }; //ex.GetHashCode(); switch (ex.Number) { case 4060: // Database không hợp lệ meResul.Message = "Database không tồn tại, vui lòng kiểm tra hoặc liên hệ với admin !"; break; case 18456: // không Đăng nhập sql meResul.Message = "không Đăng nhập sql, vui lòng kiểm tra lại server sql trước khi chạy"; break; case 547: // Ràng buộc khóa ngoại meResul.Message = "Ràng buộc khóa ngoại, vui lòng kiểm tra lại !"; break; case 2627: // trùng khóa chính meResul.Message = "Trùng khóa chính , vui lòng kiểm tra lại khóa chính"; break; case 2601: // Unique Index/Constriant Violation meResul.Message = "Unique Index/Constriant Violation"; break; case 50000: meResul.Message = "Vui lòng kiểm tra lại dữ liệu trước khi lưu"; break; default: break; } return(meResul); }
public ClassErrors(Exception Error, SqlException sqlError) { StackTrace st = null; string ExName = null; if (sqlError == null) { st = new StackTrace(Error, true); ExName = Error.GetType().Name; } else { st = new StackTrace(sqlError, true); ExName = sqlError.GetType().Name; } StackFrame[] Frames = null; Frames = st.GetFrames(); _sTrace = st.ToString(); string[] strFrames = new string[st.FrameCount]; string[] SplitFrames = null; for (int intFrCntr = 0; intFrCntr < st.FrameCount; intFrCntr += 1) { strFrames[intFrCntr] = Frames[intFrCntr].ToString(); SplitFrames = strFrames[intFrCntr].Split(':'); if (_rNumber == 0) { _rNumber = Convert.ToInt32(SplitFrames[SplitFrames.Length - 2]); _cNumber = Convert.ToInt32(SplitFrames[SplitFrames.Length - 1]); } } }
private void graba_datos() { string str1 = ""; empresas empresas = new empresas(); if (Microsoft.VisualBasic.CompilerServices.Operators.CompareString(empresas.numero, "1", false) == 0) { str1 = "JTF"; } else if (Microsoft.VisualBasic.CompilerServices.Operators.CompareString(empresas.numero, "3", false) == 0) { str1 = "ZUF"; } string str2 = Strings.Format((object)DateAndTime.Today, "yyyy-MM-dd"); int[] numArray1 = new int[10]; int[] numArray2 = new int[10]; this.cnn.Open(); SqlTransaction sqlTransaction = this.cnn.BeginTransaction(); SqlCommand command = this.cnn.CreateCommand(); command.Transaction = sqlTransaction; try { string str3 = "INSERT INTO CAJAS06 (CORTE,FECHA,PRENDAS) VALUES ( '" + this.corte.Text + "','" + str2 + "','" + this.tprod.Text + "')"; command.CommandText = str3; command.ExecuteNonQuery(); sqlTransaction.Commit(); int num = (int)Interaction.MsgBox((object)"Grabacion Exitosa", MsgBoxStyle.Exclamation, (object)"Grabaciones"); } catch (Exception ex1) { ProjectData.SetProjectError(ex1); try { int num = (int)Interaction.MsgBox((object)"Inconsistencia en Datos", MsgBoxStyle.Critical, (object)"Por favor revise !!!!"); sqlTransaction.Rollback(); } catch (SqlException ex2) { ProjectData.SetProjectError((Exception)ex2); SqlException sqlException = ex2; if (sqlTransaction.Connection != null) { int num = (int)Interaction.MsgBox((object)("Ocurrió un error de tipo " + sqlException.GetType().ToString() + " se generó cuando se trato de eliminar la transacción."), MsgBoxStyle.Critical, (object)"Error"); } ProjectData.ClearProjectError(); } ProjectData.ClearProjectError(); } finally { this.cnn.Close(); } }
private void graba_datos() { string str1 = ""; empresas empresas = new empresas(); if (Microsoft.VisualBasic.CompilerServices.Operators.CompareString(empresas.numero, "1", false) == 0) { str1 = "JTF"; } else if (Microsoft.VisualBasic.CompilerServices.Operators.CompareString(empresas.numero, "3", false) == 0) { str1 = "ZUF"; } string str2 = Strings.Format((object)DateAndTime.Today, "yyyy-MM-dd"); int[] numArray1 = new int[10]; int[] numArray2 = new int[10]; string str3 = "Vales"; this.cnn.Open(); SqlTransaction sqlTransaction = this.cnn.BeginTransaction(); SqlCommand command = this.cnn.CreateCommand(); command.Transaction = sqlTransaction; try { int num1 = checked (this.pr.Rows.Count - 2); int index1 = 1; int num2; while (index1 <= num1) { string str4 = Conversions.ToString(this.pr[index1, 1]); if (!str3.Contains(str4)) { int index2 = 2; do { if (Microsoft.VisualBasic.CompilerServices.Operators.ConditionalCompareObjectGreater(this.pr[index1, index2], (object)0, false)) { string str5 = Conversions.ToString(this.pr[0, index2]); string str6 = Conversions.ToString(this.pr[index1, 0]); string str7 = "INSERT INTO PROD_DIARIA (CORTE,FECHA,TIPO,TALLA,PRENDAS) VALUES ( '" + this.corte.Text + "','" + str2 + "','" + str6 + "','" + str5 + "'," + Conversions.ToString(Conversions.ToInteger(this.pr[index1, index2])) + ")"; command.CommandText = str7; num2 = command.ExecuteNonQuery(); string str8; if (Conversions.ToDouble(str6) == 0.0) { numArray1[checked (index2 - 2)] = Conversions.ToInteger(this.pr[index1, index2]); str8 = "P" + Conversions.ToString(checked (index2 - 2)); } else { numArray2[checked (index2 - 2)] = Conversions.ToInteger(this.pr[index1, index2]); str8 = "S" + Conversions.ToString(checked (index2 - 2)); } string str9 = Conversions.ToString(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject((object)("UPDATE CORTES_P SET " + str8 + " = " + str8 + " + "), this.pr[index1, index2]), (object)" WHERE CORTE = '"), (object)this.corte.Text), (object)"'")); command.CommandText = str9; if (command.ExecuteNonQuery() == 0) { string str10 = "INSERT INTO CORTES_P (CORTE,P0,P1,P2,P3,P4,P5,P6,P7,P8,P9,S0,S1,S2,S3,S4,S5,S6,S7,S8,S9) VALUES ( '" + this.corte.Text + "','" + Conversions.ToString(numArray1[0]) + "','" + Conversions.ToString(numArray1[1]) + "','" + Conversions.ToString(numArray1[2]) + "','" + Conversions.ToString(numArray1[3]) + "','" + Conversions.ToString(numArray1[4]) + "','" + Conversions.ToString(numArray1[5]) + "','" + Conversions.ToString(numArray1[6]) + "','" + Conversions.ToString(numArray1[7]) + "','" + Conversions.ToString(numArray1[8]) + "','" + Conversions.ToString(numArray1[9]) + "','" + Conversions.ToString(numArray2[0]) + "','" + Conversions.ToString(numArray2[1]) + "','" + Conversions.ToString(numArray2[2]) + "','" + Conversions.ToString(numArray2[3]) + "','" + Conversions.ToString(numArray2[4]) + "','" + Conversions.ToString(numArray2[5]) + "','" + Conversions.ToString(numArray2[6]) + "','" + Conversions.ToString(numArray2[7]) + "','" + Conversions.ToString(numArray2[8]) + "','" + Conversions.ToString(numArray2[9]) + "')"; command.CommandText = str10; num2 = command.ExecuteNonQuery(); } string str11 = "UPDATE CORTES SET FPROD = '" + str2 + "' WHERE CORTE = '" + this.corte.Text + "'"; command.CommandText = str11; num2 = command.ExecuteNonQuery(); } checked { ++index2; } }while (index2 <= 11); } checked { ++index1; } } string str12 = "UPDATE CAJAS01 SET ESTADO = 'T' WHERE CORTE = '" + this.corte.Text + "'"; command.CommandText = str12; num2 = command.ExecuteNonQuery(); string Style = "0000000"; string str13 = "SELECT CORRELATIVO FROM PROD_TER03 WHERE TIPO = 'ENTRADAS'"; command.CommandText = str13; string str14 = Strings.Format((object)checked ((int)Math.Round(unchecked (Conversions.ToDouble(RuntimeHelpers.GetObjectValue(command.ExecuteScalar()).ToString()) + 1.0))), Style); string str15 = "UPDATE PROD_TER03 SET CORRELATIVO = CORRELATIVO + 1 WHERE TIPO = 'ENTRADAS'"; command.CommandText = str15; num2 = command.ExecuteNonQuery(); try { foreach (DataRow row in this.pp.Rows) { if (Microsoft.VisualBasic.CompilerServices.Operators.ConditionalCompareObjectNotEqual(row["TIPO_SEG"], (object)12, false)) { string str4 = Conversions.ToString(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject((object)"INSERT INTO PROD_TER01 (CAJA,CORTE,TALLA,TIPO,UBICACION,UNIDADES_I,UNIDADES,FECHA,ESTADO,USUARIO,CLIENTE,ESCALA,ORDEN) VALUES ('", row["CAJA"]), (object)"','"), row["CORTE"]), (object)"','"), row["TALLA"]), (object)"','"), row["TIPO"]), (object)"','00','"), row["UNIDADES"]), (object)"','"), row["UNIDADES"]), (object)"',GETDATE(),'A','"), (object)empresas.usuario), (object)"','"), row["CLIENTE"]), (object)"','"), row["ESCALA"]), (object)"','"), row["ORDEN"]), (object)"')")); command.CommandText = str4; num2 = command.ExecuteNonQuery(); string str5 = Conversions.ToString(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject((object)("INSERT INTO PROD_TER02 (TIPO_MOVTO,NO_DOCTO,CAJA,CORTE,TALLA,TIPO,DESCRIPCION,FECHA,UNIDADES,USUARIO) VALUES ('E','" + str14 + "','"), row["CAJA"]), (object)"','"), row["CORTE"]), (object)"','"), row["TALLA"]), (object)"','"), row["TIPO"]), (object)"','"), (object)"INGRESOS POR PRODUCCION',GETDATE(),'"), row["UNIDADES"]), (object)"','"), (object)empresas.usuario), (object)"')")); command.CommandText = str5; num2 = command.ExecuteNonQuery(); } } } finally { IEnumerator enumerator; if (enumerator is IDisposable) { (enumerator as IDisposable).Dispose(); } } sqlTransaction.Commit(); int num3 = (int)Interaction.MsgBox((object)"Grabacion Exitosa", MsgBoxStyle.Exclamation, (object)"Grabaciones"); } catch (Exception ex1) { ProjectData.SetProjectError(ex1); try { int num = (int)Interaction.MsgBox((object)"Inconsistencia en Datos", MsgBoxStyle.Critical, (object)"Por favor revise !!!!"); sqlTransaction.Rollback(); } catch (SqlException ex2) { ProjectData.SetProjectError((Exception)ex2); SqlException sqlException = ex2; if (sqlTransaction.Connection != null) { int num = (int)Interaction.MsgBox((object)("Ocurrió un error de tipo " + sqlException.GetType().ToString() + " se generó cuando se trato de eliminar la transacción."), MsgBoxStyle.Critical, (object)"Error"); } ProjectData.ClearProjectError(); } ProjectData.ClearProjectError(); } finally { this.cnn.Close(); } }
private void graba_datos() { string str1 = ""; empresas empresas = new empresas(); string Style = "0000000"; if (Microsoft.VisualBasic.CompilerServices.Operators.CompareString(empresas.numero, "1", false) == 0) { str1 = "JTF"; } else if (Microsoft.VisualBasic.CompilerServices.Operators.CompareString(empresas.numero, "3", false) == 0) { str1 = "ZUF"; } this.cnn.Open(); SqlTransaction sqlTransaction = this.cnn.BeginTransaction(); SqlCommand command = this.cnn.CreateCommand(); command.Transaction = sqlTransaction; try { string str2 = "SELECT CORRELATIVO FROM CAJAS02"; command.CommandText = str2; int integer = Conversions.ToInteger(RuntimeHelpers.GetObjectValue(command.ExecuteScalar()).ToString()); this.inicial = str1 + Strings.Format((object)checked (integer + 1), Style); int num1 = checked (this.fg.Rows.Count - 1); int index = 1; while (index <= num1) { string str3 = Conversions.ToString(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject((object)("INSERT INTO CAJAS01 (CAJA,CORTE,TALLA,TIPO,UNIDADES,CLIENTE,UBICACION,FECHA,ESTADO,ESCALA,ORDEN,IMPRESO,TIPO_SEG,SECCION) VALUES ('" + str1 + Strings.Format(Microsoft.VisualBasic.CompilerServices.Operators.AddObject((object)integer, this.fg[index, 1]), Style) + "','" + this.CORTE.Text + "','"), this.fg[index, 6]), (object)"','P','"), this.fg[index, 7]), (object)"','"), this.fg[index, 5]), (object)"','00',GETDATE(),'A','"), (object)this.escala), (object)"','"), this.fg[index, 8]), (object)"','"), (object)empresas.usuario), (object)"','0','"), (object)this.seccion), (object)"')")); command.CommandText = str3; int num2 = command.ExecuteNonQuery(); string str4 = "UPDATE CAJAS02 SET CORRELATIVO = CORRELATIVO + 1"; command.CommandText = str4; num2 = command.ExecuteNonQuery(); this.final = str1 + Strings.Format((object)checked (integer + index), Style); checked { ++index; } } sqlTransaction.Commit(); int num3 = (int)Interaction.MsgBox((object)"Grabacion Exitosa", MsgBoxStyle.Exclamation, (object)"Grabaciones"); } catch (Exception ex1) { ProjectData.SetProjectError(ex1); try { int num = (int)Interaction.MsgBox((object)"Inconsistencia en Datos", MsgBoxStyle.Critical, (object)"Por favor revise !!!!"); sqlTransaction.Rollback(); } catch (SqlException ex2) { ProjectData.SetProjectError((Exception)ex2); SqlException sqlException = ex2; if (sqlTransaction.Connection != null) { int num = (int)Interaction.MsgBox((object)("Ocurrió un error de tipo " + sqlException.GetType().ToString() + " se generó cuando se trato de eliminar la transacción."), MsgBoxStyle.Critical, (object)"Error"); } ProjectData.ClearProjectError(); } ProjectData.ClearProjectError(); } finally { this.cnn.Close(); } }
public static void SendSQLErrorToMail(SqlException ex, SqlError exmail, string filename) { try { var configuration = ConfigurationHelper.GetConfiguration(Directory.GetCurrentDirectory()); string server = configuration.GetSection("Smtp")["ServerName"]; string mailerror = configuration.GetSection("SendMail")["MailError"]; string mailit = configuration.GetSection("SendMail")["MailIt"]; string exceptionmailsubject = configuration.GetSection("SendMail")["ExceptionMailSubject"]; //split liste des personnes à prévenir String[] substrings = mailerror.Split(";"); string ErrorlineNo = exmail.LineNumber.ToString(); string Errormsg = exmail.GetType().Name.ToString(); string extype = exmail.GetType().ToString(); string sp = exmail.Procedure.ToString(); string ErrorLocation = exmail.Message.ToString(); using (var message = new MailMessage()) { message.Subject = "ErrorMVCCoreSql"; message.Body = $"<h1>Error: {ex.Message.Replace(Environment.NewLine, "<br />")}</h1>{ex.Source.Replace(Environment.NewLine, "<br />")}<hr />"; message.Body += $"<b>Date: " + DateTime.Now.ToString() + "</b><br />"; message.Body += $"CurrentCulture.DisplayName: {CultureInfo.CurrentCulture.DisplayName}<hr />"; //////////////////////////ATTENTION CECI NE FONCTIONNE PAS SUR IIS/////////////////////// //message.Body += $"Server IIS: {System.Security.Principal.WindowsIdentity.GetCurrent().Name} <br /> "; //////////////////////////ATTENTION CECI NE FONCTIONNE PAS SUR IIS/////////////////////// message.Body += $"Server SQL: {ex.Server }<hr />"; message.Body += $"File: {filename}<br />"; message.Body += $"Procedure: {sp}<br />"; message.Body += $"Line: {ErrorlineNo}<br />"; message.Body += $"ErrorMessage: {Errormsg}<br />"; message.Body += $"Exception Type: {extype}<br />"; message.Body += $"Error Details: {ErrorLocation}<br />"; message.Body += $"Error Page Url: <hr />"; //message.Body += $"Path: {request.Path}<br />"; //message.Body += $"QueryString: {request.QueryString}<br />"; //message.Body += $"RawTarget: {request.RawTarget}<br />"; //message.Body += $"Protocol: {request.Protocol}<br />"; //message.Body += $"StatusCode: {context.Response.StatusCode}<hr />"; //message.Body += $"User Identity: {context.User.Identity.Name}<br />"; //message.Body += $"Host: {context.Request.Host}<br />"; //message.Body += $"Method: {context.Request.Method}<hr />"; message.Body += $"<b>Error:</b><br />"; message.Body += $"HelpLink: {ex.HelpLink }<br />"; message.Body += $"Type: {ex.GetType() }<br />"; message.Body += $"Values: {ex.Data.Values}<br />"; message.Body += $"TargetSite : {ex.TargetSite }<hr />"; //message.Body += $"Referer: {context.Request.Headers["Referer"]}<hr />"; //message.Body += $"User-Agent: {context.Request.Headers["User-Agent"]}<br />"; //message.Body += $"IP Address: {httpConnectionFeature?.LocalIpAddress}<br />"; if (ex.StackTrace != null) { message.Body += $"<b>Stack Trace</b><br />{ex.StackTrace.Replace(Environment.NewLine, "<br />")}"; } if (ex.InnerException != null) { message.Body += $"<hr /><b>Inner Exception</b><br />{ex.InnerException?.Message.Replace(Environment.NewLine, "<br />")}<hr />"; } message.IsBodyHtml = true; foreach (var substring in substrings) { message.To.Add(new MailAddress(substring)); } message.From = new MailAddress(mailit, exceptionmailsubject); using (var smtpClient = new SmtpClient(server)) { smtpClient.Send(message); } } } catch (Exception em) { em.ToString(); } }
private void graba_datos() { int[] numArray = new int[10]; this.cnn.Open(); SqlTransaction sqlTransaction = this.cnn.BeginTransaction(); SqlCommand command = this.cnn.CreateCommand(); command.Transaction = sqlTransaction; try { int num1 = checked (this.fg.Rows.Count - 1); int index1 = 1; while (index1 <= num1) { int index2 = 0; do { numArray[index2] = Conversions.ToInteger(this.fg[index1, checked (index2 + 2)]); checked { ++index2; } }while (index2 <= 9); string str1 = Conversions.ToString(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject((object)("UPDATE CAJAS19 SET T1 = '" + Conversions.ToString(numArray[0]) + "', T2 = '" + Conversions.ToString(numArray[1]) + "', T3 = '" + Conversions.ToString(numArray[2]) + "', T4 = '" + Conversions.ToString(numArray[3]) + "', T5 = '" + Conversions.ToString(numArray[4]) + "', T6 = '" + Conversions.ToString(numArray[5]) + "', T7 = '" + Conversions.ToString(numArray[6]) + "', T8 = '" + Conversions.ToString(numArray[7]) + "', T9 = '" + Conversions.ToString(numArray[8]) + "', T0 = '" + Conversions.ToString(numArray[9]) + "' WHERE ESTILO = '"), this.fg[index1, 1]), (object)"'")); command.CommandText = str1; if (command.ExecuteNonQuery() == 0) { string str2 = Conversions.ToString(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject((object)"INSERT INTO CAJAS19 (ESTILO,T1,T2,T3,T4,T5,T6,T7,T8,T9,T0) VALUES ('", this.fg[index1, 1]), (object)"','"), (object)numArray[0]), (object)"','"), (object)numArray[1]), (object)"','"), (object)numArray[2]), (object)"','"), (object)numArray[3]), (object)"','"), (object)numArray[4]), (object)"','"), (object)numArray[5]), (object)"','"), (object)numArray[6]), (object)"','"), (object)numArray[7]), (object)"','"), (object)numArray[8]), (object)"','"), (object)numArray[9]), (object)"')")); command.CommandText = str2; command.ExecuteNonQuery(); } checked { ++index1; } } sqlTransaction.Commit(); int num2 = (int)Interaction.MsgBox((object)"Grabación Exitosa.", MsgBoxStyle.Information, (object)"Proceso Completo."); } catch (Exception ex1) { ProjectData.SetProjectError(ex1); try { int num = (int)Interaction.MsgBox((object)"Inconsistencia en Datos", MsgBoxStyle.Critical, (object)"Por favor revise !!!!"); sqlTransaction.Rollback(); } catch (SqlException ex2) { ProjectData.SetProjectError((Exception)ex2); SqlException sqlException = ex2; if (sqlTransaction.Connection != null) { int num = (int)Interaction.MsgBox((object)("Ocurrió un error de tipo " + sqlException.GetType().ToString() + " se generó cuando se trato de eliminar la transacción."), MsgBoxStyle.Critical, (object)"Error"); } ProjectData.ClearProjectError(); } ProjectData.ClearProjectError(); } finally { this.cnn.Close(); } }
private void elimina_datos() { int rowSel = this.fg.RowSel; string str1 = Conversions.ToString(this.fg[rowSel, 1]); Conversions.ToString(this.fg[rowSel, 2]); this.cnn.Open(); SqlTransaction sqlTransaction = this.cnn.BeginTransaction(); SqlCommand command = this.cnn.CreateCommand(); command.Transaction = sqlTransaction; try { string str2 = "DELETE CAJAS19 WHERE ESTILO = '" + str1 + "'"; command.CommandText = str2; command.ExecuteNonQuery(); sqlTransaction.Commit(); } catch (Exception ex1) { ProjectData.SetProjectError(ex1); try { int num = (int)Interaction.MsgBox((object)"Inconsistencia en Datos", MsgBoxStyle.Critical, (object)"Por favor revise !!!!"); sqlTransaction.Rollback(); } catch (SqlException ex2) { ProjectData.SetProjectError((Exception)ex2); SqlException sqlException = ex2; if (sqlTransaction.Connection != null) { int num = (int)Interaction.MsgBox((object)("Ocurrió un error de tipo " + sqlException.GetType().ToString() + " se generó cuando se trato de eliminar la transacción."), MsgBoxStyle.Critical, (object)"Error"); } ProjectData.ClearProjectError(); } ProjectData.ClearProjectError(); } finally { this.cnn.Close(); } }
private void graba_datos() { empresas empresas = new empresas(); string caja = ""; SqlConnection cnn = new SqlConnection(); cnn.ConnectionString = this.cnn.ConnectionString; this.cnn.Open(); SqlTransaction sqlTransaction = this.cnn.BeginTransaction(); SqlCommand command = this.cnn.CreateCommand(); command.Transaction = sqlTransaction; try { int num1 = checked (this.fg.Rows.Count - 1); int index = 1; while (index <= num1) { this.o.crea_cajas((object)empresas, cnn, ref caja); string str = Conversions.ToString(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject((object)("INSERT INTO CAJAS01 (CAJA,CORTE,TALLA,TIPO,UNIDADES,CLIENTE,UBICACION,FECHA,ESTADO,ESCALA,ORDEN,IMPRESO,TIPO_SEG,SECCION) VALUES ('" + caja + "','" + this.CORTE.Text + "','"), this.fg[index, 6]), (object)"','P','"), this.fg[index, 7]), (object)"','"), this.fg[index, 5]), (object)"','00',GETDATE(),'A','"), (object)this.escala), (object)"','"), this.fg[index, 8]), (object)"','"), (object)empresas.usuario), (object)"','0','"), (object)this.seccion), (object)"')")); command.CommandText = str; command.ExecuteNonQuery(); if (index == 1) { this.inicial = caja; } this.final = caja; checked { ++index; } } sqlTransaction.Commit(); int num2 = (int)Interaction.MsgBox((object)"Grabacion Exitosa", MsgBoxStyle.Exclamation, (object)"Grabaciones"); } catch (Exception ex1) { ProjectData.SetProjectError(ex1); try { int num = (int)Interaction.MsgBox((object)"Inconsistencia en Datos", MsgBoxStyle.Critical, (object)"Por favor revise !!!!"); sqlTransaction.Rollback(); } catch (SqlException ex2) { ProjectData.SetProjectError((Exception)ex2); SqlException sqlException = ex2; if (sqlTransaction.Connection != null) { int num = (int)Interaction.MsgBox((object)("Ocurrió un error de tipo " + sqlException.GetType().ToString() + " se generó cuando se trato de eliminar la transacción."), MsgBoxStyle.Critical, (object)"Error"); } ProjectData.ClearProjectError(); } ProjectData.ClearProjectError(); } finally { this.cnn.Close(); } }
private void Graba_datos(DataTable dt, ref bool ok) { int num1 = 0; empresas empresas = new empresas(); ok = false; this.cnn.Open(); SqlTransaction sqlTransaction = this.cnn.BeginTransaction(); SqlCommand command = this.cnn.CreateCommand(); command.Transaction = sqlTransaction; try { try { foreach (DataRow row in dt.Rows) { try { string str = Conversions.ToString(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject((object)"INSERT INTO CAJAS04 (CAJA,CORTE,TALLA,TIPO,UNIDADES,FECHA ,QUIEN) VALUES ( '", row["CAJA"]), (object)"','"), row["CORTE"]), (object)"','"), row["TALLA"]), (object)"','"), row["TIPO"]), (object)"','"), row["UNIDADES"]), (object)"',GETDATE(),'OPERADOR')")); command.CommandText = str; checked { num1 += command.ExecuteNonQuery(); } ok = true; } catch (Exception ex) { ProjectData.SetProjectError(ex); ProjectData.ClearProjectError(); } } } finally { IEnumerator enumerator; if (enumerator is IDisposable) { (enumerator as IDisposable).Dispose(); } } if (num1 > 0) { string str = "UPDATE CAJAS01 SET ESTADO = 'P' WHERE CAJA = '" + this.caja.Text + "'"; command.CommandText = str; command.ExecuteNonQuery(); } sqlTransaction.Commit(); } catch (Exception ex1) { ProjectData.SetProjectError(ex1); try { int num2 = (int)Interaction.MsgBox((object)"Inconsistencia en Datos", MsgBoxStyle.Critical, (object)"Por favor revise !!!!"); sqlTransaction.Rollback(); } catch (SqlException ex2) { ProjectData.SetProjectError((Exception)ex2); SqlException sqlException = ex2; if (sqlTransaction.Connection != null) { int num2 = (int)Interaction.MsgBox((object)("Ocurrió un error de tipo " + sqlException.GetType().ToString() + " se generó cuando se trato de eliminar la transacción."), MsgBoxStyle.Critical, (object)"Error"); } ProjectData.ClearProjectError(); } ProjectData.ClearProjectError(); } finally { this.cnn.Close(); } }
/// <summary> /// Create a DataSet contains 1 DataRow of TraceInfo /// Compress this dataset to binary and convert to Base64 string /// </summary> /// <param name="exception"></param> /// <returns></returns> static public string Format(System.Exception exception) { string tmp = string.Empty; StringBuilder msg = null; StackTrace st1 = null; StackTrace st2 = null; StackFrame sf = null; DateTime dateTime = DateTime.Now; try { msg = new StringBuilder(); st1 = new StackTrace(1, true); msg.AppendLine(); msg.AppendLine("==============[System Error Tracing]=============="); msg.AppendLine("[CallStackTrace]"); for (int i = 0; i < st1.FrameCount; i++) { sf = st1.GetFrame(i); tmp = sf.GetMethod().DeclaringType.FullName + "." + sf.GetMethod().Name; if (tmp.IndexOf("System") != 0 && tmp.IndexOf("Microsoft") != 0) { msg.Append(tmp); msg.Append(" : (" + sf.GetFileLineNumber() + ")"); msg.Append("\r\n"); } } //Exception을 트래이싱하는부분 st2 = new StackTrace(exception, true); msg.AppendLine("[ErrStackTrace]"); for (int i = 0; i < st2.FrameCount; i++) { sf = st2.GetFrame(i); tmp = sf.GetMethod().DeclaringType.FullName + "." + sf.GetMethod().Name; if (tmp.IndexOf("System") != 0 && tmp.IndexOf("Microsoft") != 0) { msg.Append(tmp); msg.Append(" : (" + sf.GetFileLineNumber() + ")"); msg.Append("\r\n"); } } //msg에 현재 트래이싱된 시간을 담도록 한다. msg.Append("\r\n[DateTime] : " + dateTime.ToString("yyyy-MM-dd HH:mm:ss") + "\r\n"); //만약 Sql관련 Exception이면 추가항목을 넣어주도록 한다. if (exception.GetType() == typeof(System.Data.SqlClient.SqlException)) { SqlException sqlErr = (SqlException)exception; msg.Append("\r\n[SqlException] "); msg.Append("\r\nException Type: ").Append(sqlErr.GetType()); msg.Append("\r\nErrors: ").Append(sqlErr.Errors); msg.Append("\r\nClass: ").Append(sqlErr.Class); msg.Append("\r\nLineNumber: ").Append(sqlErr.LineNumber); msg.Append("\r\nMessage: ").Append("{" + sqlErr.Message + "}"); msg.Append("\r\nNumber: ").Append(sqlErr.Number); msg.Append("\r\nProcedure: ").Append(sqlErr.Procedure); msg.Append("\r\nServer: ").Append(sqlErr.Server); msg.Append("\r\nState: ").Append(sqlErr.State); msg.Append("\r\nSource: ").Append(sqlErr.Source); msg.Append("\r\nTargetSite: ").Append(sqlErr.TargetSite); msg.Append("\r\nHelpLink: ").Append(sqlErr.HelpLink); } //Sql관련Exception외에 작업들.. else { msg.Append("\r\n[Exception] "); msg.Append("\r\n" + "DetailMsg: {" + exception.Message + "}"); } } catch { //throw ex; } return(msg.ToString()); }