public void CreateHondurasRma(string opCode, int rtvShipper, string location, out string error) { var dt = new ObjectParameter("TranDT", typeof(DateTime)); var result = new ObjectParameter("Result", typeof(int)); error = ""; try { using (var context = new MONITOREntities()) { context.usp_CreateRma_Honduras(opCode, rtvShipper, location, dt, result); } } catch (Exception ex) { error = (ex.InnerException == null) ? ex.Message : ex.InnerException.Message; } }
public int CreateHondurasRma(string opCode, int rtvShipper, string location) { var dt = new ObjectParameter("TranDT", typeof(DateTime)); var result = new ObjectParameter("Result", typeof(int)); try { using (var context = new MONITOREntities()) { context.usp_CreateRma_Honduras(opCode, rtvShipper, location, dt, result); _messages.Message = "Success. Created Honduras RMA."; _messages.ShowDialog(); } } catch (Exception ex) { string error = (ex.InnerException == null) ? ex.Message : ex.InnerException.Message; _messages.Message = string.Format("Failed to create Honduras RMA. Error: {0}", error); _messages.ShowDialog(); return(0); } return(1); //string error = ""; ////string connString = "Server=eehsql1;Database=Monitor;Trusted_Connection=Yes;"; //string connString = "Initial Catalog=Monitor;Data Source=eehsql1;Integrated Security=SSPI;"; //int result = 0; //opCode = "5555"; //using (var sqlConnection = new SqlConnection(connString)) //{ // using (var cmd = new SqlCommand()) // { // try // { // cmd.CommandText = "eehsql1.eeh.dbo.eeisp_insert_EEH_RMA_from_EEI_RTV_withLocation"; // cmd.CommandType = CommandType.StoredProcedure; // //cmd.Parameters.AddWithValue("@OperatorPWD", opCode); // //cmd.Parameters.AddWithValue("@ShipperID", rtvShipper); // //cmd.Parameters.AddWithValue("@LocationCode", location); // //cmd.Parameters.AddWithValue("@Result", result); // cmd.Parameters.Add("@OperatorPWD", SqlDbType.VarChar).Value = opCode; // cmd.Parameters.Add("@ShipperID", SqlDbType.Int).Value = rtvShipper; // cmd.Parameters.Add("@LocationCode", SqlDbType.VarChar).Value = location; // cmd.Parameters.Add("@Result", SqlDbType.Int).Value = result; // cmd.Parameters["@Result"].Direction = ParameterDirection.Output; // //cmd.Parameters.Add("@Result", SqlDbType.Int).Direction = ParameterDirection.Output; // cmd.Connection = sqlConnection; // sqlConnection.Open(); // cmd.ExecuteNonQuery(); // _messages.Message = "Success - created Honduras RMA."; // _messages.ShowDialog(); // } // catch (Exception ex) // { // error = (ex.InnerException == null) ? ex.Message : ex.InnerException.Message; // _messages.Message = String.Format("Failed to RMA to Honduras location {0}. Error: {1}", location, error); // _messages.ShowDialog(); // } // } //} //return (error == "") ? 1 : 0; }