public static List <TransferOrderHeader> GetTransferOrderHeaderAsListForStatus(DataTable dt)
        {
            List <TransferOrderHeader> oList = new List <TransferOrderHeader>();

            foreach (DataRow row in dt.Rows)
            {
                try
                {
                    TransferOrderHeader o = new TransferOrderHeader();
                    o.OrderNum = Helper.ConvertToInt(row["ORDER_NUM"].ToString());
                    o.OrderSchedReplenishDate = Helper.ConvertToDate(row["ORDER_SCHED_REPLENISH_DATE"]);
                    o.OrderFacilityFrom       = row["ORDER_FACILITY_FROM"].ToString();
                    o.OrderFacilityTo         = row["ORDER_FACILITY_TO"].ToString();
                    o.OrderCarrier            = row["ORDER_CARRIER"].ToString();
                    o.OrderStatusName         = row["ORDER_STATUS"].ToString();
                    o.ModifiedOn = Helper.ConvertToDate(row["MODIFIED_ON"]);
                    o.ModifiedBy = Helper.ConvertToInt(row["MODIFIED_BY"]);
                    o.RevNum     = Helper.ConvertToInt(row["REV_NUM"]);
                    oList.Add(o);
                }
                catch (Exception ex)
                {
                    Log.InsertEntity("TransferOrderHeader", "GetTransferOrderHeaderAsList", 1, ex.StackTrace.Replace("'", ""), ex.Message.Replace("'", ""));
                    throw ex;
                }
            }
            return(oList);
        }
 public static int Update(TransferOrderHeader o)
 {
     try
     {
         string query = @"UPDATE ""TRANSFER_ORDER_HEADER"" SET ""ORDER_SCHED_REPLENISH_DATE"" = @OrderSchedReplenishDate, ""ORDER_FACILITY_FROM"" = @OrderFacilityFrom, ""ORDER_FACILITY_TO"" = @OrderFacilityTo, ""ORDER_CARRIER"" = @OrderCarrier, ""ORDER_STATUS"" = @OrderStatus, ""MODIFIED_ON"" = @ModifiedOn, ""MODIFIED_BY"" = @ModifiedBy, ""REV_NUM"" = @RevNum WHERE ""ORDER_NUM"" = @OrderNum ";
         List <Npgsql.NpgsqlParameter> parameters = new List <NpgsqlParameter>()
         {
             new NpgsqlParameter("@OrderNum", DbType.Int32)
             {
                 Value = o.OrderNum
             },
             new NpgsqlParameter("@OrderSchedReplenishDate", DbType.Date)
             {
                 Value = o.OrderSchedReplenishDate
             },
             new NpgsqlParameter("@OrderFacilityFrom", DbType.String)
             {
                 Value = o.OrderFacilityFrom
             },
             new NpgsqlParameter("@OrderFacilityTo", DbType.String)
             {
                 Value = o.OrderFacilityTo
             },
             new NpgsqlParameter("@OrderCarrier", DbType.String)
             {
                 Value = (object)o.OrderCarrier ?? DBNull.Value
             },
             new NpgsqlParameter("@OrderStatus", DbType.Int32)
             {
                 Value = o.OrderStatus
             },
             new NpgsqlParameter("@ModifiedOn", DbType.Date)
             {
                 Value = o.ModifiedOn
             },
             new NpgsqlParameter("@ModifiedBy", DbType.Int32)
             {
                 Value = o.ModifiedBy
             },
             new NpgsqlParameter("@RevNum", DbType.Int32)
             {
                 Value = o.RevNum
             }
         };
         int rowAffected = DBManager.ExecuteNonQueryCommand(query, CommandType.Text, parameters);
         AuditTable.InsertEntity("TransferOrderHeader", o.OrderNum.ToString(), 2, DateTime.Now, o.ModifiedBy);
         return(rowAffected);
     }
     catch (Exception ex)
     {
         Log.InsertEntity("TransferOrderHeader", "Update", 2, ex.StackTrace.Replace("'", ""), ex.Message.Replace("'", ""));
     }
     return(-1);
 }
        public static int Insert(TransferOrderHeader o)
        {
            try
            {
                string query = @"INSERT INTO ""TRANSFER_ORDER_HEADER"" (""ORDER_SCHED_REPLENISH_DATE"", ""ORDER_FACILITY_FROM"", ""ORDER_FACILITY_TO"", ""ORDER_CARRIER"", ""ORDER_STATUS"", ""MODIFIED_ON"", ""MODIFIED_BY"", ""REV_NUM"") VALUES (@OrderSchedReplenishDate, @OrderFacilityFrom, @OrderFacilityTo, @OrderCarrier, @OrderStatus, @ModifiedOn, @ModifiedBy, @RevNum) returning ""ORDER_NUM"" ";
                List <Npgsql.NpgsqlParameter> parameters = new List <NpgsqlParameter>()
                {
                    //new NpgsqlParameter("@OrderNum", DbType.Int32)  { Value = o.OrderNum },
                    new NpgsqlParameter("@OrderSchedReplenishDate", DbType.Date)
                    {
                        Value = o.OrderSchedReplenishDate
                    },
                    new NpgsqlParameter("@OrderFacilityFrom", DbType.String)
                    {
                        Value = o.OrderFacilityFrom
                    },
                    new NpgsqlParameter("@OrderFacilityTo", DbType.String)
                    {
                        Value = o.OrderFacilityTo
                    },
                    new NpgsqlParameter("@OrderCarrier", DbType.String)
                    {
                        Value = (object)o.OrderCarrier ?? DBNull.Value
                    },
                    new NpgsqlParameter("@OrderStatus", DbType.Int32)
                    {
                        Value = o.OrderStatus
                    },
                    new NpgsqlParameter("@ModifiedOn", DbType.Date)
                    {
                        Value = o.ModifiedOn
                    },
                    new NpgsqlParameter("@ModifiedBy", DbType.Int32)
                    {
                        Value = o.ModifiedBy
                    },
                    new NpgsqlParameter("@RevNum", DbType.Int32)
                    {
                        Value = o.RevNum
                    }
                };

                object id = DBManager.ExecuteScalarCommand(query, CommandType.Text, parameters);
                AuditTable.InsertEntity("TransferOrderHeader", id.ToString(), 1, DateTime.Now, o.ModifiedBy);
                return(int.Parse(id.ToString()));
            }
            catch (Exception ex)
            {
                Log.InsertEntity("TransferOrderHeader", "Insert", 1, ex.StackTrace.Replace("'", ""), ex.Message.Replace("'", ""));
            }
            return(-1);
        }