public IEnumerable <IMDMMessage> Persist(SPCmds sp, IMDMMessage md) { Logger.Info($"Persist {md.ToString()}"); foreach (var it in UMD_Data.InsertData(sp, md)) { yield return(it); } }
public IEnumerable <IMDMMessage> Persist(SPCmds sp, IMDMMessage md) { // UMD_Data.InsertData(sp, md); foreach (var it in UMD_Data.InsertData(sp, md)) { yield return(it); } }
public IEnumerable <IMDMMessage> InsertData(SPCmds SP, IMDMMessage dat) { if (dat != null) { switch (SP) { case SPCmds.INSERTMANIFEST: ManifestMasterData mst = (ManifestMasterData)dat; using (cnn = NewConnection()) { using (var adapter = new SqlDataAdapter()) { long manid; using (var command = new SqlCommand(SP.ToString(), cnn)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@DriverId", SqlDbType.Int).Value = 9; //use mst.UserId query the Driver table command.Parameters.AddWithValue("@TRK_CDE", SqlDbType.VarChar).Value = mst.TRK_CDE; command.Parameters.AddWithValue("@SHP_DTE", SqlDbType.Date).Value = mst.SHIP_DTE.Date; command.Parameters.AddWithValue("@DESC$", SqlDbType.VarChar).Value = mst.Desc; command.Parameters.AddWithValue("@LINK", SqlDbType.BigInt).Value = mst.LINK; command.Parameters.AddWithValue("@NOTES", SqlDbType.VarChar).Value = mst.NOTES; var retVal = command.Parameters.Add("@ManifestId", SqlDbType.BigInt); retVal.Direction = ParameterDirection.Output; adapter.InsertCommand = command; adapter.InsertCommand.ExecuteNonQuery(); manid = (long)retVal.Value; mst.ManifestId = manid; yield return(mst); } } } break; case SPCmds.INSERTMANIFESTDETAILS: ManifestDetailsData mdd = (ManifestDetailsData)dat; //SQL = @""; using (cnn = NewConnection()) { using (var adapter = new SqlDataAdapter()) { using (var command = new SqlCommand(SP.ToString(), cnn)) { command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.AddWithValue("@ManifestId", SqlDbType.Int).Value = mdd.ManId; command.Parameters.AddWithValue("@DSP_SEQ", SqlDbType.Int).Value = mdd.DSP_SEQ; command.Parameters.AddWithValue("@DLR_NO", SqlDbType.BigInt).Value = mdd.DLR_NO; adapter.InsertCommand = command; adapter.InsertCommand.ExecuteNonQuery(); yield return(mdd); } } } break; case SPCmds.INSERTORDER: OrderMasterData omd = (OrderMasterData)dat; //SQL = @""; using (cnn = NewConnection()) { using (var adapter = new SqlDataAdapter()) { using (var command = new SqlCommand(SP.ToString(), cnn)) { command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.AddWithValue("@ORD_NO", SqlDbType.BigInt).Value = omd.ORD_NO; command.Parameters.AddWithValue("@DLR_NO", SqlDbType.BigInt).Value = omd.DLR_NO; command.Parameters.AddWithValue("@SHP_DTE", SqlDbType.Date).Value = omd.SHP_DTE.Date; command.Parameters.AddWithValue("@DLR_NME", SqlDbType.VarChar).Value = omd.DLR_NME; command.Parameters.AddWithValue("@SHP_NME", SqlDbType.VarChar).Value = omd.SHP_NME; command.Parameters.AddWithValue("@SHP_ADDR", SqlDbType.VarChar).Value = omd.SHP_ADDR; command.Parameters.AddWithValue("@SHP_ADDR2", SqlDbType.VarChar).Value = omd.SHP_ADDR2; command.Parameters.AddWithValue("@SHP_TEL", SqlDbType.VarChar).Value = omd.SHP_TEL; command.Parameters.AddWithValue("@SHP_ZIP", SqlDbType.VarChar).Value = omd.SHP_ZIP; command.Parameters.AddWithValue("@CUS_NME", SqlDbType.VarChar).Value = omd.CUS_NME; command.Parameters.AddWithValue("@RTE_CDE", SqlDbType.VarChar).Value = omd.RTE_CDE; command.Parameters.AddWithValue("@SHP_QTY", SqlDbType.Int).Value = omd.SHP_QTY; command.Parameters.AddWithValue("@MAN_ID", SqlDbType.Int).Value = omd.ManId; var retVal = command.Parameters.Add("@CustomerIdOut", SqlDbType.Int); retVal.Direction = ParameterDirection.Output; adapter.InsertCommand = command; adapter.InsertCommand.ExecuteNonQuery(); yield return(omd); } } } break; case SPCmds.INSERTORDERDETAILS: OrderDetailsData odd = (OrderDetailsData)dat; //SQL = @""; using (cnn = NewConnection()) { using (var adapter = new SqlDataAdapter()) { using (var command = new SqlCommand(SP.ToString(), cnn)) { command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.AddWithValue("@ORD_NO", SqlDbType.BigInt).Value = odd.ORD_NO; command.Parameters.AddWithValue("@MDL_NO", SqlDbType.Int).Value = odd.MDL_NO; command.Parameters.AddWithValue("@DESC", SqlDbType.VarChar).Value = odd.DESC; command.Parameters.AddWithValue("@CLR", SqlDbType.Int).Value = odd.CLR; command.Parameters.AddWithValue("@WIDTH", SqlDbType.BigInt).Value = odd.WIDTH; command.Parameters.AddWithValue("@HEIGHT", SqlDbType.BigInt).Value = odd.HEIGHT; command.Parameters.AddWithValue("@MDL_CNT", SqlDbType.Int).Value = odd.MDL_CNT; command.Parameters.AddWithValue("@WIN_CNT", SqlDbType.Int).Value = odd.WIN_CNT; command.Parameters.AddWithValue("@Status", SqlDbType.VarChar).Value = "LOADED"; adapter.InsertCommand = command; adapter.InsertCommand.ExecuteNonQuery(); yield return(odd); } } } break; case SPCmds.INSERTORDEROPTIONS: OrderOptionsData oop = (OrderOptionsData)dat; //SQL = @""; using (cnn = NewConnection()) { using (var adapter = new SqlDataAdapter()) { using (var command = new SqlCommand(SP.ToString(), cnn)) { command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.AddWithValue("@ORD_NO", SqlDbType.BigInt).Value = oop.ORD_NO; command.Parameters.AddWithValue("@MDL_NO", SqlDbType.Int).Value = oop.MDL_NO; command.Parameters.AddWithValue("@DESC", SqlDbType.VarChar).Value = oop.DESC; command.Parameters.AddWithValue("@CLR", SqlDbType.Int).Value = oop.CLR; command.Parameters.AddWithValue("@MDL_CNT", SqlDbType.Int).Value = oop.MDL_CNT; // command.Parameters.AddWithValue("@WIN_CNT", SqlDbType.Int).Value = oop.WIN_CNT; command.Parameters.AddWithValue("@Status", SqlDbType.VarChar).Value = "LOADED"; adapter.InsertCommand = command; adapter.InsertCommand.ExecuteNonQuery(); yield return(oop); } } } break; default: throw new Exception("UM SQL Server Stored Procedure Not Found."); } } yield break; }
public IMDMMessage QueryData(Func <OdbcDataReader, IMDMMessage> cb, SPCmds SQL) { throw new NotImplementedException(); }
public void InsertData(SPCmds sql, IMDMMessage msg) { throw new NotImplementedException(); }